@sveltejs/vite-plugin-svelte 1.0.0-next.44 → 1.0.0-next.45
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 +20 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +19 -6
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/src/ui/inspector/Inspector.svelte +1 -1
- package/src/ui/inspector/plugin.ts +1 -1
- package/src/utils/__tests__/dependencies.spec.ts +7 -4
- package/src/utils/__tests__/sourcemap.spec.ts +1 -0
- package/src/utils/compile.ts +2 -1
- package/src/utils/options.ts +26 -6
package/dist/index.d.ts
CHANGED
|
@@ -46,11 +46,13 @@ interface Options {
|
|
|
46
46
|
*/
|
|
47
47
|
emitCss?: boolean;
|
|
48
48
|
/**
|
|
49
|
-
* The options to be passed to the Svelte compiler
|
|
49
|
+
* The options to be passed to the Svelte compiler. A few options are set by default,
|
|
50
|
+
* including `dev` and `css`. However, some options are non-configurable, like
|
|
51
|
+
* `filename`, `format`, `generate`, and `cssHash` (in dev).
|
|
50
52
|
*
|
|
51
53
|
* @see https://svelte.dev/docs#svelte_compile
|
|
52
54
|
*/
|
|
53
|
-
compilerOptions?: CompileOptions
|
|
55
|
+
compilerOptions?: Omit<CompileOptions, 'filename' | 'format' | 'generate'>;
|
|
54
56
|
/**
|
|
55
57
|
* Handles warning emitted from the Svelte compiler
|
|
56
58
|
*/
|
package/dist/index.js
CHANGED
|
@@ -280,7 +280,8 @@ var _createCompileSvelte = (makeHot) => async function compileSvelte2(svelteRequ
|
|
|
280
280
|
const dependencies = [];
|
|
281
281
|
const compileOptions = __spreadProps(__spreadValues({}, options.compilerOptions), {
|
|
282
282
|
filename,
|
|
283
|
-
generate: ssr ? "ssr" : "dom"
|
|
283
|
+
generate: ssr ? "ssr" : "dom",
|
|
284
|
+
format: "esm"
|
|
284
285
|
});
|
|
285
286
|
if (options.hot && options.emitCss) {
|
|
286
287
|
const hash = `s-${safeBase64Hash(normalizedFilename)}`;
|
|
@@ -1083,10 +1084,7 @@ async function preResolveOptions(inlineOptions = {}, viteUserConfig, viteEnv) {
|
|
|
1083
1084
|
});
|
|
1084
1085
|
const defaultOptions = {
|
|
1085
1086
|
extensions: [".svelte"],
|
|
1086
|
-
emitCss: true
|
|
1087
|
-
compilerOptions: {
|
|
1088
|
-
format: "esm"
|
|
1089
|
-
}
|
|
1087
|
+
emitCss: true
|
|
1090
1088
|
};
|
|
1091
1089
|
const svelteConfig = await loadSvelteConfig(viteConfigWithResolvedRoot, inlineOptions);
|
|
1092
1090
|
const extraOptions = {
|
|
@@ -1123,6 +1121,7 @@ function resolveOptions(preResolveOptions2, viteConfig) {
|
|
|
1123
1121
|
isProduction: viteConfig.isProduction
|
|
1124
1122
|
};
|
|
1125
1123
|
const merged = mergeConfigs(defaultOptions, preResolveOptions2, extraOptions);
|
|
1124
|
+
removeIgnoredOptions(merged);
|
|
1126
1125
|
addExtraPreprocessors(merged, viteConfig);
|
|
1127
1126
|
enforceOptionsForHmr(merged);
|
|
1128
1127
|
enforceOptionsForProduction(merged);
|
|
@@ -1171,6 +1170,20 @@ function enforceOptionsForProduction(options) {
|
|
|
1171
1170
|
}
|
|
1172
1171
|
}
|
|
1173
1172
|
}
|
|
1173
|
+
function removeIgnoredOptions(options) {
|
|
1174
|
+
const ignoredCompilerOptions = ["generate", "format", "filename"];
|
|
1175
|
+
if (options.hot && options.emitCss) {
|
|
1176
|
+
ignoredCompilerOptions.push("cssHash");
|
|
1177
|
+
}
|
|
1178
|
+
const passedCompilerOptions = Object.keys(options.compilerOptions || {});
|
|
1179
|
+
const passedIgnored = passedCompilerOptions.filter((o) => ignoredCompilerOptions.includes(o));
|
|
1180
|
+
if (passedIgnored.length) {
|
|
1181
|
+
log.warn(`The following Svelte compilerOptions are controlled by vite-plugin-svelte and essential to its functionality. User-specified values are ignored. Please remove them from your configuration: ${passedIgnored.join(", ")}`);
|
|
1182
|
+
passedIgnored.forEach((ignored) => {
|
|
1183
|
+
delete options.compilerOptions[ignored];
|
|
1184
|
+
});
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1174
1187
|
function resolveViteRoot(viteConfig) {
|
|
1175
1188
|
return normalizePath2(viteConfig.root ? path4.resolve(viteConfig.root) : process.cwd());
|
|
1176
1189
|
}
|
|
@@ -1542,7 +1555,7 @@ function svelteInspector() {
|
|
|
1542
1555
|
disabled = true;
|
|
1543
1556
|
} else {
|
|
1544
1557
|
if (vps.api.options.kit && !inspectorOptions.appendTo) {
|
|
1545
|
-
const out_dir = vps.api.options.kit.outDir || ".svelte-kit";
|
|
1558
|
+
const out_dir = path8.basename(vps.api.options.kit.outDir || ".svelte-kit");
|
|
1546
1559
|
inspectorOptions.appendTo = `${out_dir}/runtime/client/start.js`;
|
|
1547
1560
|
}
|
|
1548
1561
|
appendTo = inspectorOptions.appendTo;
|