@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.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { Plugin } from 'vite';
1
+ import { UserConfig, Plugin } from 'vite';
2
2
  import { CompileOptions, Warning } from 'svelte/types/compiler/interfaces';
3
3
  export { CompileOptions, Warning } from 'svelte/types/compiler/interfaces';
4
4
  import { PreprocessorGroup } from 'svelte/types/compiler/preprocess';
5
5
  export { MarkupPreprocessor, Preprocessor, PreprocessorGroup, Processed } from 'svelte/types/compiler/preprocess';
6
+ import { KitConfig } from '@sveltejs/kit';
6
7
 
7
8
  interface Options {
8
9
  /**
@@ -101,6 +102,10 @@ interface Options {
101
102
  * These options are considered experimental and breaking changes to them can occur in any release
102
103
  */
103
104
  experimental?: ExperimentalOptions;
105
+ /**
106
+ * Options for SvelteKit
107
+ */
108
+ kit?: KitConfig;
104
109
  }
105
110
  /**
106
111
  * These options are considered experimental and breaking changes to them can occur in any release
@@ -200,6 +205,8 @@ declare type ModuleFormat = NonNullable<CompileOptions['format']>;
200
205
  declare type CssHashGetter = NonNullable<CompileOptions['cssHash']>;
201
206
  declare type Arrayable<T> = T | T[];
202
207
 
208
+ declare function loadSvelteConfig(viteConfig?: UserConfig, inlineOptions?: Partial<Options>): Promise<Partial<Options> | undefined>;
209
+
203
210
  declare function svelte(inlineOptions?: Partial<Options>): Plugin[];
204
211
 
205
- export { Arrayable, CssHashGetter, ModuleFormat, Options, svelte };
212
+ export { Arrayable, CssHashGetter, ModuleFormat, Options, loadSvelteConfig, svelte };
package/dist/index.js CHANGED
@@ -457,9 +457,9 @@ var knownSvelteConfigNames = [
457
457
  "svelte.config.cjs",
458
458
  "svelte.config.mjs"
459
459
  ];
460
- var dynamicImportDefault = new Function("path", 'return import(path + "?t=" + Date.now()).then(m => m.default)');
460
+ var dynamicImportDefault = new Function("path", "timestamp", 'return import(path + "?t=" + timestamp).then(m => m.default)');
461
461
  async function loadSvelteConfig(viteConfig, inlineOptions) {
462
- if (inlineOptions.configFile === false) {
462
+ if ((inlineOptions == null ? void 0 : inlineOptions.configFile) === false) {
463
463
  return;
464
464
  }
465
465
  const configFile = findConfigToLoad(viteConfig, inlineOptions);
@@ -467,7 +467,7 @@ async function loadSvelteConfig(viteConfig, inlineOptions) {
467
467
  let err;
468
468
  if (configFile.endsWith(".js") || configFile.endsWith(".mjs")) {
469
469
  try {
470
- const result = await dynamicImportDefault(pathToFileURL(configFile).href);
470
+ const result = await dynamicImportDefault(pathToFileURL(configFile).href, fs2.statSync(configFile).mtimeMs);
471
471
  if (result != null) {
472
472
  return __spreadProps(__spreadValues({}, result), {
473
473
  configFile
@@ -503,8 +503,8 @@ async function loadSvelteConfig(viteConfig, inlineOptions) {
503
503
  }
504
504
  }
505
505
  function findConfigToLoad(viteConfig, inlineOptions) {
506
- const root = viteConfig.root || process.cwd();
507
- if (inlineOptions.configFile) {
506
+ const root = (viteConfig == null ? void 0 : viteConfig.root) || process.cwd();
507
+ if (inlineOptions == null ? void 0 : inlineOptions.configFile) {
508
508
  const abolutePath = path.isAbsolute(inlineOptions.configFile) ? inlineOptions.configFile : path.resolve(root, inlineOptions.configFile);
509
509
  if (!fs2.existsSync(abolutePath)) {
510
510
  throw new Error(`failed to find svelte config file ${abolutePath}.`);
@@ -649,6 +649,7 @@ function isSvelteLib(pkg) {
649
649
  }
650
650
  var COMMON_DEPENDENCIES_WITHOUT_SVELTE_FIELD = [
651
651
  "@lukeed/uuid",
652
+ "@playwright/test",
652
653
  "@sveltejs/vite-plugin-svelte",
653
654
  "@sveltejs/kit",
654
655
  "autoprefixer",
@@ -658,6 +659,7 @@ var COMMON_DEPENDENCIES_WITHOUT_SVELTE_FIELD = [
658
659
  "eslint",
659
660
  "jest",
660
661
  "mdsvex",
662
+ "playwright",
661
663
  "postcss",
662
664
  "prettier",
663
665
  "svelte",
@@ -666,7 +668,9 @@ var COMMON_DEPENDENCIES_WITHOUT_SVELTE_FIELD = [
666
668
  "svelte-preprocess",
667
669
  "tslib",
668
670
  "typescript",
669
- "vite"
671
+ "vite",
672
+ "vitest",
673
+ "__vite-browser-external"
670
674
  ];
671
675
  var COMMON_PREFIXES_WITHOUT_SVELTE_FIELD = [
672
676
  "@fontsource/",
@@ -1122,6 +1126,7 @@ function resolveOptions(preResolveOptions2, viteConfig) {
1122
1126
  };
1123
1127
  const merged = mergeConfigs(defaultOptions, preResolveOptions2, extraOptions);
1124
1128
  removeIgnoredOptions(merged);
1129
+ addSvelteKitOptions(merged);
1125
1130
  addExtraPreprocessors(merged, viteConfig);
1126
1131
  enforceOptionsForHmr(merged);
1127
1132
  enforceOptionsForProduction(merged);
@@ -1184,6 +1189,17 @@ function removeIgnoredOptions(options) {
1184
1189
  });
1185
1190
  }
1186
1191
  }
1192
+ function addSvelteKitOptions(options) {
1193
+ var _a, _b;
1194
+ if ((options == null ? void 0 : options.kit) != null) {
1195
+ const hydratable = ((_a = options.kit.browser) == null ? void 0 : _a.hydrate) !== false;
1196
+ if (options.compilerOptions.hydratable != null && options.compilerOptions.hydratable !== hydratable) {
1197
+ 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".`);
1198
+ }
1199
+ log.debug(`Setting compilerOptions.hydratable: ${hydratable} for SvelteKit`);
1200
+ options.compilerOptions.hydratable = hydratable;
1201
+ }
1202
+ }
1187
1203
  function resolveViteRoot(viteConfig) {
1188
1204
  return normalizePath2(viteConfig.root ? path4.resolve(viteConfig.root) : process.cwd());
1189
1205
  }
@@ -1759,6 +1775,7 @@ function svelte(inlineOptions) {
1759
1775
  return plugins.filter(Boolean);
1760
1776
  }
1761
1777
  export {
1778
+ loadSvelteConfig,
1762
1779
  svelte
1763
1780
  };
1764
1781
  //# sourceMappingURL=index.js.map