-
Notifications
You must be signed in to change notification settings - Fork 916
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
Use svelte.config.js's extensions for plugin-svelte input #1373
Use svelte.config.js's extensions for plugin-svelte input #1373
Conversation
…e (and not overridden by plugin config)
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/pikapkg/snowpack/8ek70b5vs |
Can you share a link to where this is documented as correct in a I'm +1 on this PR, but in the past we've been bitten by matching other plugins and then realizing that the Svelte team had a different recommended API/pattern. |
There is no such doc nor recommendation inside of language-tools from what I can tell. Rollup plugin is the only thing I am aware of with an |
@FredKSchott @firefish5000 When I look at the Webpack loader (https://github.com/sveltejs/svelte-loader#usage) I see it referencing fwiw, I was migrating to snowpack from svite and it had this convention. I was actually baffled for a bit as to why my |
Okay, I'm feeling good about this then! +1 to merging by EOD today or tomorrow, in case @Rich-Harris has any last minute thoughts |
@techniq Note that webpack config only uses const svelteExtensions = ['.svelte','.svx']
...
resolve: {
alias: {
svelte: path.resolve('node_modules', 'svelte')
},
// Note this is not equivalent to the svelte rollup plugin's `extensions` field as it must specify extensions
// for all import statements webpack can resolve. Svelte is merely one of the things it can resolve
extensions: ['.js','.ts','.css', ...svelteExtensions]
mainFields: ['svelte', 'browser', 'module', 'main']
},
module: {
rules: [
...
{
// This is the code for the svelte loader, it uses a regex. We could easily build this from the svelteExtensions,
// but its certainly not a direct relationship as this syntax is more powerful at the cost of being one of the
// causes for webpacks config hell
test: /\.(svelte|svx)$/,
exclude: /node_modules/,
use: 'svelte-loader'
}
...
]
} This could certainly be made to use extensions, but atm, neither language-tools nor the default config for svelte-webpack and svelte-rollup support loading from svelte.config.js. The main issue is it is a non-standard field that we would be imposing a (albeit intuitive, as I use it as well in the same way) expected value for in a config file we do not own. |
Changes
Uses
svelte.config.js
's extensions for plugin-svelte input if available (and not overridden by plugin config). This will cut down on duplicated configuration.Testing
I wasn't for certain how best to update the tests for this change.
Docs
Update
input
section of README