@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/vite-plugin-svelte",
3
- "version": "1.0.9",
3
+ "version": "1.1.0",
4
4
  "license": "MIT",
5
5
  "author": "dominikg",
6
6
  "files": [
@@ -41,11 +41,10 @@
41
41
  },
42
42
  "homepage": "https://github.com/sveltejs/vite-plugin-svelte#readme",
43
43
  "dependencies": {
44
- "@rollup/pluginutils": "^4.2.1",
45
44
  "debug": "^4.3.4",
46
45
  "deepmerge": "^4.2.2",
47
46
  "kleur": "^4.1.5",
48
- "magic-string": "^0.26.5",
47
+ "magic-string": "^0.26.7",
49
48
  "svelte-hmr": "^0.15.0"
50
49
  },
51
50
  "peerDependencies": {
@@ -62,11 +61,11 @@
62
61
  "@types/debug": "^4.1.7",
63
62
  "@types/diff-match-patch": "^1.0.32",
64
63
  "diff-match-patch": "^1.0.5",
65
- "esbuild": "^0.15.10",
64
+ "esbuild": "^0.15.12",
66
65
  "rollup": "^2.79.1",
67
- "svelte": "^3.50.1",
68
- "tsup": "^6.2.3",
69
- "vite": "^3.1.4"
66
+ "svelte": "^3.52.0",
67
+ "tsup": "^6.3.0",
68
+ "vite": "^3.1.8"
70
69
  },
71
70
  "scripts": {
72
71
  "dev": "pnpm build:ci --sourcemap --watch src",
package/src/index.ts CHANGED
@@ -85,7 +85,7 @@ export function svelte(inlineOptions?: Partial<Options>): Plugin[] {
85
85
  },
86
86
 
87
87
  async buildStart() {
88
- if (!options.experimental?.prebundleSvelteLibraries) return;
88
+ if (!options.prebundleSvelteLibraries) return;
89
89
  const isSvelteMetadataChanged = await saveSvelteMetadata(viteConfig.cacheDir, options);
90
90
  if (isSvelteMetadataChanged) {
91
91
  // Force Vite to optimize again. Although we mutate the config here, it works because
package/src/utils/id.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-unused-vars */
2
- import { createFilter } from '@rollup/pluginutils';
2
+ import { createFilter } from 'vite';
3
3
  import { Arrayable, ResolvedOptions } from './options';
4
4
  import { normalizePath } from 'vite';
5
5
  import * as fs from 'fs';
@@ -34,6 +34,7 @@ const allowedPluginOptions = new Set([
34
34
  'hot',
35
35
  'ignorePluginPreprocessors',
36
36
  'disableDependencyReinclusion',
37
+ 'prebundleSvelteLibraries',
37
38
  'experimental'
38
39
  ]);
39
40
 
@@ -188,6 +189,7 @@ export function resolveOptions(
188
189
  const merged = mergeConfigs<ResolvedOptions>(defaultOptions, preResolveOptions, extraOptions);
189
190
 
190
191
  removeIgnoredOptions(merged);
192
+ handleDeprecatedOptions(merged);
191
193
  addSvelteKitOptions(merged);
192
194
  addExtraPreprocessors(merged, viteConfig);
193
195
  enforceOptionsForHmr(merged);
@@ -288,6 +290,15 @@ function addSvelteKitOptions(options: ResolvedOptions) {
288
290
  }
289
291
  }
290
292
 
293
+ function handleDeprecatedOptions(options: ResolvedOptions) {
294
+ if ((options.experimental as any)?.prebundleSvelteLibraries) {
295
+ options.prebundleSvelteLibraries = (options.experimental as any)?.prebundleSvelteLibraries;
296
+ log.warn(
297
+ 'experimental.prebundleSvelteLibraries is no longer experimental and has moved to prebundleSvelteLibraries'
298
+ );
299
+ }
300
+ }
301
+
291
302
  // vite passes unresolved `root`option to config hook but we need the resolved value, so do it here
292
303
  // https://github.com/sveltejs/vite-plugin-svelte/issues/113
293
304
  // https://github.com/vitejs/vite/blob/43c957de8a99bb326afd732c962f42127b0a4d1e/packages/vite/src/node/config.ts#L293
@@ -318,7 +329,7 @@ export function buildExtraViteConfig(
318
329
  config.optimizeDeps
319
330
  );
320
331
 
321
- if (options.experimental?.prebundleSvelteLibraries) {
332
+ if (options.prebundleSvelteLibraries) {
322
333
  extraViteConfig.optimizeDeps = {
323
334
  ...extraViteConfig.optimizeDeps,
324
335
  // Experimental Vite API to allow these extensions to be scanned and prebundled
@@ -378,7 +389,7 @@ function buildOptimizeDepsForSvelte(
378
389
  }
379
390
 
380
391
  // If we prebundle svelte libraries, we can skip the whole prebundling dance below
381
- if (options.experimental?.prebundleSvelteLibraries) {
392
+ if (options.prebundleSvelteLibraries) {
382
393
  return { include, exclude };
383
394
  }
384
395
 
@@ -540,6 +551,13 @@ export interface PluginOptions {
540
551
  */
541
552
  disableDependencyReinclusion?: boolean | string[];
542
553
 
554
+ /**
555
+ * Force Vite to pre-bundle Svelte libraries
556
+ *
557
+ * @default false
558
+ */
559
+ prebundleSvelteLibraries?: boolean;
560
+
543
561
  /**
544
562
  * These options are considered experimental and breaking changes to them can occur in any release
545
563
  */
@@ -594,13 +612,6 @@ export interface ExperimentalOptions {
594
612
  */
595
613
  useVitePreprocess?: boolean;
596
614
 
597
- /**
598
- * Force Vite to pre-bundle Svelte libraries
599
- *
600
- * @default false
601
- */
602
- prebundleSvelteLibraries?: boolean;
603
-
604
615
  /**
605
616
  * If a preprocessor does not provide a sourcemap, a best-effort fallback sourcemap will be provided.
606
617
  * This option requires `diff-match-patch` to be installed as a peer dependency.