-
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
Simplify. cleanup, enhance snowpack internals #2707
Changes from all commits
ab38057
c8d5062
7a929ba
d876119
7b1bc00
8f26514
e4f931a
95e8672
159d50a
adf2580
892834b
72d5dd8
600cbaf
5ad4565
d26e13d
a341e48
d493acd
31f1a4a
eb0fd54
a3683ff
7371bdd
5b17018
72e076f
20ee69e
c424ed3
4f93348
2145e29
17f171e
c67883c
510e0fe
d5b2c05
b743c11
ab57bc7
cd49f8e
1069e26
1e82589
a4bbb5a
b7a5031
7bf6df1
59560fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,22 +13,27 @@ module.exports = function plugin(snowpackConfig, pluginOptions = {}) { | |
const isDev = process.env.NODE_ENV !== 'production'; | ||
const useSourceMaps = | ||
snowpackConfig.buildOptions.sourcemap || snowpackConfig.buildOptions.sourceMaps; | ||
// Old Snowpack versions wouldn't build dependencies. Starting in v3.1, Snowpack's build pipeline | ||
// is run on all files, including npm package files. The rollup plugin is no longer needed. | ||
const needsRollupPlugin = typeof snowpackConfig.buildOptions.resolveProxyImports === 'undefined'; | ||
|
||
// Support importing Svelte files when you install dependencies. | ||
const packageOptions = snowpackConfig.packageOptions || snowpackConfig.installOptions; | ||
if (packageOptions.source === 'local') { | ||
packageOptions.rollup = packageOptions.rollup || {}; | ||
packageOptions.rollup.plugins = packageOptions.rollup.plugins || []; | ||
packageOptions.rollup.plugins.push( | ||
svelteRollupPlugin({ | ||
include: /\.svelte$/, | ||
compilerOptions: {dev: isDev}, | ||
// Snowpack wraps JS-imported CSS in a JS wrapper, so use | ||
// Svelte's own first-class `emitCss: false` here. | ||
// TODO: Remove once Snowpack adds first-class CSS import support in deps. | ||
emitCss: false, | ||
}), | ||
); | ||
if (needsRollupPlugin) { | ||
packageOptions.rollup = packageOptions.rollup || {}; | ||
packageOptions.rollup.plugins = packageOptions.rollup.plugins || []; | ||
packageOptions.rollup.plugins.push( | ||
svelteRollupPlugin({ | ||
include: /\.svelte$/, | ||
compilerOptions: {dev: isDev}, | ||
// Snowpack wraps JS-imported CSS in a JS wrapper, so use | ||
// Svelte's own first-class `emitCss: false` here. | ||
// TODO: Remove once Snowpack adds first-class CSS import support in deps. | ||
emitCss: false, | ||
}), | ||
); | ||
} | ||
// Support importing sharable Svelte components. | ||
packageOptions.packageLookupFields.push('svelte'); | ||
} | ||
|
@@ -97,7 +102,7 @@ module.exports = function plugin(snowpackConfig, pluginOptions = {}) { | |
'svelte-hmr/runtime/hot-api-esm.js', | ||
'svelte-hmr/runtime/proxy-adapter-dom.js', | ||
], | ||
async load({filePath, isHmrEnabled, isSSR}) { | ||
async load({filePath, isHmrEnabled, isSSR, isPackage}) { | ||
let codeToCompile = await fs.promises.readFile(filePath, 'utf-8'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: |
||
// PRE-PROCESS | ||
if (preprocessOptions !== false) { | ||
|
@@ -110,9 +115,9 @@ module.exports = function plugin(snowpackConfig, pluginOptions = {}) { | |
|
||
const finalCompileOptions = { | ||
generate: isSSR ? 'ssr' : 'dom', | ||
css: false, | ||
css: isPackage ? true : false, | ||
...compilerOptions, // Note(drew) should take precedence over generate above | ||
dev: isDev, | ||
dev: isHmrEnabled || isDev, | ||
outputFilename: filePath, | ||
filename: filePath, | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,19 +45,19 @@ | |
"vendor" | ||
], | ||
"dependencies": { | ||
"cli-spinners": "^2.5.0", | ||
"default-browser-id": "^2.0.0", | ||
"esbuild": "^0.8.7", | ||
"open": "^7.0.4", | ||
"rollup": "^2.34.0", | ||
"resolve": "^1.20.0" | ||
"resolve": "^1.20.0", | ||
"rollup": "^2.34.0" | ||
}, | ||
"optionalDependencies": { | ||
"fsevents": "^2.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/cheerio": "0.22.22", | ||
"bufferutil": "^4.0.2", | ||
"cacache": "^15.0.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 |
||
"cachedir": "^2.3.0", | ||
"cheerio": "1.0.0-rc.3", | ||
"chokidar": "^3.4.0", | ||
|
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.
👍🏻