@sveltejs/vite-plugin-svelte 1.0.0-next.31 → 1.0.0-next.32
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 +14 -12
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +14 -12
- package/dist/index.js.map +2 -2
- package/package.json +3 -3
- package/src/index.ts +5 -9
- package/src/utils/options.ts +5 -1
- package/src/utils/resolve.ts +7 -1
- package/src/utils/watch.ts +7 -7
package/src/utils/options.ts
CHANGED
|
@@ -121,6 +121,7 @@ function mergeOptions(
|
|
|
121
121
|
viteConfig: UserConfig,
|
|
122
122
|
viteEnv: ConfigEnv
|
|
123
123
|
): ResolvedOptions {
|
|
124
|
+
// @ts-ignore
|
|
124
125
|
const merged = {
|
|
125
126
|
...defaultOptions,
|
|
126
127
|
...svelteConfig,
|
|
@@ -137,7 +138,9 @@ function mergeOptions(
|
|
|
137
138
|
root: viteConfig.root!,
|
|
138
139
|
isProduction: viteEnv.mode === 'production',
|
|
139
140
|
isBuild: viteEnv.command === 'build',
|
|
140
|
-
isServe: viteEnv.command === 'serve'
|
|
141
|
+
isServe: viteEnv.command === 'serve',
|
|
142
|
+
// @ts-expect-error we don't declare kit property of svelte config but read it once here to identify kit projects
|
|
143
|
+
isSvelteKit: !!svelteConfig?.kit
|
|
141
144
|
};
|
|
142
145
|
// configFile of svelteConfig contains the absolute path it was loaded from,
|
|
143
146
|
// prefer it over the possibly relative inline path
|
|
@@ -485,6 +488,7 @@ export interface ResolvedOptions extends Options {
|
|
|
485
488
|
isBuild: boolean;
|
|
486
489
|
isServe: boolean;
|
|
487
490
|
server?: ViteDevServer;
|
|
491
|
+
isSvelteKit?: boolean;
|
|
488
492
|
}
|
|
489
493
|
|
|
490
494
|
export type {
|
package/src/utils/resolve.ts
CHANGED
|
@@ -14,7 +14,13 @@ export function resolveViaPackageJsonSvelte(importee: string, importer?: string)
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function isBareImport(importee: string): boolean {
|
|
17
|
-
if (
|
|
17
|
+
if (
|
|
18
|
+
!importee ||
|
|
19
|
+
importee[0] === '.' ||
|
|
20
|
+
importee[0] === '\0' ||
|
|
21
|
+
importee.includes(':') ||
|
|
22
|
+
path.isAbsolute(importee)
|
|
23
|
+
) {
|
|
18
24
|
return false;
|
|
19
25
|
}
|
|
20
26
|
const parts = importee.split('/');
|
package/src/utils/watch.ts
CHANGED
|
@@ -17,7 +17,7 @@ export function setupWatchers(
|
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
19
|
const { watcher, ws } = server;
|
|
20
|
-
const {
|
|
20
|
+
const { root, server: serverConfig } = server.config;
|
|
21
21
|
|
|
22
22
|
const emitChangeEventOnDependants = (filename: string) => {
|
|
23
23
|
const dependants = cache.getDependants(filename);
|
|
@@ -42,12 +42,9 @@ export function setupWatchers(
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
const triggerViteRestart = (filename: string) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
log.info(`svelte config changed: restarting vite server. - file: ${filename}`);
|
|
49
|
-
watcher.emit('change', viteConfigFile);
|
|
50
|
-
} else {
|
|
45
|
+
if (serverConfig.middlewareMode || options.isSvelteKit) {
|
|
46
|
+
// in middlewareMode or for sveltekit we can't restart the server automatically
|
|
47
|
+
// show the user an overlay instead
|
|
51
48
|
const message =
|
|
52
49
|
'Svelte config change detected, restart your dev process to apply the changes.';
|
|
53
50
|
log.info(message, filename);
|
|
@@ -55,6 +52,9 @@ export function setupWatchers(
|
|
|
55
52
|
type: 'error',
|
|
56
53
|
err: { message, stack: '', plugin: 'vite-plugin-svelte', id: filename }
|
|
57
54
|
});
|
|
55
|
+
} else {
|
|
56
|
+
log.info(`svelte config changed: restarting vite server. - file: ${filename}`);
|
|
57
|
+
server.restart(!!options.experimental?.prebundleSvelteLibraries);
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
|