tomblachut / svelte-intellij

Svelte components in WebStorm and friends
MIT License
482 stars 38 forks source link

Improve auto import for components from node_modules #61

Closed elliotwaite closed 3 years ago

elliotwaite commented 4 years ago

Auto import will duplicate an already imported named import.

Here's a video demo: https://youtu.be/mrJlFoHUUkk (deleted)

It would also be nice if there was an option to disable auto imports.

tomblachut commented 4 years ago

Thanks for reporting, but could you check if the title is correct? Support for node modules is ATM incomplete and I'm guessing this is the real issue here. Importing project's components should work.

elliotwaite commented 4 years ago

Ah, if node modules aren't supported yet, that's probably the issue.

I'm not sure what you mean by checking if the title is correct. Can you clarify? The title of this GitHub issue, or the name of the imported component, or something else?

Also, I'm not sure if this is related, but the DrawerTitle component that I'm importing in the video demo is a component I'm developing for an NPM package, so it exists in two locations: in node_modules/@svelte-material/drawer (the node modules path) and in packages/drawer (the development path). And the node_modules/@svelte-material/drawer path just aliases to the packages/drawer path to allow for seamless development.

I'll have to check back in when node modules support is added to see if it also works for my dual location use case.

Thanks for your efforts.

tomblachut commented 4 years ago

Happy to help :)

I mean title of the GitHub issue. It says that named imports are problematic but I think we now agree that it's related to import path/node_modules and named imports work okay outside of that. I'd like you to check if that is in fact true or maybe there is another bug, and update title to match.

I'll have to check back in when node modules support is added to see if it also works for my dual location use case.

That would be great! It could be related but I don't have enough info right now to verify your situation with two locations. Anyway I hope node_modules fix will also help with that.

elliotwaite commented 4 years ago

Ah, got it. Updated the title.

I just tested it and was still getting errors when the components were outside of the node_modules dir, but I think it's mainly an issue with the plugin not being able to find named exports. But I think adding node modules support will also cover making named exports work in general.

tomblachut commented 4 years ago

Great, thanks.