Support Vue
See original GitHub issueI’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:
- Created 3 years ago
- Reactions:2
- Comments:13 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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:
This does not:
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
tocreate-api-client
orcreate-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:Please let me know if this works for you. (support added in
v1.17.0
)@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