question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I’m unfortunately stuck with a framework that encourages using non-standard .vue files. Would be amazing if unimported could parse them.

Should be rather easy to implement an MVP version IMO, as the most important part would basically be to just ignore everything outside of the <script> block (as that’s not JS/TS) and interpret the result as (j|t)sx?


yarn run v1.22.10
$ ./node_modules/.bin/unimported .
⠙ resolving imports
Failed parsing ./source/SomeVueFile.vue
{
  index: 34,
  lineNumber: 2,
  column: 23,
  message: 'Identifier expected.'
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
smeijercommented, Aug 5, 2021

This should work now, albeit in a basic form.

I just strip the content from the <script>...</script> tag using string mutations (because I don’t want to include a heavy html parser), and use that as the source. So there are some limitations. The most important one, both those tags need to stand on their own line! But I think that’s a good convention to use anyways 😅

In other words. This works:

<template>...</template>
<script>
  ...
</script>

This does not:

<template>...</template>
<script>...</script>

I also only support a single <script> tag per .vue file, as vue seems to have that limitation as well;

The example project also does something smart regarding two build targets and aliasing create-api to create-api-client or create-api-server depending on which build config is used. Note that this is something that unimported currently does not support.

To enable support for vue projects, add the .vue extension to your .unimportedrc.json config. For example, this is the config I used on the hackernews project:

{
  "entry": ["src/entry-client.js", "src/entry-server.js"],
  "extensions": [".js", ".vue"],
  "aliases": {
    "create-api": ["./src/api/create-api-client"]
  }
}

Please let me know if this works for you. (support added in v1.17.0)

1reaction
FlorianWendelborncommented, Aug 9, 2021

@smeijer I can confirm that upgrading to 1.18.0 and removing the previous patch-package patch still works as expected. Thanks for the fix

Read more comments on GitHub >

github_iconTop Results From Across the Web

Contact Pearson VUE
There are many ways to contact Pearson VUE. This page lists all of the ways to contact us so that your question can...
Read more >
Vue.js - The Progressive JavaScript Framework | Vue.js
Builds on top of standard HTML, CSS and JavaScript with intuitive API and world-class documentation. Performant. Truly reactive, compiler-optimized rendering ...
Read more >
Using Vue with TypeScript - Vue.js
Vue is written in TypeScript itself and provides first-class TypeScript support. All official Vue packages come with bundled type declarations that should ...
Read more >
Frequently Asked Questions - Vue.js
If you are starting a new project today, Vue 3 is the recommended choice. There are only a few reasons for you to...
Read more >
Releases - Vue.js
Sometimes TypeScript itself ships incompatible changes between minor versions, and we may have to adjust types to support newer versions of TypeScript.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found