@sveltejs/vite-plugin-svelte 1.0.9 → 1.1.0

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.cjs CHANGED
@@ -31,7 +31,7 @@ __export(src_exports, {
31
31
  });
32
32
  module.exports = __toCommonJS(src_exports);
33
33
 
34
- // ../../node_modules/.pnpm/tsup@6.2.3/node_modules/tsup/assets/cjs_shims.js
34
+ // ../../node_modules/.pnpm/tsup@6.3.0/node_modules/tsup/assets/cjs_shims.js
35
35
  var getImportMetaUrl = () => typeof document === "undefined" ? new URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
36
36
  var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
37
37
 
@@ -415,8 +415,8 @@ function createCompileSvelte(options) {
415
415
  }
416
416
 
417
417
  // src/utils/id.ts
418
- var import_pluginutils = require("@rollup/pluginutils");
419
418
  var import_vite = require("vite");
419
+ var import_vite2 = require("vite");
420
420
  var fs = __toESM(require("fs"), 1);
421
421
  var VITE_FS_PREFIX = "/@fs/";
422
422
  var IS_WINDOWS = process.platform === "win32";
@@ -465,7 +465,7 @@ function parseRequestQuery(rawQuery) {
465
465
  return query;
466
466
  }
467
467
  function normalize(filename, normalizedRoot) {
468
- return stripRoot((0, import_vite.normalizePath)(filename), normalizedRoot);
468
+ return stripRoot((0, import_vite2.normalizePath)(filename), normalizedRoot);
469
469
  }
470
470
  function existsInRoot(filename, root) {
471
471
  if (filename.startsWith(VITE_FS_PREFIX)) {
@@ -477,12 +477,12 @@ function stripRoot(normalizedFilename, normalizedRoot) {
477
477
  return normalizedFilename.startsWith(normalizedRoot + "/") ? normalizedFilename.slice(normalizedRoot.length) : normalizedFilename;
478
478
  }
479
479
  function buildFilter(include, exclude, extensions) {
480
- const rollupFilter = (0, import_pluginutils.createFilter)(include, exclude);
480
+ const rollupFilter = (0, import_vite.createFilter)(include, exclude);
481
481
  return (filename) => rollupFilter(filename) && extensions.some((ext) => filename.endsWith(ext));
482
482
  }
483
483
  function buildIdParser(options) {
484
484
  const { include, exclude, extensions, root } = options;
485
- const normalizedRoot = (0, import_vite.normalizePath)(root);
485
+ const normalizedRoot = (0, import_vite2.normalizePath)(root);
486
486
  const filter = buildFilter(include, exclude, extensions);
487
487
  return (id, ssr, timestamp = Date.now()) => {
488
488
  const { filename, rawQuery } = splitId(id);
@@ -493,7 +493,7 @@ function buildIdParser(options) {
493
493
  }
494
494
 
495
495
  // src/utils/options.ts
496
- var import_vite3 = require("vite");
496
+ var import_vite4 = require("vite");
497
497
 
498
498
  // src/utils/load-svelte-config.ts
499
499
  var import_module = require("module");
@@ -897,7 +897,7 @@ async function compileSvelte(options, { filename, code }) {
897
897
  }
898
898
 
899
899
  // src/utils/preprocess.ts
900
- var import_vite2 = require("vite");
900
+ var import_vite3 = require("vite");
901
901
  var import_magic_string2 = __toESM(require("magic-string"), 1);
902
902
  var import_compiler3 = require("svelte/compiler");
903
903
 
@@ -958,7 +958,7 @@ function createViteScriptPreprocessor() {
958
958
  const lang = attributes.lang;
959
959
  if (!supportedScriptLangs.includes(lang))
960
960
  return;
961
- const transformResult = await (0, import_vite2.transformWithEsbuild)(content, filename, {
961
+ const transformResult = await (0, import_vite3.transformWithEsbuild)(content, filename, {
962
962
  loader: lang,
963
963
  target: "esnext",
964
964
  tsconfigRaw: {
@@ -1162,6 +1162,7 @@ var allowedPluginOptions = /* @__PURE__ */ new Set([
1162
1162
  "hot",
1163
1163
  "ignorePluginPreprocessors",
1164
1164
  "disableDependencyReinclusion",
1165
+ "prebundleSvelteLibraries",
1165
1166
  "experimental"
1166
1167
  ]);
1167
1168
  var knownRootOptions = /* @__PURE__ */ new Set(["extensions", "compilerOptions", "preprocess", "onwarn"]);
@@ -1288,6 +1289,7 @@ function resolveOptions(preResolveOptions2, viteConfig) {
1288
1289
  };
1289
1290
  const merged = mergeConfigs(defaultOptions, preResolveOptions2, extraOptions);
1290
1291
  removeIgnoredOptions(merged);
1292
+ handleDeprecatedOptions(merged);
1291
1293
  addSvelteKitOptions(merged);
1292
1294
  addExtraPreprocessors(merged, viteConfig);
1293
1295
  enforceOptionsForHmr(merged);
@@ -1377,11 +1379,20 @@ function addSvelteKitOptions(options) {
1377
1379
  options.compilerOptions.hydratable = hydratable;
1378
1380
  }
1379
1381
  }
1382
+ function handleDeprecatedOptions(options) {
1383
+ var _a, _b;
1384
+ if ((_a = options.experimental) == null ? void 0 : _a.prebundleSvelteLibraries) {
1385
+ options.prebundleSvelteLibraries = (_b = options.experimental) == null ? void 0 : _b.prebundleSvelteLibraries;
1386
+ log.warn(
1387
+ "experimental.prebundleSvelteLibraries is no longer experimental and has moved to prebundleSvelteLibraries"
1388
+ );
1389
+ }
1390
+ }
1380
1391
  function resolveViteRoot(viteConfig) {
1381
- return (0, import_vite3.normalizePath)(viteConfig.root ? import_path4.default.resolve(viteConfig.root) : process.cwd());
1392
+ return (0, import_vite4.normalizePath)(viteConfig.root ? import_path4.default.resolve(viteConfig.root) : process.cwd());
1382
1393
  }
1383
1394
  function buildExtraViteConfig(options, config) {
1384
- var _a, _b;
1395
+ var _a;
1385
1396
  const svelteDeps = findRootSvelteDependencies(options.root);
1386
1397
  const extraViteConfig = {
1387
1398
  resolve: {
@@ -1394,7 +1405,7 @@ function buildExtraViteConfig(options, config) {
1394
1405
  options,
1395
1406
  config.optimizeDeps
1396
1407
  );
1397
- if ((_a = options.experimental) == null ? void 0 : _a.prebundleSvelteLibraries) {
1408
+ if (options.prebundleSvelteLibraries) {
1398
1409
  extraViteConfig.optimizeDeps = {
1399
1410
  ...extraViteConfig.optimizeDeps,
1400
1411
  extensions: options.extensions ?? [".svelte"],
@@ -1405,23 +1416,22 @@ function buildExtraViteConfig(options, config) {
1405
1416
  };
1406
1417
  }
1407
1418
  extraViteConfig.ssr = buildSSROptionsForSvelte(svelteDeps, options, config, extraViteConfig);
1408
- if ((options.hot == null || options.hot === true || options.hot && options.hot.partialAccept !== false) && ((_b = config.experimental) == null ? void 0 : _b.hmrPartialAccept) !== false) {
1419
+ if ((options.hot == null || options.hot === true || options.hot && options.hot.partialAccept !== false) && ((_a = config.experimental) == null ? void 0 : _a.hmrPartialAccept) !== false) {
1409
1420
  log.debug('enabling "experimental.hmrPartialAccept" in vite config');
1410
1421
  extraViteConfig.experimental = { hmrPartialAccept: true };
1411
1422
  }
1412
1423
  return extraViteConfig;
1413
1424
  }
1414
1425
  function buildOptimizeDepsForSvelte(svelteDeps, options, optimizeDeps) {
1415
- var _a;
1416
1426
  const include = [];
1417
1427
  const exclude = ["svelte-hmr"];
1418
1428
  const isIncluded = (dep) => {
1419
- var _a2;
1420
- return include.includes(dep) || ((_a2 = optimizeDeps == null ? void 0 : optimizeDeps.include) == null ? void 0 : _a2.includes(dep));
1429
+ var _a;
1430
+ return include.includes(dep) || ((_a = optimizeDeps == null ? void 0 : optimizeDeps.include) == null ? void 0 : _a.includes(dep));
1421
1431
  };
1422
1432
  const isExcluded = (dep) => {
1423
- var _a2;
1424
- return exclude.includes(dep) || ((_a2 = optimizeDeps == null ? void 0 : optimizeDeps.exclude) == null ? void 0 : _a2.some((id) => dep === id || id.startsWith(`${dep}/`)));
1433
+ var _a;
1434
+ return exclude.includes(dep) || ((_a = optimizeDeps == null ? void 0 : optimizeDeps.exclude) == null ? void 0 : _a.some((id) => dep === id || id.startsWith(`${dep}/`)));
1425
1435
  };
1426
1436
  if (!isExcluded("svelte")) {
1427
1437
  const svelteImportsToInclude = SVELTE_IMPORTS.filter((x) => x !== "svelte/ssr");
@@ -1432,7 +1442,7 @@ function buildOptimizeDepsForSvelte(svelteDeps, options, optimizeDeps) {
1432
1442
  } else {
1433
1443
  log.debug('"svelte" is excluded in optimizeDeps.exclude, skipped adding it to include.');
1434
1444
  }
1435
- if ((_a = options.experimental) == null ? void 0 : _a.prebundleSvelteLibraries) {
1445
+ if (options.prebundleSvelteLibraries) {
1436
1446
  return { include, exclude };
1437
1447
  }
1438
1448
  svelteDeps = svelteDeps.filter((dep) => dep.type === "component-library");
@@ -1756,7 +1766,7 @@ function generateSvelteMetadata(options) {
1756
1766
  }
1757
1767
 
1758
1768
  // src/ui/inspector/plugin.ts
1759
- var import_vite4 = require("vite");
1769
+ var import_vite5 = require("vite");
1760
1770
  var import_path8 = __toESM(require("path"), 1);
1761
1771
  var import_url2 = require("url");
1762
1772
  var import_fs6 = __toESM(require("fs"), 1);
@@ -1784,7 +1794,7 @@ var defaultInspectorOptions = {
1784
1794
  customStyles: true
1785
1795
  };
1786
1796
  function getInspectorPath() {
1787
- const pluginPath = (0, import_vite4.normalizePath)(import_path8.default.dirname((0, import_url2.fileURLToPath)(importMetaUrl)));
1797
+ const pluginPath = (0, import_vite5.normalizePath)(import_path8.default.dirname((0, import_url2.fileURLToPath)(importMetaUrl)));
1788
1798
  return pluginPath.replace(/\/vite-plugin-svelte\/dist$/, "/vite-plugin-svelte/src/ui/inspector/");
1789
1799
  }
1790
1800
  function svelteInspector() {
@@ -1913,8 +1923,7 @@ function svelte(inlineOptions) {
1913
1923
  log.debug("resolved options", options);
1914
1924
  },
1915
1925
  async buildStart() {
1916
- var _a;
1917
- if (!((_a = options.experimental) == null ? void 0 : _a.prebundleSvelteLibraries))
1926
+ if (!options.prebundleSvelteLibraries)
1918
1927
  return;
1919
1928
  const isSvelteMetadataChanged = await saveSvelteMetadata(viteConfig.cacheDir, options);
1920
1929
  if (isSvelteMetadataChanged) {