@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.cjs
CHANGED
|
@@ -908,7 +908,8 @@ function mergeOptions(defaultOptions, svelteConfig, inlineOptions, viteConfig, v
|
|
|
908
908
|
root: viteConfig.root,
|
|
909
909
|
isProduction: viteEnv.mode === "production",
|
|
910
910
|
isBuild: viteEnv.command === "build",
|
|
911
|
-
isServe: viteEnv.command === "serve"
|
|
911
|
+
isServe: viteEnv.command === "serve",
|
|
912
|
+
isSvelteKit: !!(svelteConfig == null ? void 0 : svelteConfig.kit)
|
|
912
913
|
});
|
|
913
914
|
if (svelteConfig == null ? void 0 : svelteConfig.configFile) {
|
|
914
915
|
merged.configFile = svelteConfig.configFile;
|
|
@@ -1090,7 +1091,7 @@ function setupWatchers(options, cache, requestParser) {
|
|
|
1090
1091
|
return;
|
|
1091
1092
|
}
|
|
1092
1093
|
const { watcher, ws } = server;
|
|
1093
|
-
const {
|
|
1094
|
+
const { root, server: serverConfig } = server.config;
|
|
1094
1095
|
const emitChangeEventOnDependants = (filename) => {
|
|
1095
1096
|
const dependants = cache.getDependants(filename);
|
|
1096
1097
|
dependants.forEach((dependant) => {
|
|
@@ -1110,16 +1111,17 @@ function setupWatchers(options, cache, requestParser) {
|
|
|
1110
1111
|
}
|
|
1111
1112
|
};
|
|
1112
1113
|
const triggerViteRestart = (filename) => {
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
watcher.emit("change", viteConfigFile);
|
|
1116
|
-
} else {
|
|
1114
|
+
var _a;
|
|
1115
|
+
if (serverConfig.middlewareMode || options.isSvelteKit) {
|
|
1117
1116
|
const message = "Svelte config change detected, restart your dev process to apply the changes.";
|
|
1118
1117
|
log.info(message, filename);
|
|
1119
1118
|
ws.send({
|
|
1120
1119
|
type: "error",
|
|
1121
1120
|
err: { message, stack: "", plugin: "vite-plugin-svelte", id: filename }
|
|
1122
1121
|
});
|
|
1122
|
+
} else {
|
|
1123
|
+
log.info(`svelte config changed: restarting vite server. - file: ${filename}`);
|
|
1124
|
+
server.restart(!!((_a = options.experimental) == null ? void 0 : _a.prebundleSvelteLibraries));
|
|
1123
1125
|
}
|
|
1124
1126
|
};
|
|
1125
1127
|
const possibleSvelteConfigs = knownSvelteConfigNames.map((cfg) => import_path4.default.join(root, cfg));
|
|
@@ -1170,7 +1172,7 @@ function resolveViaPackageJsonSvelte(importee, importer) {
|
|
|
1170
1172
|
}
|
|
1171
1173
|
}
|
|
1172
1174
|
function isBareImport(importee) {
|
|
1173
|
-
if (!importee || importee[0] === "." || importee[0] === "\0" || import_path5.default.isAbsolute(importee)) {
|
|
1175
|
+
if (!importee || importee[0] === "." || importee[0] === "\0" || importee.includes(":") || import_path5.default.isAbsolute(importee)) {
|
|
1174
1176
|
return false;
|
|
1175
1177
|
}
|
|
1176
1178
|
const parts = importee.split("/");
|
|
@@ -1467,9 +1469,9 @@ function svelte(inlineOptions) {
|
|
|
1467
1469
|
}
|
|
1468
1470
|
}
|
|
1469
1471
|
},
|
|
1470
|
-
async resolveId(importee, importer, opts
|
|
1471
|
-
const ssr =
|
|
1472
|
-
const svelteRequest = requestParser(importee,
|
|
1472
|
+
async resolveId(importee, importer, opts) {
|
|
1473
|
+
const ssr = !!(opts == null ? void 0 : opts.ssr);
|
|
1474
|
+
const svelteRequest = requestParser(importee, ssr);
|
|
1473
1475
|
if (svelteRequest == null ? void 0 : svelteRequest.query.svelte) {
|
|
1474
1476
|
if (svelteRequest.query.type === "style") {
|
|
1475
1477
|
log.debug(`resolveId resolved virtual css module ${svelteRequest.cssId}`);
|
|
@@ -1510,8 +1512,8 @@ function svelte(inlineOptions) {
|
|
|
1510
1512
|
},
|
|
1511
1513
|
async transform(code, id, opts) {
|
|
1512
1514
|
var _a;
|
|
1513
|
-
const ssr =
|
|
1514
|
-
const svelteRequest = requestParser(id,
|
|
1515
|
+
const ssr = !!(opts == null ? void 0 : opts.ssr);
|
|
1516
|
+
const svelteRequest = requestParser(id, ssr);
|
|
1515
1517
|
if (!svelteRequest) {
|
|
1516
1518
|
return;
|
|
1517
1519
|
}
|