@sveltejs/vite-plugin-svelte 1.0.0-next.45 → 1.0.0-next.48

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
@@ -39,11 +39,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
39
39
  // src/index.ts
40
40
  var src_exports = {};
41
41
  __export(src_exports, {
42
+ loadSvelteConfig: () => loadSvelteConfig,
42
43
  svelte: () => svelte
43
44
  });
44
45
  module.exports = __toCommonJS(src_exports);
45
46
 
46
- // ../../node_modules/.pnpm/tsup@5.12.8/node_modules/tsup/assets/cjs_shims.js
47
+ // ../../node_modules/.pnpm/tsup@6.1.0/node_modules/tsup/assets/cjs_shims.js
47
48
  var getImportMetaUrl = () => typeof document === "undefined" ? new URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
48
49
  var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
49
50
 
@@ -477,9 +478,9 @@ var knownSvelteConfigNames = [
477
478
  "svelte.config.cjs",
478
479
  "svelte.config.mjs"
479
480
  ];
480
- var dynamicImportDefault = new Function("path", 'return import(path + "?t=" + Date.now()).then(m => m.default)');
481
+ var dynamicImportDefault = new Function("path", "timestamp", 'return import(path + "?t=" + timestamp).then(m => m.default)');
481
482
  async function loadSvelteConfig(viteConfig, inlineOptions) {
482
- if (inlineOptions.configFile === false) {
483
+ if ((inlineOptions == null ? void 0 : inlineOptions.configFile) === false) {
483
484
  return;
484
485
  }
485
486
  const configFile = findConfigToLoad(viteConfig, inlineOptions);
@@ -487,7 +488,7 @@ async function loadSvelteConfig(viteConfig, inlineOptions) {
487
488
  let err;
488
489
  if (configFile.endsWith(".js") || configFile.endsWith(".mjs")) {
489
490
  try {
490
- const result = await dynamicImportDefault((0, import_url.pathToFileURL)(configFile).href);
491
+ const result = await dynamicImportDefault((0, import_url.pathToFileURL)(configFile).href, import_fs.default.statSync(configFile).mtimeMs);
491
492
  if (result != null) {
492
493
  return __spreadProps(__spreadValues({}, result), {
493
494
  configFile
@@ -523,8 +524,8 @@ async function loadSvelteConfig(viteConfig, inlineOptions) {
523
524
  }
524
525
  }
525
526
  function findConfigToLoad(viteConfig, inlineOptions) {
526
- const root = viteConfig.root || process.cwd();
527
- if (inlineOptions.configFile) {
527
+ const root = (viteConfig == null ? void 0 : viteConfig.root) || process.cwd();
528
+ if (inlineOptions == null ? void 0 : inlineOptions.configFile) {
528
529
  const abolutePath = import_path.default.isAbsolute(inlineOptions.configFile) ? inlineOptions.configFile : import_path.default.resolve(root, inlineOptions.configFile);
529
530
  if (!import_fs.default.existsSync(abolutePath)) {
530
531
  throw new Error(`failed to find svelte config file ${abolutePath}.`);
@@ -669,6 +670,7 @@ function isSvelteLib(pkg) {
669
670
  }
670
671
  var COMMON_DEPENDENCIES_WITHOUT_SVELTE_FIELD = [
671
672
  "@lukeed/uuid",
673
+ "@playwright/test",
672
674
  "@sveltejs/vite-plugin-svelte",
673
675
  "@sveltejs/kit",
674
676
  "autoprefixer",
@@ -678,6 +680,7 @@ var COMMON_DEPENDENCIES_WITHOUT_SVELTE_FIELD = [
678
680
  "eslint",
679
681
  "jest",
680
682
  "mdsvex",
683
+ "playwright",
681
684
  "postcss",
682
685
  "prettier",
683
686
  "svelte",
@@ -686,7 +689,9 @@ var COMMON_DEPENDENCIES_WITHOUT_SVELTE_FIELD = [
686
689
  "svelte-preprocess",
687
690
  "tslib",
688
691
  "typescript",
689
- "vite"
692
+ "vite",
693
+ "vitest",
694
+ "__vite-browser-external"
690
695
  ];
691
696
  var COMMON_PREFIXES_WITHOUT_SVELTE_FIELD = [
692
697
  "@fontsource/",
@@ -1140,6 +1145,7 @@ function resolveOptions(preResolveOptions2, viteConfig) {
1140
1145
  };
1141
1146
  const merged = mergeConfigs(defaultOptions, preResolveOptions2, extraOptions);
1142
1147
  removeIgnoredOptions(merged);
1148
+ addSvelteKitOptions(merged);
1143
1149
  addExtraPreprocessors(merged, viteConfig);
1144
1150
  enforceOptionsForHmr(merged);
1145
1151
  enforceOptionsForProduction(merged);
@@ -1202,6 +1208,17 @@ function removeIgnoredOptions(options) {
1202
1208
  });
1203
1209
  }
1204
1210
  }
1211
+ function addSvelteKitOptions(options) {
1212
+ var _a, _b;
1213
+ if ((options == null ? void 0 : options.kit) != null) {
1214
+ const hydratable = ((_a = options.kit.browser) == null ? void 0 : _a.hydrate) !== false;
1215
+ if (options.compilerOptions.hydratable != null && options.compilerOptions.hydratable !== hydratable) {
1216
+ log.warn(`Conflicting values "compilerOptions.hydratable: ${options.compilerOptions.hydratable}" and "kit.browser.hydrate: ${(_b = options.kit.browser) == null ? void 0 : _b.hydrate}" in your svelte config. You should remove "compilerOptions.hydratable".`);
1217
+ }
1218
+ log.debug(`Setting compilerOptions.hydratable: ${hydratable} for SvelteKit`);
1219
+ options.compilerOptions.hydratable = hydratable;
1220
+ }
1221
+ }
1205
1222
  function resolveViteRoot(viteConfig) {
1206
1223
  return (0, import_vite3.normalizePath)(viteConfig.root ? import_path4.default.resolve(viteConfig.root) : process.cwd());
1207
1224
  }
@@ -1778,6 +1795,7 @@ function svelte(inlineOptions) {
1778
1795
  }
1779
1796
  // Annotate the CommonJS export names for ESM import in node:
1780
1797
  0 && (module.exports = {
1798
+ loadSvelteConfig,
1781
1799
  svelte
1782
1800
  });
1783
1801
  //# sourceMappingURL=index.cjs.map