@sveltejs/vite-plugin-svelte
Advanced tools
Comparing version 1.0.0-next.39 to 1.0.0-next.40
@@ -1173,3 +1173,3 @@ var __defProp = Object.defineProperty; | ||
} | ||
function buildExtraViteConfig(options, config, configEnv) { | ||
function buildExtraViteConfig(options, config) { | ||
const svelteDeps = findRootSvelteDependencies(options.root); | ||
@@ -1182,6 +1182,6 @@ const extraViteConfig = { | ||
}; | ||
if (configEnv.command === "serve") { | ||
if (options.isServe) { | ||
extraViteConfig.optimizeDeps = buildOptimizeDepsForSvelte(svelteDeps, options, config.optimizeDeps); | ||
} | ||
extraViteConfig.ssr = buildSSROptionsForSvelte(svelteDeps, options, config); | ||
extraViteConfig.ssr = buildSSROptionsForSvelte(svelteDeps, options, config, extraViteConfig); | ||
return extraViteConfig; | ||
@@ -1249,5 +1249,12 @@ } | ||
})); | ||
return { | ||
const ssr = { | ||
noExternal | ||
}; | ||
if (options.isServe) { | ||
ssr.external = Array.from(new Set(svelteDeps.flatMap((dep) => Object.keys(dep.pkg.dependencies || {})))).filter((dep) => { | ||
var _a2, _b2, _c2, _d; | ||
return !ssr.noExternal.includes(dep) && !((_b2 = (_a2 = config.ssr) == null ? void 0 : _a2.noExternal) == null ? void 0 : _b2.includes(dep)) && !((_d = (_c2 = config.ssr) == null ? void 0 : _c2.external) == null ? void 0 : _d.includes(dep)); | ||
}); | ||
} | ||
return ssr; | ||
} | ||
@@ -1528,3 +1535,3 @@ function patchResolvedViteConfig(viteConfig, options) { | ||
options = await preResolveOptions(inlineOptions, config, configEnv); | ||
const extraViteConfig = buildExtraViteConfig(options, config, configEnv); | ||
const extraViteConfig = buildExtraViteConfig(options, config); | ||
log.debug("additional vite config", extraViteConfig); | ||
@@ -1531,0 +1538,0 @@ return extraViteConfig; |
{ | ||
"name": "@sveltejs/vite-plugin-svelte", | ||
"version": "1.0.0-next.39", | ||
"version": "1.0.0-next.40", | ||
"license": "MIT", | ||
@@ -43,7 +43,7 @@ "author": "dominikg", | ||
"dependencies": { | ||
"@rollup/pluginutils": "^4.1.2", | ||
"@rollup/pluginutils": "^4.2.0", | ||
"debug": "^4.3.3", | ||
"kleur": "^4.1.4", | ||
"magic-string": "^0.25.7", | ||
"svelte-hmr": "^0.14.9" | ||
"magic-string": "^0.26.1", | ||
"svelte-hmr": "^0.14.11" | ||
}, | ||
@@ -64,7 +64,7 @@ "peerDependencies": { | ||
"diff-match-patch": "^1.0.5", | ||
"esbuild": "^0.14.23", | ||
"rollup": "^2.68.0", | ||
"esbuild": "^0.14.26", | ||
"rollup": "^2.70.1", | ||
"svelte": "^3.46.4", | ||
"tsup": "^5.11.13", | ||
"vite": "^2.8.4" | ||
"tsup": "^5.12.1", | ||
"vite": "^2.8.6" | ||
}, | ||
@@ -71,0 +71,0 @@ "scripts": { |
@@ -58,3 +58,3 @@ import fs from 'fs'; | ||
// extra vite config | ||
const extraViteConfig = buildExtraViteConfig(options, config, configEnv); | ||
const extraViteConfig = buildExtraViteConfig(options, config); | ||
log.debug('additional vite config', extraViteConfig); | ||
@@ -61,0 +61,0 @@ return extraViteConfig; |
@@ -187,4 +187,3 @@ /* eslint-disable no-unused-vars */ | ||
options: PreResolvedOptions, | ||
config: UserConfig, | ||
configEnv: ConfigEnv | ||
config: UserConfig | ||
): Partial<UserConfig> { | ||
@@ -204,3 +203,3 @@ // extra handling for svelte dependencies in the project | ||
if (configEnv.command === 'serve') { | ||
if (options.isServe) { | ||
extraViteConfig.optimizeDeps = buildOptimizeDepsForSvelte( | ||
@@ -214,3 +213,3 @@ svelteDeps, | ||
// @ts-ignore | ||
extraViteConfig.ssr = buildSSROptionsForSvelte(svelteDeps, options, config); | ||
extraViteConfig.ssr = buildSSROptionsForSvelte(svelteDeps, options, config, extraViteConfig); | ||
@@ -300,3 +299,3 @@ return extraViteConfig; | ||
if (options.isBuild && config.build?.ssr) { | ||
// @ts-ignore | ||
// @ts-expect-error ssr still flagged in vite | ||
if (!config.ssr?.external?.includes('svelte')) { | ||
@@ -316,9 +315,26 @@ noExternal.push('svelte'); | ||
...Array.from(new Set(svelteDeps.map((s) => s.name))).filter((x) => { | ||
// @ts-ignore | ||
// @ts-expect-error ssr still flagged in vite | ||
return !config.ssr?.external?.includes(x) && !config.optimizeDeps?.include?.includes(x); | ||
}) | ||
); | ||
return { | ||
const ssr = { | ||
noExternal | ||
}; | ||
if (options.isServe) { | ||
// during dev, we have to externalize transitive dependencies, see https://github.com/sveltejs/vite-plugin-svelte/issues/281 | ||
// @ts-expect-error ssr still flagged in vite | ||
ssr.external = Array.from( | ||
new Set(svelteDeps.flatMap((dep) => Object.keys(dep.pkg.dependencies || {}))) | ||
).filter( | ||
(dep) => | ||
!ssr.noExternal.includes(dep) && | ||
// @ts-expect-error ssr still flagged in vite | ||
!config.ssr?.noExternal?.includes(dep) && | ||
// @ts-expect-error ssr still flagged in vite | ||
!config.ssr?.external?.includes(dep) | ||
); | ||
} | ||
return ssr; | ||
} | ||
@@ -325,0 +341,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
443060
5777
+ Addedmagic-string@0.26.7(transitive)
- Removedmagic-string@0.25.9(transitive)
Updated@rollup/pluginutils@^4.2.0
Updatedmagic-string@^0.26.1
Updatedsvelte-hmr@^0.14.11