@sveltejs/vite-plugin-svelte 1.0.0-next.38 → 1.0.0-next.41
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 +89 -101
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +79 -84
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/src/index.ts +22 -8
- package/src/utils/esbuild.ts +3 -26
- package/src/utils/optimizer.ts +17 -22
- package/src/utils/options.ts +39 -14
- package/src/utils/preprocess.ts +6 -2
package/dist/index.cjs
CHANGED
|
@@ -21,35 +21,29 @@ var __spreadValues = (a, b) => {
|
|
|
21
21
|
return a;
|
|
22
22
|
};
|
|
23
23
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
24
|
var __export = (target, all) => {
|
|
26
25
|
for (var name in all)
|
|
27
26
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
28
27
|
};
|
|
29
|
-
var
|
|
30
|
-
if (
|
|
31
|
-
for (let key of __getOwnPropNames(
|
|
32
|
-
if (!__hasOwnProp.call(
|
|
33
|
-
__defProp(
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
34
33
|
}
|
|
35
|
-
return
|
|
34
|
+
return to;
|
|
36
35
|
};
|
|
37
|
-
var __toESM = (
|
|
38
|
-
|
|
39
|
-
};
|
|
40
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
41
|
-
return (module2, temp) => {
|
|
42
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
43
|
-
};
|
|
44
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
45
38
|
|
|
46
39
|
// src/index.ts
|
|
47
40
|
var src_exports = {};
|
|
48
41
|
__export(src_exports, {
|
|
49
42
|
svelte: () => svelte
|
|
50
43
|
});
|
|
44
|
+
module.exports = __toCommonJS(src_exports);
|
|
51
45
|
|
|
52
|
-
// ../../node_modules/.pnpm/tsup@5.
|
|
46
|
+
// ../../node_modules/.pnpm/tsup@5.12.4_typescript@4.6.3/node_modules/tsup/assets/cjs_shims.js
|
|
53
47
|
var getImportMetaUrl = () => typeof document === "undefined" ? new URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
54
48
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
55
49
|
|
|
@@ -562,7 +556,7 @@ var SVELTE_HMR_IMPORTS = [
|
|
|
562
556
|
];
|
|
563
557
|
|
|
564
558
|
// src/utils/options.ts
|
|
565
|
-
var
|
|
559
|
+
var import_path4 = __toESM(require("path"), 1);
|
|
566
560
|
|
|
567
561
|
// src/utils/dependencies.ts
|
|
568
562
|
var import_path2 = __toESM(require("path"), 1);
|
|
@@ -592,7 +586,7 @@ function findRootSvelteDependencies(root, cwdFallback = true) {
|
|
|
592
586
|
].filter((dep) => !is_common_without_svelte_field(dep));
|
|
593
587
|
return getSvelteDependencies(deps, root);
|
|
594
588
|
}
|
|
595
|
-
function getSvelteDependencies(deps, pkgDir,
|
|
589
|
+
function getSvelteDependencies(deps, pkgDir, path8 = []) {
|
|
596
590
|
const result = [];
|
|
597
591
|
const localRequire = (0, import_module2.createRequire)(`${pkgDir}/package.json`);
|
|
598
592
|
const resolvedDeps = deps.map((dep) => resolveDependencyData(dep, localRequire)).filter(Boolean);
|
|
@@ -600,18 +594,18 @@ function getSvelteDependencies(deps, pkgDir, path7 = []) {
|
|
|
600
594
|
const type = getSvelteDependencyType(pkg);
|
|
601
595
|
if (!type)
|
|
602
596
|
continue;
|
|
603
|
-
result.push({ name: pkg.name, type, pkg, dir, path:
|
|
597
|
+
result.push({ name: pkg.name, type, pkg, dir, path: path8 });
|
|
604
598
|
if (type === "component-library" && pkg.dependencies) {
|
|
605
599
|
let dependencyNames = Object.keys(pkg.dependencies);
|
|
606
|
-
const circular = dependencyNames.filter((name) =>
|
|
600
|
+
const circular = dependencyNames.filter((name) => path8.includes(name));
|
|
607
601
|
if (circular.length > 0) {
|
|
608
|
-
log.warn.enabled && log.warn(`skipping circular svelte dependencies in automated vite optimizeDeps handling`, circular.map((x) =>
|
|
609
|
-
dependencyNames = dependencyNames.filter((name) => !
|
|
602
|
+
log.warn.enabled && log.warn(`skipping circular svelte dependencies in automated vite optimizeDeps handling`, circular.map((x) => path8.concat(x).join(">")));
|
|
603
|
+
dependencyNames = dependencyNames.filter((name) => !path8.includes(name));
|
|
610
604
|
}
|
|
611
|
-
if (
|
|
612
|
-
log.debug.once(`encountered deep svelte dependency tree: ${
|
|
605
|
+
if (path8.length === 3) {
|
|
606
|
+
log.debug.once(`encountered deep svelte dependency tree: ${path8.join(">")}`);
|
|
613
607
|
}
|
|
614
|
-
result.push(...getSvelteDependencies(dependencyNames, dir,
|
|
608
|
+
result.push(...getSvelteDependencies(dependencyNames, dir, path8.concat(pkg.name)));
|
|
615
609
|
}
|
|
616
610
|
}
|
|
617
611
|
return result;
|
|
@@ -792,7 +786,9 @@ function esbuildSveltePlugin(options) {
|
|
|
792
786
|
return {
|
|
793
787
|
name: "vite-plugin-svelte:optimize-svelte",
|
|
794
788
|
setup(build) {
|
|
795
|
-
|
|
789
|
+
var _a;
|
|
790
|
+
if ((_a = build.initialOptions.plugins) == null ? void 0 : _a.some((v) => v.name === "vite:dep-scan"))
|
|
791
|
+
return;
|
|
796
792
|
const svelteExtensions = (options.extensions ?? [".svelte"]).map((ext) => ext.slice(1));
|
|
797
793
|
const svelteFilter = new RegExp(`\\.(` + svelteExtensions.join("|") + `)(\\?.*)?$`);
|
|
798
794
|
build.onLoad({ filter: svelteFilter }, async ({ path: filename }) => {
|
|
@@ -807,23 +803,6 @@ function esbuildSveltePlugin(options) {
|
|
|
807
803
|
}
|
|
808
804
|
};
|
|
809
805
|
}
|
|
810
|
-
function disableVitePrebundleSvelte(build) {
|
|
811
|
-
var _a;
|
|
812
|
-
const viteDepPrebundlePlugin = (_a = build.initialOptions.plugins) == null ? void 0 : _a.find((v) => v.name === "vite:dep-pre-bundle");
|
|
813
|
-
if (!viteDepPrebundlePlugin)
|
|
814
|
-
return;
|
|
815
|
-
const _setup = viteDepPrebundlePlugin.setup.bind(viteDepPrebundlePlugin);
|
|
816
|
-
viteDepPrebundlePlugin.setup = function(build2) {
|
|
817
|
-
const _onResolve = build2.onResolve.bind(build2);
|
|
818
|
-
build2.onResolve = function(options, callback) {
|
|
819
|
-
if (options.filter.source.includes("svelte")) {
|
|
820
|
-
options.filter = new RegExp(options.filter.source.replace("|svelte", ""), options.filter.flags);
|
|
821
|
-
}
|
|
822
|
-
return _onResolve(options, callback);
|
|
823
|
-
};
|
|
824
|
-
return _setup(build2);
|
|
825
|
-
};
|
|
826
|
-
}
|
|
827
806
|
async function compileSvelte(options, { filename, code }) {
|
|
828
807
|
var _a, _b;
|
|
829
808
|
const compileOptions = __spreadProps(__spreadValues({}, options.compilerOptions), {
|
|
@@ -909,6 +888,7 @@ async function buildSourceMap(from, to, filename) {
|
|
|
909
888
|
}
|
|
910
889
|
|
|
911
890
|
// src/utils/preprocess.ts
|
|
891
|
+
var import_path3 = __toESM(require("path"), 1);
|
|
912
892
|
var supportedStyleLangs = ["css", "less", "sass", "scss", "styl", "stylus", "postcss"];
|
|
913
893
|
var supportedScriptLangs = ["ts"];
|
|
914
894
|
function createViteScriptPreprocessor() {
|
|
@@ -949,7 +929,7 @@ function createViteStylePreprocessor(config) {
|
|
|
949
929
|
const moduleId = `${filename}.${lang}`;
|
|
950
930
|
const transformResult = await pluginTransform(content, moduleId);
|
|
951
931
|
if (((_b = (_a = transformResult.map) == null ? void 0 : _a.sources) == null ? void 0 : _b[0]) === moduleId) {
|
|
952
|
-
transformResult.map.sources[0] = filename;
|
|
932
|
+
transformResult.map.sources[0] = import_path3.default.basename(filename);
|
|
953
933
|
}
|
|
954
934
|
return {
|
|
955
935
|
code: transformResult.code,
|
|
@@ -974,7 +954,10 @@ function createInjectScopeEverythingRulePreprocessorGroup() {
|
|
|
974
954
|
s.append(" *{}");
|
|
975
955
|
return {
|
|
976
956
|
code: s.toString(),
|
|
977
|
-
map: s.generateDecodedMap({
|
|
957
|
+
map: s.generateDecodedMap({
|
|
958
|
+
source: filename ? import_path3.default.basename(filename) : void 0,
|
|
959
|
+
hires: true
|
|
960
|
+
})
|
|
978
961
|
};
|
|
979
962
|
}
|
|
980
963
|
};
|
|
@@ -1192,9 +1175,9 @@ function enforceOptionsForProduction(options) {
|
|
|
1192
1175
|
}
|
|
1193
1176
|
}
|
|
1194
1177
|
function resolveViteRoot(viteConfig) {
|
|
1195
|
-
return (0, import_vite3.normalizePath)(viteConfig.root ?
|
|
1178
|
+
return (0, import_vite3.normalizePath)(viteConfig.root ? import_path4.default.resolve(viteConfig.root) : process.cwd());
|
|
1196
1179
|
}
|
|
1197
|
-
function buildExtraViteConfig(options, config
|
|
1180
|
+
function buildExtraViteConfig(options, config) {
|
|
1198
1181
|
const svelteDeps = findRootSvelteDependencies(options.root);
|
|
1199
1182
|
const extraViteConfig = {
|
|
1200
1183
|
resolve: {
|
|
@@ -1202,22 +1185,31 @@ function buildExtraViteConfig(options, config, configEnv) {
|
|
|
1202
1185
|
dedupe: [...SVELTE_IMPORTS, ...SVELTE_HMR_IMPORTS]
|
|
1203
1186
|
}
|
|
1204
1187
|
};
|
|
1205
|
-
if (
|
|
1188
|
+
if (options.isServe) {
|
|
1206
1189
|
extraViteConfig.optimizeDeps = buildOptimizeDepsForSvelte(svelteDeps, options, config.optimizeDeps);
|
|
1207
1190
|
}
|
|
1208
|
-
|
|
1191
|
+
if (options.experimental.prebundleSvelteLibraries) {
|
|
1192
|
+
extraViteConfig.optimizeDeps = __spreadProps(__spreadValues({}, extraViteConfig.optimizeDeps), {
|
|
1193
|
+
extensions: options.extensions ?? [".svelte"],
|
|
1194
|
+
esbuildOptions: {
|
|
1195
|
+
plugins: [{ name: facadeEsbuildSveltePluginName, setup: () => {
|
|
1196
|
+
} }]
|
|
1197
|
+
}
|
|
1198
|
+
});
|
|
1199
|
+
}
|
|
1200
|
+
extraViteConfig.ssr = buildSSROptionsForSvelte(svelteDeps, options, config, extraViteConfig);
|
|
1209
1201
|
return extraViteConfig;
|
|
1210
1202
|
}
|
|
1211
|
-
function buildOptimizeDepsForSvelte(svelteDeps, options,
|
|
1203
|
+
function buildOptimizeDepsForSvelte(svelteDeps, options, optimizeDeps) {
|
|
1212
1204
|
const include = [];
|
|
1213
1205
|
const exclude = ["svelte-hmr"];
|
|
1214
1206
|
const isIncluded = (dep) => {
|
|
1215
1207
|
var _a;
|
|
1216
|
-
return include.includes(dep) || ((_a =
|
|
1208
|
+
return include.includes(dep) || ((_a = optimizeDeps == null ? void 0 : optimizeDeps.include) == null ? void 0 : _a.includes(dep));
|
|
1217
1209
|
};
|
|
1218
1210
|
const isExcluded = (dep) => {
|
|
1219
1211
|
var _a;
|
|
1220
|
-
return exclude.includes(dep) || ((_a =
|
|
1212
|
+
return exclude.includes(dep) || ((_a = optimizeDeps == null ? void 0 : optimizeDeps.exclude) == null ? void 0 : _a.some((id) => dep === id || id.startsWith(`${dep}/`)));
|
|
1221
1213
|
};
|
|
1222
1214
|
if (!isExcluded("svelte")) {
|
|
1223
1215
|
const svelteImportsToInclude = SVELTE_IMPORTS.filter((x) => x !== "svelte/ssr");
|
|
@@ -1227,14 +1219,7 @@ function buildOptimizeDepsForSvelte(svelteDeps, options, optimizeDeps2) {
|
|
|
1227
1219
|
log.debug('"svelte" is excluded in optimizeDeps.exclude, skipped adding it to include.');
|
|
1228
1220
|
}
|
|
1229
1221
|
if (options.experimental.prebundleSvelteLibraries) {
|
|
1230
|
-
return {
|
|
1231
|
-
include,
|
|
1232
|
-
exclude,
|
|
1233
|
-
esbuildOptions: {
|
|
1234
|
-
plugins: [{ name: facadeEsbuildSveltePluginName, setup: () => {
|
|
1235
|
-
} }]
|
|
1236
|
-
}
|
|
1237
|
-
};
|
|
1222
|
+
return { include, exclude };
|
|
1238
1223
|
}
|
|
1239
1224
|
svelteDeps = svelteDeps.filter((dep) => dep.type === "component-library");
|
|
1240
1225
|
const svelteDepsToExclude = Array.from(new Set(svelteDeps.map((dep) => dep.name))).filter((dep) => !isIncluded(dep));
|
|
@@ -1268,9 +1253,16 @@ function buildSSROptionsForSvelte(svelteDeps, options, config) {
|
|
|
1268
1253
|
var _a2, _b2, _c2, _d;
|
|
1269
1254
|
return !((_b2 = (_a2 = config.ssr) == null ? void 0 : _a2.external) == null ? void 0 : _b2.includes(x)) && !((_d = (_c2 = config.optimizeDeps) == null ? void 0 : _c2.include) == null ? void 0 : _d.includes(x));
|
|
1270
1255
|
}));
|
|
1271
|
-
|
|
1256
|
+
const ssr = {
|
|
1272
1257
|
noExternal
|
|
1273
1258
|
};
|
|
1259
|
+
if (options.isServe) {
|
|
1260
|
+
ssr.external = Array.from(new Set(svelteDeps.flatMap((dep) => Object.keys(dep.pkg.dependencies || {})))).filter((dep) => {
|
|
1261
|
+
var _a2, _b2, _c2, _d;
|
|
1262
|
+
return !ssr.noExternal.includes(dep) && !((_b2 = (_a2 = config.ssr) == null ? void 0 : _a2.noExternal) == null ? void 0 : _b2.includes(dep)) && !((_d = (_c2 = config.ssr) == null ? void 0 : _c2.external) == null ? void 0 : _d.includes(dep));
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
return ssr;
|
|
1274
1266
|
}
|
|
1275
1267
|
function patchResolvedViteConfig(viteConfig, options) {
|
|
1276
1268
|
var _a, _b;
|
|
@@ -1349,8 +1341,8 @@ var VitePluginSvelteCache = class {
|
|
|
1349
1341
|
return this._js.get(svelteRequest.normalizedFilename);
|
|
1350
1342
|
}
|
|
1351
1343
|
}
|
|
1352
|
-
getDependants(
|
|
1353
|
-
const dependants = this._dependants.get(
|
|
1344
|
+
getDependants(path8) {
|
|
1345
|
+
const dependants = this._dependants.get(path8);
|
|
1354
1346
|
return dependants ? [...dependants] : [];
|
|
1355
1347
|
}
|
|
1356
1348
|
getResolvedSvelteField(name, importer) {
|
|
@@ -1366,7 +1358,7 @@ var VitePluginSvelteCache = class {
|
|
|
1366
1358
|
|
|
1367
1359
|
// src/utils/watch.ts
|
|
1368
1360
|
var import_fs4 = __toESM(require("fs"), 1);
|
|
1369
|
-
var
|
|
1361
|
+
var import_path5 = __toESM(require("path"), 1);
|
|
1370
1362
|
function setupWatchers(options, cache, requestParser) {
|
|
1371
1363
|
const { server, configFile: svelteConfigFile } = options;
|
|
1372
1364
|
if (!server) {
|
|
@@ -1405,7 +1397,7 @@ function setupWatchers(options, cache, requestParser) {
|
|
|
1405
1397
|
server.restart();
|
|
1406
1398
|
}
|
|
1407
1399
|
};
|
|
1408
|
-
const possibleSvelteConfigs = knownSvelteConfigNames.map((cfg) =>
|
|
1400
|
+
const possibleSvelteConfigs = knownSvelteConfigNames.map((cfg) => import_path5.default.join(root, cfg));
|
|
1409
1401
|
const restartOnConfigAdd = (filename) => {
|
|
1410
1402
|
if (possibleSvelteConfigs.includes(filename)) {
|
|
1411
1403
|
triggerViteRestart(filename);
|
|
@@ -1435,12 +1427,12 @@ function setupWatchers(options, cache, requestParser) {
|
|
|
1435
1427
|
}
|
|
1436
1428
|
function ensureWatchedFile(watcher, file, root) {
|
|
1437
1429
|
if (file && !file.startsWith(root + "/") && !file.includes("\0") && import_fs4.default.existsSync(file)) {
|
|
1438
|
-
watcher.add(
|
|
1430
|
+
watcher.add(import_path5.default.resolve(file));
|
|
1439
1431
|
}
|
|
1440
1432
|
}
|
|
1441
1433
|
|
|
1442
1434
|
// src/utils/resolve.ts
|
|
1443
|
-
var
|
|
1435
|
+
var import_path6 = __toESM(require("path"), 1);
|
|
1444
1436
|
var import_module4 = require("module");
|
|
1445
1437
|
function resolveViaPackageJsonSvelte(importee, importer, cache) {
|
|
1446
1438
|
if (importer && isBareImport(importee) && !isNodeInternal(importee) && !is_common_without_svelte_field(importee)) {
|
|
@@ -1453,7 +1445,7 @@ function resolveViaPackageJsonSvelte(importee, importer, cache) {
|
|
|
1453
1445
|
if (pkgData) {
|
|
1454
1446
|
const { pkg, dir } = pkgData;
|
|
1455
1447
|
if (pkg.svelte) {
|
|
1456
|
-
const result =
|
|
1448
|
+
const result = import_path6.default.resolve(dir, pkg.svelte);
|
|
1457
1449
|
cache.setResolvedSvelteField(importee, importer, result);
|
|
1458
1450
|
return result;
|
|
1459
1451
|
}
|
|
@@ -1464,7 +1456,7 @@ function isNodeInternal(importee) {
|
|
|
1464
1456
|
return importee.startsWith("node:") || import_module4.builtinModules.includes(importee);
|
|
1465
1457
|
}
|
|
1466
1458
|
function isBareImport(importee) {
|
|
1467
|
-
if (!importee || importee[0] === "." || importee[0] === "\0" || importee.includes(":") ||
|
|
1459
|
+
if (!importee || importee[0] === "." || importee[0] === "\0" || importee.includes(":") || import_path6.default.isAbsolute(importee)) {
|
|
1468
1460
|
return false;
|
|
1469
1461
|
}
|
|
1470
1462
|
const parts = importee.split("/");
|
|
@@ -1479,9 +1471,8 @@ function isBareImport(importee) {
|
|
|
1479
1471
|
}
|
|
1480
1472
|
|
|
1481
1473
|
// src/utils/optimizer.ts
|
|
1482
|
-
var import_fs5 =
|
|
1483
|
-
var
|
|
1484
|
-
var import_vite4 = require("vite");
|
|
1474
|
+
var import_fs5 = require("fs");
|
|
1475
|
+
var import_path7 = __toESM(require("path"), 1);
|
|
1485
1476
|
var PREBUNDLE_SENSITIVE_OPTIONS = [
|
|
1486
1477
|
"compilerOptions",
|
|
1487
1478
|
"configFile",
|
|
@@ -1490,23 +1481,20 @@ var PREBUNDLE_SENSITIVE_OPTIONS = [
|
|
|
1490
1481
|
"ignorePluginPreprocessors",
|
|
1491
1482
|
"preprocess"
|
|
1492
1483
|
];
|
|
1493
|
-
async function
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
const
|
|
1497
|
-
if (!viteMetadataPath)
|
|
1498
|
-
return;
|
|
1499
|
-
const svelteMetadataPath = import_path6.default.resolve(viteMetadataPath, "../_svelte_metadata.json");
|
|
1500
|
-
const currentSvelteMetadata = JSON.stringify(generateSvelteMetadata(options), (_, value) => {
|
|
1484
|
+
async function saveSvelteMetadata(cacheDir, options) {
|
|
1485
|
+
const svelteMetadata = generateSvelteMetadata(options);
|
|
1486
|
+
const svelteMetadataPath = import_path7.default.resolve(cacheDir, "_svelte_metadata.json");
|
|
1487
|
+
const currentSvelteMetadata = JSON.stringify(svelteMetadata, (_, value) => {
|
|
1501
1488
|
return typeof value === "function" ? value.toString() : value;
|
|
1502
1489
|
});
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1490
|
+
let existingSvelteMetadata;
|
|
1491
|
+
try {
|
|
1492
|
+
existingSvelteMetadata = await import_fs5.promises.readFile(svelteMetadataPath, "utf8");
|
|
1493
|
+
} catch {
|
|
1507
1494
|
}
|
|
1508
|
-
await
|
|
1509
|
-
import_fs5.
|
|
1495
|
+
await import_fs5.promises.mkdir(cacheDir, { recursive: true });
|
|
1496
|
+
await import_fs5.promises.writeFile(svelteMetadataPath, currentSvelteMetadata);
|
|
1497
|
+
return currentSvelteMetadata !== existingSvelteMetadata;
|
|
1510
1498
|
}
|
|
1511
1499
|
function generateSvelteMetadata(options) {
|
|
1512
1500
|
const metadata = {};
|
|
@@ -1515,14 +1503,6 @@ function generateSvelteMetadata(options) {
|
|
|
1515
1503
|
}
|
|
1516
1504
|
return metadata;
|
|
1517
1505
|
}
|
|
1518
|
-
function findViteMetadataPath(cacheDir) {
|
|
1519
|
-
const metadataPaths = ["_metadata.json", "deps/_metadata.json"];
|
|
1520
|
-
for (const metadataPath of metadataPaths) {
|
|
1521
|
-
const viteMetadataPath = import_path6.default.resolve(cacheDir, metadataPath);
|
|
1522
|
-
if (import_fs5.default.existsSync(viteMetadataPath))
|
|
1523
|
-
return viteMetadataPath;
|
|
1524
|
-
}
|
|
1525
|
-
}
|
|
1526
1506
|
|
|
1527
1507
|
// src/index.ts
|
|
1528
1508
|
function svelte(inlineOptions) {
|
|
@@ -1546,7 +1526,7 @@ function svelte(inlineOptions) {
|
|
|
1546
1526
|
log.setLevel(config.logLevel);
|
|
1547
1527
|
}
|
|
1548
1528
|
options = await preResolveOptions(inlineOptions, config, configEnv);
|
|
1549
|
-
const extraViteConfig = buildExtraViteConfig(options, config
|
|
1529
|
+
const extraViteConfig = buildExtraViteConfig(options, config);
|
|
1550
1530
|
log.debug("additional vite config", extraViteConfig);
|
|
1551
1531
|
return extraViteConfig;
|
|
1552
1532
|
},
|
|
@@ -1559,7 +1539,12 @@ function svelte(inlineOptions) {
|
|
|
1559
1539
|
log.debug("resolved options", options);
|
|
1560
1540
|
},
|
|
1561
1541
|
async buildStart() {
|
|
1562
|
-
|
|
1542
|
+
if (!options.experimental.prebundleSvelteLibraries)
|
|
1543
|
+
return;
|
|
1544
|
+
const isSvelteMetadataChanged = await saveSvelteMetadata(viteConfig.cacheDir, options);
|
|
1545
|
+
if (isSvelteMetadataChanged) {
|
|
1546
|
+
viteConfig.server.force = true;
|
|
1547
|
+
}
|
|
1563
1548
|
},
|
|
1564
1549
|
configureServer(server) {
|
|
1565
1550
|
options.server = server;
|
|
@@ -1606,10 +1591,14 @@ function svelte(inlineOptions) {
|
|
|
1606
1591
|
}
|
|
1607
1592
|
return resolvedSvelteSSR;
|
|
1608
1593
|
}
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1594
|
+
try {
|
|
1595
|
+
const resolved = resolveViaPackageJsonSvelte(importee, importer, cache);
|
|
1596
|
+
if (resolved) {
|
|
1597
|
+
log.debug(`resolveId resolved ${resolved} via package.json svelte field of ${importee}`);
|
|
1598
|
+
return resolved;
|
|
1599
|
+
}
|
|
1600
|
+
} catch (e) {
|
|
1601
|
+
log.debug.once(`error trying to resolve ${importee} from ${importer} via package.json svelte field `, e);
|
|
1613
1602
|
}
|
|
1614
1603
|
},
|
|
1615
1604
|
async transform(code, id, opts) {
|
|
@@ -1646,7 +1635,6 @@ function svelte(inlineOptions) {
|
|
|
1646
1635
|
}
|
|
1647
1636
|
};
|
|
1648
1637
|
}
|
|
1649
|
-
module.exports = __toCommonJS(src_exports);
|
|
1650
1638
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1651
1639
|
0 && (module.exports = {
|
|
1652
1640
|
svelte
|