@sveltejs/vite-plugin-svelte 1.0.0-next.39 → 1.0.0-next.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1170,7 +1170,7 @@ function enforceOptionsForProduction(options) {
1170
1170
  function resolveViteRoot(viteConfig) {
1171
1171
  return normalizePath2(viteConfig.root ? path3.resolve(viteConfig.root) : process.cwd());
1172
1172
  }
1173
- function buildExtraViteConfig(options, config, configEnv) {
1173
+ function buildExtraViteConfig(options, config) {
1174
1174
  const svelteDeps = findRootSvelteDependencies(options.root);
1175
1175
  const extraViteConfig = {
1176
1176
  resolve: {
@@ -1178,10 +1178,10 @@ function buildExtraViteConfig(options, config, configEnv) {
1178
1178
  dedupe: [...SVELTE_IMPORTS, ...SVELTE_HMR_IMPORTS]
1179
1179
  }
1180
1180
  };
1181
- if (configEnv.command === "serve") {
1181
+ if (options.isServe) {
1182
1182
  extraViteConfig.optimizeDeps = buildOptimizeDepsForSvelte(svelteDeps, options, config.optimizeDeps);
1183
1183
  }
1184
- extraViteConfig.ssr = buildSSROptionsForSvelte(svelteDeps, options, config);
1184
+ extraViteConfig.ssr = buildSSROptionsForSvelte(svelteDeps, options, config, extraViteConfig);
1185
1185
  return extraViteConfig;
1186
1186
  }
1187
1187
  function buildOptimizeDepsForSvelte(svelteDeps, options, optimizeDeps2) {
@@ -1244,9 +1244,16 @@ function buildSSROptionsForSvelte(svelteDeps, options, config) {
1244
1244
  var _a2, _b2, _c2, _d;
1245
1245
  return !((_b2 = (_a2 = config.ssr) == null ? void 0 : _a2.external) == null ? void 0 : _b2.includes(x)) && !((_d = (_c2 = config.optimizeDeps) == null ? void 0 : _c2.include) == null ? void 0 : _d.includes(x));
1246
1246
  }));
1247
- return {
1247
+ const ssr = {
1248
1248
  noExternal
1249
1249
  };
1250
+ if (options.isServe) {
1251
+ ssr.external = Array.from(new Set(svelteDeps.flatMap((dep) => Object.keys(dep.pkg.dependencies || {})))).filter((dep) => {
1252
+ var _a2, _b2, _c2, _d;
1253
+ 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));
1254
+ });
1255
+ }
1256
+ return ssr;
1250
1257
  }
1251
1258
  function patchResolvedViteConfig(viteConfig, options) {
1252
1259
  var _a, _b;
@@ -1522,7 +1529,7 @@ function svelte(inlineOptions) {
1522
1529
  log.setLevel(config.logLevel);
1523
1530
  }
1524
1531
  options = await preResolveOptions(inlineOptions, config, configEnv);
1525
- const extraViteConfig = buildExtraViteConfig(options, config, configEnv);
1532
+ const extraViteConfig = buildExtraViteConfig(options, config);
1526
1533
  log.debug("additional vite config", extraViteConfig);
1527
1534
  return extraViteConfig;
1528
1535
  },