@sveltejs/vite-plugin-svelte 1.0.0-next.44 → 1.0.0-next.47
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 +27 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.js +25 -11
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/index.ts +2 -0
- 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/load-svelte-config.ts +12 -8
- package/src/utils/options.ts +26 -6
package/dist/index.cjs
CHANGED
|
@@ -39,11 +39,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
39
39
|
// src/index.ts
|
|
40
40
|
var src_exports = {};
|
|
41
41
|
__export(src_exports, {
|
|
42
|
+
loadSvelteConfig: () => loadSvelteConfig,
|
|
42
43
|
svelte: () => svelte
|
|
43
44
|
});
|
|
44
45
|
module.exports = __toCommonJS(src_exports);
|
|
45
46
|
|
|
46
|
-
// ../../node_modules/.pnpm/tsup@
|
|
47
|
+
// ../../node_modules/.pnpm/tsup@6.0.1/node_modules/tsup/assets/cjs_shims.js
|
|
47
48
|
var getImportMetaUrl = () => typeof document === "undefined" ? new URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
48
49
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
49
50
|
|
|
@@ -302,7 +303,8 @@ var _createCompileSvelte = (makeHot) => async function compileSvelte2(svelteRequ
|
|
|
302
303
|
const dependencies = [];
|
|
303
304
|
const compileOptions = __spreadProps(__spreadValues({}, options.compilerOptions), {
|
|
304
305
|
filename,
|
|
305
|
-
generate: ssr ? "ssr" : "dom"
|
|
306
|
+
generate: ssr ? "ssr" : "dom",
|
|
307
|
+
format: "esm"
|
|
306
308
|
});
|
|
307
309
|
if (options.hot && options.emitCss) {
|
|
308
310
|
const hash = `s-${safeBase64Hash(normalizedFilename)}`;
|
|
@@ -476,9 +478,9 @@ var knownSvelteConfigNames = [
|
|
|
476
478
|
"svelte.config.cjs",
|
|
477
479
|
"svelte.config.mjs"
|
|
478
480
|
];
|
|
479
|
-
var dynamicImportDefault = new Function("path", 'return import(path + "?t=" +
|
|
481
|
+
var dynamicImportDefault = new Function("path", "timestamp", 'return import(path + "?t=" + timestamp).then(m => m.default)');
|
|
480
482
|
async function loadSvelteConfig(viteConfig, inlineOptions) {
|
|
481
|
-
if (inlineOptions.configFile === false) {
|
|
483
|
+
if ((inlineOptions == null ? void 0 : inlineOptions.configFile) === false) {
|
|
482
484
|
return;
|
|
483
485
|
}
|
|
484
486
|
const configFile = findConfigToLoad(viteConfig, inlineOptions);
|
|
@@ -486,7 +488,7 @@ async function loadSvelteConfig(viteConfig, inlineOptions) {
|
|
|
486
488
|
let err;
|
|
487
489
|
if (configFile.endsWith(".js") || configFile.endsWith(".mjs")) {
|
|
488
490
|
try {
|
|
489
|
-
const result = await dynamicImportDefault((0, import_url.pathToFileURL)(configFile).href);
|
|
491
|
+
const result = await dynamicImportDefault((0, import_url.pathToFileURL)(configFile).href, import_fs.default.statSync(configFile).mtimeMs);
|
|
490
492
|
if (result != null) {
|
|
491
493
|
return __spreadProps(__spreadValues({}, result), {
|
|
492
494
|
configFile
|
|
@@ -522,8 +524,8 @@ async function loadSvelteConfig(viteConfig, inlineOptions) {
|
|
|
522
524
|
}
|
|
523
525
|
}
|
|
524
526
|
function findConfigToLoad(viteConfig, inlineOptions) {
|
|
525
|
-
const root = viteConfig.root || process.cwd();
|
|
526
|
-
if (inlineOptions.configFile) {
|
|
527
|
+
const root = (viteConfig == null ? void 0 : viteConfig.root) || process.cwd();
|
|
528
|
+
if (inlineOptions == null ? void 0 : inlineOptions.configFile) {
|
|
527
529
|
const abolutePath = import_path.default.isAbsolute(inlineOptions.configFile) ? inlineOptions.configFile : import_path.default.resolve(root, inlineOptions.configFile);
|
|
528
530
|
if (!import_fs.default.existsSync(abolutePath)) {
|
|
529
531
|
throw new Error(`failed to find svelte config file ${abolutePath}.`);
|
|
@@ -1101,10 +1103,7 @@ async function preResolveOptions(inlineOptions = {}, viteUserConfig, viteEnv) {
|
|
|
1101
1103
|
});
|
|
1102
1104
|
const defaultOptions = {
|
|
1103
1105
|
extensions: [".svelte"],
|
|
1104
|
-
emitCss: true
|
|
1105
|
-
compilerOptions: {
|
|
1106
|
-
format: "esm"
|
|
1107
|
-
}
|
|
1106
|
+
emitCss: true
|
|
1108
1107
|
};
|
|
1109
1108
|
const svelteConfig = await loadSvelteConfig(viteConfigWithResolvedRoot, inlineOptions);
|
|
1110
1109
|
const extraOptions = {
|
|
@@ -1141,6 +1140,7 @@ function resolveOptions(preResolveOptions2, viteConfig) {
|
|
|
1141
1140
|
isProduction: viteConfig.isProduction
|
|
1142
1141
|
};
|
|
1143
1142
|
const merged = mergeConfigs(defaultOptions, preResolveOptions2, extraOptions);
|
|
1143
|
+
removeIgnoredOptions(merged);
|
|
1144
1144
|
addExtraPreprocessors(merged, viteConfig);
|
|
1145
1145
|
enforceOptionsForHmr(merged);
|
|
1146
1146
|
enforceOptionsForProduction(merged);
|
|
@@ -1189,6 +1189,20 @@ function enforceOptionsForProduction(options) {
|
|
|
1189
1189
|
}
|
|
1190
1190
|
}
|
|
1191
1191
|
}
|
|
1192
|
+
function removeIgnoredOptions(options) {
|
|
1193
|
+
const ignoredCompilerOptions = ["generate", "format", "filename"];
|
|
1194
|
+
if (options.hot && options.emitCss) {
|
|
1195
|
+
ignoredCompilerOptions.push("cssHash");
|
|
1196
|
+
}
|
|
1197
|
+
const passedCompilerOptions = Object.keys(options.compilerOptions || {});
|
|
1198
|
+
const passedIgnored = passedCompilerOptions.filter((o) => ignoredCompilerOptions.includes(o));
|
|
1199
|
+
if (passedIgnored.length) {
|
|
1200
|
+
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(", ")}`);
|
|
1201
|
+
passedIgnored.forEach((ignored) => {
|
|
1202
|
+
delete options.compilerOptions[ignored];
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1192
1206
|
function resolveViteRoot(viteConfig) {
|
|
1193
1207
|
return (0, import_vite3.normalizePath)(viteConfig.root ? import_path4.default.resolve(viteConfig.root) : process.cwd());
|
|
1194
1208
|
}
|
|
@@ -1560,7 +1574,7 @@ function svelteInspector() {
|
|
|
1560
1574
|
disabled = true;
|
|
1561
1575
|
} else {
|
|
1562
1576
|
if (vps.api.options.kit && !inspectorOptions.appendTo) {
|
|
1563
|
-
const out_dir = vps.api.options.kit.outDir || ".svelte-kit";
|
|
1577
|
+
const out_dir = import_path8.default.basename(vps.api.options.kit.outDir || ".svelte-kit");
|
|
1564
1578
|
inspectorOptions.appendTo = `${out_dir}/runtime/client/start.js`;
|
|
1565
1579
|
}
|
|
1566
1580
|
appendTo = inspectorOptions.appendTo;
|
|
@@ -1765,6 +1779,7 @@ function svelte(inlineOptions) {
|
|
|
1765
1779
|
}
|
|
1766
1780
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1767
1781
|
0 && (module.exports = {
|
|
1782
|
+
loadSvelteConfig,
|
|
1768
1783
|
svelte
|
|
1769
1784
|
});
|
|
1770
1785
|
//# sourceMappingURL=index.cjs.map
|