@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/dist/index.js
CHANGED
|
@@ -890,7 +890,8 @@ function mergeOptions(defaultOptions, svelteConfig, inlineOptions, viteConfig, v
|
|
|
890
890
|
root: viteConfig.root,
|
|
891
891
|
isProduction: viteEnv.mode === "production",
|
|
892
892
|
isBuild: viteEnv.command === "build",
|
|
893
|
-
isServe: viteEnv.command === "serve"
|
|
893
|
+
isServe: viteEnv.command === "serve",
|
|
894
|
+
isSvelteKit: !!(svelteConfig == null ? void 0 : svelteConfig.kit)
|
|
894
895
|
});
|
|
895
896
|
if (svelteConfig == null ? void 0 : svelteConfig.configFile) {
|
|
896
897
|
merged.configFile = svelteConfig.configFile;
|
|
@@ -1072,7 +1073,7 @@ function setupWatchers(options, cache, requestParser) {
|
|
|
1072
1073
|
return;
|
|
1073
1074
|
}
|
|
1074
1075
|
const { watcher, ws } = server;
|
|
1075
|
-
const {
|
|
1076
|
+
const { root, server: serverConfig } = server.config;
|
|
1076
1077
|
const emitChangeEventOnDependants = (filename) => {
|
|
1077
1078
|
const dependants = cache.getDependants(filename);
|
|
1078
1079
|
dependants.forEach((dependant) => {
|
|
@@ -1092,16 +1093,17 @@ function setupWatchers(options, cache, requestParser) {
|
|
|
1092
1093
|
}
|
|
1093
1094
|
};
|
|
1094
1095
|
const triggerViteRestart = (filename) => {
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
watcher.emit("change", viteConfigFile);
|
|
1098
|
-
} else {
|
|
1096
|
+
var _a;
|
|
1097
|
+
if (serverConfig.middlewareMode || options.isSvelteKit) {
|
|
1099
1098
|
const message = "Svelte config change detected, restart your dev process to apply the changes.";
|
|
1100
1099
|
log.info(message, filename);
|
|
1101
1100
|
ws.send({
|
|
1102
1101
|
type: "error",
|
|
1103
1102
|
err: { message, stack: "", plugin: "vite-plugin-svelte", id: filename }
|
|
1104
1103
|
});
|
|
1104
|
+
} else {
|
|
1105
|
+
log.info(`svelte config changed: restarting vite server. - file: ${filename}`);
|
|
1106
|
+
server.restart(!!((_a = options.experimental) == null ? void 0 : _a.prebundleSvelteLibraries));
|
|
1105
1107
|
}
|
|
1106
1108
|
};
|
|
1107
1109
|
const possibleSvelteConfigs = knownSvelteConfigNames.map((cfg) => path4.join(root, cfg));
|
|
@@ -1152,7 +1154,7 @@ function resolveViaPackageJsonSvelte(importee, importer) {
|
|
|
1152
1154
|
}
|
|
1153
1155
|
}
|
|
1154
1156
|
function isBareImport(importee) {
|
|
1155
|
-
if (!importee || importee[0] === "." || importee[0] === "\0" || path5.isAbsolute(importee)) {
|
|
1157
|
+
if (!importee || importee[0] === "." || importee[0] === "\0" || importee.includes(":") || path5.isAbsolute(importee)) {
|
|
1156
1158
|
return false;
|
|
1157
1159
|
}
|
|
1158
1160
|
const parts = importee.split("/");
|
|
@@ -1451,9 +1453,9 @@ function svelte(inlineOptions) {
|
|
|
1451
1453
|
}
|
|
1452
1454
|
}
|
|
1453
1455
|
},
|
|
1454
|
-
async resolveId(importee, importer, opts
|
|
1455
|
-
const ssr =
|
|
1456
|
-
const svelteRequest = requestParser(importee,
|
|
1456
|
+
async resolveId(importee, importer, opts) {
|
|
1457
|
+
const ssr = !!(opts == null ? void 0 : opts.ssr);
|
|
1458
|
+
const svelteRequest = requestParser(importee, ssr);
|
|
1457
1459
|
if (svelteRequest == null ? void 0 : svelteRequest.query.svelte) {
|
|
1458
1460
|
if (svelteRequest.query.type === "style") {
|
|
1459
1461
|
log.debug(`resolveId resolved virtual css module ${svelteRequest.cssId}`);
|
|
@@ -1494,8 +1496,8 @@ function svelte(inlineOptions) {
|
|
|
1494
1496
|
},
|
|
1495
1497
|
async transform(code, id, opts) {
|
|
1496
1498
|
var _a;
|
|
1497
|
-
const ssr =
|
|
1498
|
-
const svelteRequest = requestParser(id,
|
|
1499
|
+
const ssr = !!(opts == null ? void 0 : opts.ssr);
|
|
1500
|
+
const svelteRequest = requestParser(id, ssr);
|
|
1499
1501
|
if (!svelteRequest) {
|
|
1500
1502
|
return;
|
|
1501
1503
|
}
|