-
Notifications
You must be signed in to change notification settings - Fork 82
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
feat: svelte config util #59
base: master
Are you sure you want to change the base?
Conversation
I like this very much! About drawbacks: None of the listed are of concern to me, I think they force us to have a good talk about the config which is a good thing. I also don't think that the overhead is that big (bundlesize-wise). I have one question about namespaces: I remember you mentioning that you could repeat top level entries in the namespace to overwrite the top level entries. Is that part of the solution? If yes, could you detail that part a little? |
I had that added already but changed my mind. I think the inlineOptions in loadConfig give tools enough freedom |
Sounds good. If we later feel it's needed we can always add it in a backwards-compatible way |
Regarding validation, I think it's of Rich's interest to re-use the code from Kit (also mentioned in RFC), and avoid a third-party library for it. I've made a pull request in the past to convert to superstruct, but was closed because the package size is quite hefty, and the error messages aren't really friendly. In my experience refactoring that, making Kit's validation generic won't be easy unless we draw the line on the kind of validations we would only support. Otherwise, if someone can suggest an alternative mini validation library, would be nice too. Or another route we could go is to dismiss validation all together and rely on types only. |
Linking to past discussion about this for reference: sveltejs/vite-plugin-svelte#146. There was a fair amount of discussion around what should be a top-level shared key vs living under a namespace for each bundler |
One more question about transpiling TS->JS: would that affect the config file only, or would all transitive imports be transpiled as well? People will expect the latter I guess, but I'm not sure how this could be implemented right now. |
For |
postcss-load-config uses ts-node too but i'd rather not introduce that and stick with esbuild as thats more likely to be available already via vite/sveltekit. |
Had a chat with @bluwy about this, takeaways:
|
It seems like people are generally in favor of this, so what needs to be done to finalize this RFC and move it forward? Is there an "acting maintainer" for svelte-loader that should be pinged about this? |
I've just read the RFC and it looks good to me! Got nothing to add and I agree with leaving the validation for a later release. Very nice standardization initiative 🙏 |
Maybe @DeMoorJasper from parcel-plugin-svelte could chime in too. IIRC parcel has its own config reading logic, plus parcel will have some big news coming soon (might affect this). So if it's not possible for them to use |
cc @drwpow and @FredKSchott for snowpack plugin svelte |
@Conduitry might have some insights for rollup-plugin-svelte about this. @lukeed might have some ideas about transpiling TS on the fly, maybe the new tsm-package can help with that? |
For parcel we'd need some way to invalidate our cache on config changes, so in this case we'd need to know which files have been looked at to find the config and which file(s) contain the config. Also preferably a preference towards non-js config files as js configs can't be statically checked and would require us to invalidate the cache of every svelte file every time the bundler restarts. A way to define some defaults would probably also be nice. |
Non-js config files will very likely be impossible, kit already has some settings which expect a function |
This might be tricky since ideally we would normally
I think |
@non25 has probably been the most active person on that repo |
Looks good, maybe we could finally configure compiler-related options for language server, eslint and plugin/loader in one place. |
We need to leave things like prettier or eslint out of this since they have an established config style already, and in the case of eslint they need commonjs configs. But I agree that rollup/webpack plugins could start using this, too, and as Dominik mentioned in the RFC, provide their own options within a namespace like |
leaving this here as a reminder: sveltejs/kit#3219 add error handling for missing config file including links to documentation how to add/use svelte config |
Hi @dominikg is this the final takeaways? This RFC provides the guide for @sveltejs/config package which helps svelte kit to bundle/transpile For So the idea is to make @sveltejs/config support different bundlers with namespace? |
options = { | ||
fromDir: '/some/path', // process.cwd by default, tools can pass what they need, eg vite root | ||
inlineConfig: {/*...*/}, // svelte config object built from inline options eg cli args passed to the tool. merged in | ||
namespace: 'kit', // namespace for the tool loading the config, useful for advanced features |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean this one
+ namespace: 'kit', // namespace for the tool loading the config, useful for advanced features
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if sveltekit calls @sveltejs/config
to load the svelte config, it can identify itself which enables sveltejs/config to implement some kit specific features or just have better logging.
|
||
### To users | ||
|
||
Currently, svelte.config.js isn't really documented on its own. The tools show how they use it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just add README.md in @sveltejs/config
packages folder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be hard to keep in sync for the different namespaces where the actual type depends on the version used (eg sveltekit3 is going to have config changes that need documenting)
We do have some ideas for improving documentation discoverability though
Please share additional ideas. I'm willing to implement it once finalized.