Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support autocompleted or aliased imports #105

Closed
jacob-8 opened this issue May 21, 2020 · 4 comments
Closed

Support autocompleted or aliased imports #105

jacob-8 opened this issue May 21, 2020 · 4 comments

Comments

@jacob-8
Copy link

jacob-8 commented May 21, 2020

Is your feature request related to a problem? Please describe.
When adding or refactoring routed .svelte files in Sapper, it is quite tedious to use the correct import path for components. Is it "../components/View.svelte" or "../../components/View.svelte", etc...

Describe the solution you'd like
Auto component import: when I start typing <View into a .svelte file, I would like a tooltip offering to import matching component(s).
Additionally, when refactoring, I would like the editor to ask if I would like to update import paths as it does with Angular, for example.

Describe alternatives you've considered
An alternative would be to support the use of rollup-plugin-alias as seen in https://github.com/sveltecasts/010-rollup-alias/blob/master/rollup.config.js#L18 so that we can simply type import View from "@components/View.svelte";
Note that I'm using a simpler implementation of rollup-plugin-alias:

const aliases = alias({
	resolve: ['.jsx', '.js', '.tsx', '.ts', '.svelte'],
	entries: [
		{ find: '@components', replacement: `${__dirname}/src/components`},
		{ find: '@routes', replacement: `${__dirname}/src/routes`},
	]
})

And it would be even more awesome if BOTH could be supported. Thanks for the great work!

@jasonlyu123
Copy link
Member

jasonlyu123 commented May 21, 2020

Lastest version of svelte beta support component auto import and import completion. But rename files and symbols still need some works.
The route alias is also supported but you would have to configure it though tsconfig/jsconfig.json
you can check out https://code.visualstudio.com/docs/languages/jsconfig#_using-webpack-aliases and https://www.typescriptlang.org/docs/handbook/module-resolution.html#base-url for more info

@jacob-8
Copy link
Author

jacob-8 commented May 21, 2020

Great to hear! Thanks.

But rename files and symbols still need some works

Should we close this or rename it to hone focus in on that feature?

@dummdidumm
Copy link
Member

I would prefer to close this one and open one feature request for rename symbols and one for file renames/moves (I think these two are very different things to implement).

@dummdidumm
Copy link
Member

Closing in favor of #110 and #111

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants