@sveltejs/vite-plugin-svelte 1.0.0-next.47 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/vite-plugin-svelte",
3
- "version": "1.0.0-next.47",
3
+ "version": "1.0.0-next.48",
4
4
  "license": "MIT",
5
5
  "author": "dominikg",
6
6
  "files": [
@@ -59,14 +59,15 @@
59
59
  }
60
60
  },
61
61
  "devDependencies": {
62
+ "@sveltejs/kit": "^1.0.0-next.350",
62
63
  "@types/debug": "^4.1.7",
63
64
  "@types/diff-match-patch": "^1.0.32",
64
65
  "diff-match-patch": "^1.0.5",
65
66
  "esbuild": "^0.14.42",
66
- "rollup": "^2.75.4",
67
+ "rollup": "^2.75.5",
67
68
  "svelte": "^3.48.0",
68
- "tsup": "^6.0.1",
69
- "vite": "^2.9.9"
69
+ "tsup": "^6.1.0",
70
+ "vite": "^2.9.10"
70
71
  },
71
72
  "scripts": {
72
73
  "dev": "pnpm build:ci --sourcemap --watch src",
@@ -127,6 +127,7 @@ function isSvelteLib(pkg: Pkg) {
127
127
 
128
128
  const COMMON_DEPENDENCIES_WITHOUT_SVELTE_FIELD = [
129
129
  '@lukeed/uuid',
130
+ '@playwright/test',
130
131
  '@sveltejs/vite-plugin-svelte',
131
132
  '@sveltejs/kit',
132
133
  'autoprefixer',
@@ -136,6 +137,7 @@ const COMMON_DEPENDENCIES_WITHOUT_SVELTE_FIELD = [
136
137
  'eslint',
137
138
  'jest',
138
139
  'mdsvex',
140
+ 'playwright',
139
141
  'postcss',
140
142
  'prettier',
141
143
  'svelte',
@@ -144,7 +146,9 @@ const COMMON_DEPENDENCIES_WITHOUT_SVELTE_FIELD = [
144
146
  'svelte-preprocess',
145
147
  'tslib',
146
148
  'typescript',
147
- 'vite'
149
+ 'vite',
150
+ 'vitest',
151
+ '__vite-browser-external' // see https://github.com/sveltejs/vite-plugin-svelte/issues/362
148
152
  ];
149
153
  const COMMON_PREFIXES_WITHOUT_SVELTE_FIELD = [
150
154
  '@fontsource/',
@@ -11,14 +11,16 @@ import { log } from './log';
11
11
  import { loadSvelteConfig } from './load-svelte-config';
12
12
  import { SVELTE_HMR_IMPORTS, SVELTE_IMPORTS, SVELTE_RESOLVE_MAIN_FIELDS } from './constants';
13
13
  // eslint-disable-next-line node/no-missing-import
14
- import { CompileOptions, Warning } from 'svelte/types/compiler/interfaces';
15
- import {
14
+ import type { CompileOptions, Warning } from 'svelte/types/compiler/interfaces';
15
+ import type {
16
16
  MarkupPreprocessor,
17
17
  Preprocessor,
18
18
  PreprocessorGroup,
19
19
  Processed
20
20
  // eslint-disable-next-line node/no-missing-import
21
21
  } from 'svelte/types/compiler/preprocess';
22
+ // eslint-disable-next-line node/no-missing-import
23
+ import type { KitConfig } from '@sveltejs/kit';
22
24
  import path from 'path';
23
25
  import { findRootSvelteDependencies, needsOptimization, SvelteDependency } from './dependencies';
24
26
  import { createRequire } from 'module';
@@ -76,7 +78,6 @@ export async function preResolveOptions(
76
78
  inlineOptions,
77
79
  extraOptions
78
80
  );
79
-
80
81
  // configFile of svelteConfig contains the absolute path it was loaded from,
81
82
  // prefer it over the possibly relative inline path
82
83
  if (svelteConfig?.configFile) {
@@ -116,6 +117,7 @@ export function resolveOptions(
116
117
  const merged: ResolvedOptions = mergeConfigs(defaultOptions, preResolveOptions, extraOptions);
117
118
 
118
119
  removeIgnoredOptions(merged);
120
+ addSvelteKitOptions(merged);
119
121
  addExtraPreprocessors(merged, viteConfig);
120
122
  enforceOptionsForHmr(merged);
121
123
  enforceOptionsForProduction(merged);
@@ -195,6 +197,23 @@ function removeIgnoredOptions(options: ResolvedOptions) {
195
197
  }
196
198
  }
197
199
 
200
+ // some SvelteKit options need compilerOptions to work, so set them here.
201
+ function addSvelteKitOptions(options: ResolvedOptions) {
202
+ if (options?.kit != null) {
203
+ const hydratable = options.kit.browser?.hydrate !== false;
204
+ if (
205
+ options.compilerOptions.hydratable != null &&
206
+ options.compilerOptions.hydratable !== hydratable
207
+ ) {
208
+ log.warn(
209
+ `Conflicting values "compilerOptions.hydratable: ${options.compilerOptions.hydratable}" and "kit.browser.hydrate: ${options.kit.browser?.hydrate}" in your svelte config. You should remove "compilerOptions.hydratable".`
210
+ );
211
+ }
212
+ log.debug(`Setting compilerOptions.hydratable: ${hydratable} for SvelteKit`);
213
+ options.compilerOptions.hydratable = hydratable;
214
+ }
215
+ }
216
+
198
217
  // vite passes unresolved `root`option to config hook but we need the resolved value, so do it here
199
218
  // https://github.com/sveltejs/vite-plugin-svelte/issues/113
200
219
  // https://github.com/vitejs/vite/blob/43c957de8a99bb326afd732c962f42127b0a4d1e/packages/vite/src/node/config.ts#L293
@@ -476,6 +495,11 @@ export interface Options {
476
495
  * These options are considered experimental and breaking changes to them can occur in any release
477
496
  */
478
497
  experimental?: ExperimentalOptions;
498
+
499
+ /**
500
+ * Options for SvelteKit
501
+ */
502
+ kit?: KitConfig;
479
503
  }
480
504
 
481
505
  /**