vite 8.0.0-beta.2 → 8.0.0-beta.4
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/client/client.mjs +4 -4
- package/dist/node/chunks/node.js +368 -384
- package/dist/node/index.d.ts +4 -3
- package/package.json +8 -8
package/dist/node/chunks/node.js
CHANGED
|
@@ -313,7 +313,7 @@ function sort(line) {
|
|
|
313
313
|
function sortComparator$1(a, b) {
|
|
314
314
|
return a[0] - b[0];
|
|
315
315
|
}
|
|
316
|
-
function encode(decoded) {
|
|
316
|
+
function encode$1(decoded) {
|
|
317
317
|
const writer = new StringWriter();
|
|
318
318
|
let sourcesIndex = 0;
|
|
319
319
|
let sourceLine = 0;
|
|
@@ -639,7 +639,7 @@ function traceSegment(map$1, line, column) {
|
|
|
639
639
|
const index = traceSegmentInternal(segments, cast$1(map$1)._decodedMemo, line, column, GREATEST_LOWER_BOUND);
|
|
640
640
|
return index === -1 ? null : segments[index];
|
|
641
641
|
}
|
|
642
|
-
function originalPositionFor(map$1, needle) {
|
|
642
|
+
function originalPositionFor$1(map$1, needle) {
|
|
643
643
|
let { line, column, bias } = needle;
|
|
644
644
|
line--;
|
|
645
645
|
if (line < 0) throw new Error(LINE_GTR_ZERO);
|
|
@@ -753,7 +753,7 @@ function toDecodedMap(map$1) {
|
|
|
753
753
|
}
|
|
754
754
|
function toEncodedMap(map$1) {
|
|
755
755
|
const decoded = toDecodedMap(map$1);
|
|
756
|
-
return Object.assign({}, decoded, { mappings: encode(decoded.mappings) });
|
|
756
|
+
return Object.assign({}, decoded, { mappings: encode$1(decoded.mappings) });
|
|
757
757
|
}
|
|
758
758
|
function addSegmentInternal(skipable, map$1, genLine, genColumn, source, sourceLine, sourceColumn, name, content) {
|
|
759
759
|
const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names } = cast2(map$1);
|
|
@@ -855,7 +855,7 @@ function traceMappings(tree) {
|
|
|
855
855
|
let traced = SOURCELESS_MAPPING;
|
|
856
856
|
if (segment.length !== 1) {
|
|
857
857
|
const source2 = rootSources[segment[1]];
|
|
858
|
-
traced = originalPositionFor
|
|
858
|
+
traced = originalPositionFor(source2, segment[2], segment[3], segment.length === 5 ? rootNames[segment[4]] : "");
|
|
859
859
|
if (traced == null) continue;
|
|
860
860
|
}
|
|
861
861
|
const { column, line, name, content, source, ignore } = traced;
|
|
@@ -866,12 +866,12 @@ function traceMappings(tree) {
|
|
|
866
866
|
}
|
|
867
867
|
return gen;
|
|
868
868
|
}
|
|
869
|
-
function originalPositionFor
|
|
869
|
+
function originalPositionFor(source, line, column, name) {
|
|
870
870
|
if (!source.map) return SegmentObject(source.source, line, column, name, source.content, source.ignore);
|
|
871
871
|
const segment = traceSegment(source.map, line, column);
|
|
872
872
|
if (segment == null) return null;
|
|
873
873
|
if (segment.length === 1) return SOURCELESS_MAPPING;
|
|
874
|
-
return originalPositionFor
|
|
874
|
+
return originalPositionFor(source.sources[segment[1]], segment[2], segment[3], segment.length === 5 ? source.map.names[segment[4]] : name);
|
|
875
875
|
}
|
|
876
876
|
function asArray(value$1) {
|
|
877
877
|
if (Array.isArray(value$1)) return value$1;
|
|
@@ -1442,7 +1442,7 @@ function loadPackageData(pkgPath) {
|
|
|
1442
1442
|
let hasSideEffects;
|
|
1443
1443
|
if (typeof sideEffects === "boolean") hasSideEffects = () => sideEffects;
|
|
1444
1444
|
else if (Array.isArray(sideEffects)) if (sideEffects.length <= 0) hasSideEffects = () => false;
|
|
1445
|
-
else hasSideEffects = createFilter(sideEffects.map((sideEffect) => {
|
|
1445
|
+
else hasSideEffects = createFilter$1(sideEffects.map((sideEffect) => {
|
|
1446
1446
|
if (sideEffect.includes("/")) return sideEffect;
|
|
1447
1447
|
return `**/${sideEffect}`;
|
|
1448
1448
|
}), null, { resolve: pkgDir });
|
|
@@ -1488,7 +1488,7 @@ function watchPackageDataPlugin(packageCache) {
|
|
|
1488
1488
|
let watchFile = watchFileStub;
|
|
1489
1489
|
const setPackageData = packageCache.set.bind(packageCache);
|
|
1490
1490
|
packageCache.set = (id, pkg) => {
|
|
1491
|
-
if (!isInNodeModules(pkg.dir) && !watchedDirs.has(pkg.dir)) {
|
|
1491
|
+
if (!isInNodeModules$1(pkg.dir) && !watchedDirs.has(pkg.dir)) {
|
|
1492
1492
|
watchedDirs.add(pkg.dir);
|
|
1493
1493
|
watchFile(path.join(pkg.dir, "package.json"));
|
|
1494
1494
|
}
|
|
@@ -1575,9 +1575,9 @@ function traverseBetweenDirs(longerDir, shorterDir, cb) {
|
|
|
1575
1575
|
|
|
1576
1576
|
//#endregion
|
|
1577
1577
|
//#region src/node/utils.ts
|
|
1578
|
-
var import_picocolors
|
|
1578
|
+
var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
1579
1579
|
init_node();
|
|
1580
|
-
const createFilter = createFilter$2;
|
|
1580
|
+
const createFilter$1 = createFilter$2;
|
|
1581
1581
|
const replaceSlashOrColonRE = /[/:]/g;
|
|
1582
1582
|
const replaceDotRE = /\./g;
|
|
1583
1583
|
const replaceNestedIdRE = /\s*>\s*/g;
|
|
@@ -1616,7 +1616,7 @@ function isNodeBuiltin(id) {
|
|
|
1616
1616
|
if (id.startsWith(NODE_BUILTIN_NAMESPACE)) return true;
|
|
1617
1617
|
return nodeBuiltins.includes(id);
|
|
1618
1618
|
}
|
|
1619
|
-
function isInNodeModules(id) {
|
|
1619
|
+
function isInNodeModules$1(id) {
|
|
1620
1620
|
return id.includes("node_modules");
|
|
1621
1621
|
}
|
|
1622
1622
|
function moduleListContains(moduleList, id) {
|
|
@@ -1719,10 +1719,10 @@ function removeImportQuery(url$4) {
|
|
|
1719
1719
|
function removeDirectQuery(url$4) {
|
|
1720
1720
|
return url$4.replace(directRequestRE$1, "$1").replace(trailingSeparatorRE, "");
|
|
1721
1721
|
}
|
|
1722
|
-
const urlRE = /(\?|&)url(?:&|$)/;
|
|
1723
|
-
const rawRE = /(\?|&)raw(?:&|$)/;
|
|
1722
|
+
const urlRE$1 = /(\?|&)url(?:&|$)/;
|
|
1723
|
+
const rawRE$1 = /(\?|&)raw(?:&|$)/;
|
|
1724
1724
|
function removeUrlQuery(url$4) {
|
|
1725
|
-
return url$4.replace(urlRE, "$1").replace(trailingSeparatorRE, "");
|
|
1725
|
+
return url$4.replace(urlRE$1, "$1").replace(trailingSeparatorRE, "");
|
|
1726
1726
|
}
|
|
1727
1727
|
function injectQuery(url$4, queryToInject) {
|
|
1728
1728
|
const { file, postfix } = splitFileAndPostfix(url$4);
|
|
@@ -1747,9 +1747,9 @@ async function asyncReplace(input, re, replacer) {
|
|
|
1747
1747
|
function timeFrom(start, subtract = 0) {
|
|
1748
1748
|
const time = performance$1.now() - start - subtract;
|
|
1749
1749
|
const timeString = (time.toFixed(2) + `ms`).padEnd(5, " ");
|
|
1750
|
-
if (time < 10) return import_picocolors
|
|
1751
|
-
else if (time < 50) return import_picocolors
|
|
1752
|
-
else return import_picocolors
|
|
1750
|
+
if (time < 10) return import_picocolors.default.green(timeString);
|
|
1751
|
+
else if (time < 50) return import_picocolors.default.yellow(timeString);
|
|
1752
|
+
else return import_picocolors.default.red(timeString);
|
|
1753
1753
|
}
|
|
1754
1754
|
/**
|
|
1755
1755
|
* pretty url for logging.
|
|
@@ -1759,10 +1759,10 @@ function prettifyUrl(url$4, root) {
|
|
|
1759
1759
|
const isAbsoluteFile = url$4.startsWith(root);
|
|
1760
1760
|
if (isAbsoluteFile || url$4.startsWith(FS_PREFIX)) {
|
|
1761
1761
|
const file = path.posix.relative(root, isAbsoluteFile ? url$4 : fsPathFromId(url$4));
|
|
1762
|
-
return import_picocolors
|
|
1763
|
-
} else return import_picocolors
|
|
1762
|
+
return import_picocolors.default.dim(file);
|
|
1763
|
+
} else return import_picocolors.default.dim(url$4);
|
|
1764
1764
|
}
|
|
1765
|
-
function isObject(value$1) {
|
|
1765
|
+
function isObject$1(value$1) {
|
|
1766
1766
|
return Object.prototype.toString.call(value$1) === "[object Object]";
|
|
1767
1767
|
}
|
|
1768
1768
|
function isDefined(value$1) {
|
|
@@ -2194,7 +2194,7 @@ function backwardCompatibleWorkerPlugins(plugins) {
|
|
|
2194
2194
|
}
|
|
2195
2195
|
function deepClone(value$1) {
|
|
2196
2196
|
if (Array.isArray(value$1)) return value$1.map((v) => deepClone(v));
|
|
2197
|
-
if (isObject(value$1)) {
|
|
2197
|
+
if (isObject$1(value$1)) {
|
|
2198
2198
|
const cloned = {};
|
|
2199
2199
|
for (const key in value$1) cloned[key] = deepClone(value$1[key]);
|
|
2200
2200
|
return cloned;
|
|
@@ -2214,7 +2214,7 @@ function mergeWithDefaultsRecursively(defaults, values) {
|
|
|
2214
2214
|
merged[key] = value$1;
|
|
2215
2215
|
continue;
|
|
2216
2216
|
}
|
|
2217
|
-
if (isObject(existing) && isObject(value$1)) {
|
|
2217
|
+
if (isObject$1(existing) && isObject$1(value$1)) {
|
|
2218
2218
|
merged[key] = mergeWithDefaultsRecursively(existing, value$1);
|
|
2219
2219
|
continue;
|
|
2220
2220
|
}
|
|
@@ -2298,7 +2298,7 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
|
|
|
2298
2298
|
merged[key] = [...arraify(existing), ...arraify(value$1)];
|
|
2299
2299
|
continue;
|
|
2300
2300
|
}
|
|
2301
|
-
if (isObject(existing) && isObject(value$1)) {
|
|
2301
|
+
if (isObject$1(existing) && isObject$1(value$1)) {
|
|
2302
2302
|
merged[key] = mergeConfigRecursively(existing, value$1, rootPath && !environmentPathRE.test(rootPath) ? `${rootPath}.${key}` : key);
|
|
2303
2303
|
continue;
|
|
2304
2304
|
}
|
|
@@ -2313,7 +2313,7 @@ function mergeConfig(defaults, overrides, isRoot = true) {
|
|
|
2313
2313
|
function mergeAlias(a, b) {
|
|
2314
2314
|
if (!a) return b;
|
|
2315
2315
|
if (!b) return a;
|
|
2316
|
-
if (isObject(a) && isObject(b)) return {
|
|
2316
|
+
if (isObject$1(a) && isObject$1(b)) return {
|
|
2317
2317
|
...a,
|
|
2318
2318
|
...b
|
|
2319
2319
|
};
|
|
@@ -2424,7 +2424,7 @@ function getPkgName(name) {
|
|
|
2424
2424
|
return name[0] === "@" ? name.split("/")[1] : name;
|
|
2425
2425
|
}
|
|
2426
2426
|
const escapeRegexRE$1 = /[-/\\^$*+?.()|[\]{}]/g;
|
|
2427
|
-
function escapeRegex(str) {
|
|
2427
|
+
function escapeRegex$1(str) {
|
|
2428
2428
|
return str.replace(escapeRegexRE$1, "\\$&");
|
|
2429
2429
|
}
|
|
2430
2430
|
function getPackageManagerCommand(type = "install") {
|
|
@@ -2585,19 +2585,18 @@ function perEnvironmentState(initial) {
|
|
|
2585
2585
|
|
|
2586
2586
|
//#endregion
|
|
2587
2587
|
//#region src/node/plugins/reporter.ts
|
|
2588
|
-
var import_picocolors$34 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
2589
2588
|
const groups = [
|
|
2590
2589
|
{
|
|
2591
2590
|
name: "Assets",
|
|
2592
|
-
color: import_picocolors
|
|
2591
|
+
color: import_picocolors.default.green
|
|
2593
2592
|
},
|
|
2594
2593
|
{
|
|
2595
2594
|
name: "CSS",
|
|
2596
|
-
color: import_picocolors
|
|
2595
|
+
color: import_picocolors.default.magenta
|
|
2597
2596
|
},
|
|
2598
2597
|
{
|
|
2599
2598
|
name: "JS",
|
|
2600
|
-
color: import_picocolors
|
|
2599
|
+
color: import_picocolors.default.cyan
|
|
2601
2600
|
}
|
|
2602
2601
|
];
|
|
2603
2602
|
const COMPRESSIBLE_ASSETS_RE = /\.(?:html|json|svg|txt|xml|xhtml|wasm)$/;
|
|
@@ -2631,7 +2630,7 @@ function buildReporterPlugin(config) {
|
|
|
2631
2630
|
let hasTransformed = false;
|
|
2632
2631
|
let transformedCount = 0;
|
|
2633
2632
|
const logTransform = throttle((id) => {
|
|
2634
|
-
writeLine(`transforming (${transformedCount}) ${import_picocolors
|
|
2633
|
+
writeLine(`transforming (${transformedCount}) ${import_picocolors.default.dim(path.relative(config.root, id))}`);
|
|
2635
2634
|
});
|
|
2636
2635
|
return {
|
|
2637
2636
|
reset() {
|
|
@@ -2649,7 +2648,7 @@ function buildReporterPlugin(config) {
|
|
|
2649
2648
|
},
|
|
2650
2649
|
log() {
|
|
2651
2650
|
if (tty) clearLine$1();
|
|
2652
|
-
environment.logger.info(`${import_picocolors
|
|
2651
|
+
environment.logger.info(`${import_picocolors.default.green(`✓`)} ${transformedCount} modules transformed.`);
|
|
2653
2652
|
}
|
|
2654
2653
|
};
|
|
2655
2654
|
}) : void 0;
|
|
@@ -2731,19 +2730,19 @@ function buildReporterPlugin(config) {
|
|
|
2731
2730
|
for (const entry of filtered.sort((a, z) => a.size - z.size)) {
|
|
2732
2731
|
const isLarge = group.name === "JS" && entry.size / 1e3 > chunkLimit;
|
|
2733
2732
|
if (isLarge) hasLargeChunks = true;
|
|
2734
|
-
const sizeColor = isLarge ? import_picocolors
|
|
2735
|
-
let log$1 = import_picocolors
|
|
2736
|
-
log$1 += !config.build.lib && entry.name.startsWith(withTrailingSlash(assetsDir)) ? import_picocolors
|
|
2737
|
-
log$1 += import_picocolors
|
|
2738
|
-
if (entry.compressedSize) log$1 += import_picocolors
|
|
2739
|
-
if (entry.mapSize) log$1 += import_picocolors
|
|
2733
|
+
const sizeColor = isLarge ? import_picocolors.default.yellow : import_picocolors.default.dim;
|
|
2734
|
+
let log$1 = import_picocolors.default.dim(withTrailingSlash(relativeOutDir));
|
|
2735
|
+
log$1 += !config.build.lib && entry.name.startsWith(withTrailingSlash(assetsDir)) ? import_picocolors.default.dim(assetsDir) + group.color(entry.name.slice(assetsDir.length).padEnd(longest + 2 - assetsDir.length)) : group.color(entry.name.padEnd(longest + 2));
|
|
2736
|
+
log$1 += import_picocolors.default.bold(sizeColor(displaySize(entry.size).padStart(sizePad)));
|
|
2737
|
+
if (entry.compressedSize) log$1 += import_picocolors.default.dim(` │ gzip: ${displaySize(entry.compressedSize).padStart(compressPad)}`);
|
|
2738
|
+
if (entry.mapSize) log$1 += import_picocolors.default.dim(` │ map: ${displaySize(entry.mapSize).padStart(mapPad)}`);
|
|
2740
2739
|
config.logger.info(log$1);
|
|
2741
2740
|
}
|
|
2742
2741
|
}
|
|
2743
2742
|
} else hasLargeChunks = Object.values(output).some((chunk) => {
|
|
2744
2743
|
return chunk.type === "chunk" && chunk.code.length / 1e3 > chunkLimit;
|
|
2745
2744
|
});
|
|
2746
|
-
if (hasLargeChunks && environment.config.build.minify && !config.build.lib && environment.config.consumer === "client") environment.logger.warn(import_picocolors
|
|
2745
|
+
if (hasLargeChunks && environment.config.build.minify && !config.build.lib && environment.config.consumer === "client") environment.logger.warn(import_picocolors.default.yellow(`\n(!) Some chunks are larger than ${chunkLimit} kB after minification. Consider:\n- Using dynamic import() to code-split the application\n- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks\n- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.`));
|
|
2747
2746
|
}
|
|
2748
2747
|
};
|
|
2749
2748
|
});
|
|
@@ -2770,7 +2769,7 @@ function buildReporterPlugin(config) {
|
|
|
2770
2769
|
const module$1 = this.getModuleInfo(id);
|
|
2771
2770
|
if (!module$1) continue;
|
|
2772
2771
|
if (module$1.importers.length && module$1.dynamicImporters.length) {
|
|
2773
|
-
if (module$1.dynamicImporters.some((id$1) => !isInNodeModules(id$1) && chunk.moduleIds.includes(id$1))) this.warn(`\n(!) ${module$1.id} is dynamically imported by ${module$1.dynamicImporters.join(", ")} but also statically imported by ${module$1.importers.join(", ")}, dynamic import will not move module into another chunk.\n`);
|
|
2772
|
+
if (module$1.dynamicImporters.some((id$1) => !isInNodeModules$1(id$1) && chunk.moduleIds.includes(id$1))) this.warn(`\n(!) ${module$1.id} is dynamically imported by ${module$1.dynamicImporters.join(", ")} but also statically imported by ${module$1.importers.join(", ")}, dynamic import will not move module into another chunk.\n`);
|
|
2774
2773
|
}
|
|
2775
2774
|
}
|
|
2776
2775
|
chunksReporter(this).register();
|
|
@@ -2859,7 +2858,7 @@ async function resolveTSConfigJson(filename, cache$1) {
|
|
|
2859
2858
|
* @param {string} dir an absolute directory path
|
|
2860
2859
|
* @returns {boolean} if dir path includes a node_modules segment
|
|
2861
2860
|
*/
|
|
2862
|
-
const isInNodeModules
|
|
2861
|
+
const isInNodeModules = IS_POSIX ? (dir) => dir.includes("/node_modules/") : (dir) => dir.match(/[/\\]node_modules[/\\]/);
|
|
2863
2862
|
/**
|
|
2864
2863
|
* convert posix separator to native separator
|
|
2865
2864
|
*
|
|
@@ -3037,7 +3036,7 @@ function replaceTokens(result) {
|
|
|
3037
3036
|
*/
|
|
3038
3037
|
async function find(filename, options) {
|
|
3039
3038
|
let dir = path.dirname(path.resolve(filename));
|
|
3040
|
-
if (options?.ignoreNodeModules && isInNodeModules
|
|
3039
|
+
if (options?.ignoreNodeModules && isInNodeModules(dir)) return null;
|
|
3041
3040
|
const cache$1 = options?.cache;
|
|
3042
3041
|
const configName = options?.configName ?? "tsconfig.json";
|
|
3043
3042
|
if (cache$1?.hasConfigPath(dir, configName)) return cache$1.getConfigPath(dir, configName);
|
|
@@ -3618,7 +3617,6 @@ var TSConfckCache = class {
|
|
|
3618
3617
|
|
|
3619
3618
|
//#endregion
|
|
3620
3619
|
//#region src/node/plugins/esbuild.ts
|
|
3621
|
-
var import_picocolors$33 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
3622
3620
|
const debug$14 = createDebugger("vite:esbuild");
|
|
3623
3621
|
const IIFE_BEGIN_RE$1 = /(?:const|var)\s+\S+\s*=\s*\(?function\([^()]*\)\s*\{\s*"use strict";/;
|
|
3624
3622
|
const validExtensionRE$1 = /\.\w+$/;
|
|
@@ -3635,7 +3633,7 @@ let warnedTransformWithEsbuild = false;
|
|
|
3635
3633
|
const warnTransformWithEsbuildUsageOnce = () => {
|
|
3636
3634
|
if (warnedTransformWithEsbuild) return;
|
|
3637
3635
|
warnedTransformWithEsbuild = true;
|
|
3638
|
-
console.warn(import_picocolors
|
|
3636
|
+
console.warn(import_picocolors.default.yellow("`transformWithEsbuild` is deprecated and will be removed in the future. Please migrate to `transformWithOxc`."));
|
|
3639
3637
|
};
|
|
3640
3638
|
async function transformWithEsbuild(code, filename, options, inMap, config, watcher, ignoreEsbuildWarning = false) {
|
|
3641
3639
|
let loader = options?.loader;
|
|
@@ -3815,7 +3813,7 @@ function resolveEsbuildTranspileOptions(config, format$1) {
|
|
|
3815
3813
|
};
|
|
3816
3814
|
}
|
|
3817
3815
|
function prettifyMessage(m, code) {
|
|
3818
|
-
let res = import_picocolors
|
|
3816
|
+
let res = import_picocolors.default.yellow(m.text);
|
|
3819
3817
|
if (m.location) res += `\n` + generateCodeFrame(code, m.location);
|
|
3820
3818
|
return res + `\n`;
|
|
3821
3819
|
}
|
|
@@ -4254,11 +4252,11 @@ const ENC_CARET_RE = /%5e/gi;
|
|
|
4254
4252
|
const ENC_BACKTICK_RE = /%60/gi;
|
|
4255
4253
|
const ENC_PIPE_RE = /%7c/gi;
|
|
4256
4254
|
const ENC_SPACE_RE = /%20/gi;
|
|
4257
|
-
function encode
|
|
4255
|
+
function encode(text) {
|
|
4258
4256
|
return encodeURI("" + text).replace(ENC_PIPE_RE, "|");
|
|
4259
4257
|
}
|
|
4260
4258
|
function encodeQueryValue(input) {
|
|
4261
|
-
return encode
|
|
4259
|
+
return encode(typeof input === "string" ? input : JSON.stringify(input)).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CARET_RE, "^").replace(SLASH_RE, "%2F");
|
|
4262
4260
|
}
|
|
4263
4261
|
function encodeQueryKey(text) {
|
|
4264
4262
|
return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
|
|
@@ -4646,7 +4644,7 @@ function hasESMSyntax(code, opts = {}) {
|
|
|
4646
4644
|
}
|
|
4647
4645
|
|
|
4648
4646
|
//#endregion
|
|
4649
|
-
//#region ../../node_modules/.pnpm/@rolldown+pluginutils@1.0.0-beta.
|
|
4647
|
+
//#region ../../node_modules/.pnpm/@rolldown+pluginutils@1.0.0-beta.56/node_modules/@rolldown/pluginutils/dist/simple-filters.js
|
|
4650
4648
|
/**
|
|
4651
4649
|
* Constructs a RegExp that matches the exact string specified.
|
|
4652
4650
|
*
|
|
@@ -4668,7 +4666,7 @@ function hasESMSyntax(code, opts = {}) {
|
|
|
4668
4666
|
* ```
|
|
4669
4667
|
*/
|
|
4670
4668
|
function exactRegex(str, flags) {
|
|
4671
|
-
return new RegExp(`^${escapeRegex
|
|
4669
|
+
return new RegExp(`^${escapeRegex(str)}$`, flags);
|
|
4672
4670
|
}
|
|
4673
4671
|
/**
|
|
4674
4672
|
* Constructs a RegExp that matches a value that has the specified prefix.
|
|
@@ -4691,10 +4689,10 @@ function exactRegex(str, flags) {
|
|
|
4691
4689
|
* ```
|
|
4692
4690
|
*/
|
|
4693
4691
|
function prefixRegex(str, flags) {
|
|
4694
|
-
return new RegExp(`^${escapeRegex
|
|
4692
|
+
return new RegExp(`^${escapeRegex(str)}`, flags);
|
|
4695
4693
|
}
|
|
4696
4694
|
const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
|
|
4697
|
-
function escapeRegex
|
|
4695
|
+
function escapeRegex(str) {
|
|
4698
4696
|
return str.replace(escapeRegexRE, "\\$&");
|
|
4699
4697
|
}
|
|
4700
4698
|
function makeIdFiltersToMatchWithQuery(input) {
|
|
@@ -4716,8 +4714,8 @@ var ImportType;
|
|
|
4716
4714
|
A$1[A$1.Static = 1] = "Static", A$1[A$1.Dynamic = 2] = "Dynamic", A$1[A$1.ImportMeta = 3] = "ImportMeta", A$1[A$1.StaticSourcePhase = 4] = "StaticSourcePhase", A$1[A$1.DynamicSourcePhase = 5] = "DynamicSourcePhase", A$1[A$1.StaticDeferPhase = 6] = "StaticDeferPhase", A$1[A$1.DynamicDeferPhase = 7] = "DynamicDeferPhase";
|
|
4717
4715
|
})(ImportType || (ImportType = {}));
|
|
4718
4716
|
const A = 1 === new Uint8Array(new Uint16Array([1]).buffer)[0];
|
|
4719
|
-
function parse$
|
|
4720
|
-
if (!C) return init.then((() => parse$
|
|
4717
|
+
function parse$3(E$1, g = "@") {
|
|
4718
|
+
if (!C) return init.then((() => parse$3(E$1)));
|
|
4721
4719
|
const I = E$1.length + 1, w = (C.__heap_base.value || C.__heap_base) + 4 * I - C.memory.buffer.byteLength;
|
|
4722
4720
|
w > 0 && C.memory.grow(Math.ceil(w / 65536));
|
|
4723
4721
|
const K = C.sa(I - 1);
|
|
@@ -4784,7 +4782,6 @@ const init = WebAssembly.compile(E()).then(WebAssembly.instantiate).then((({ exp
|
|
|
4784
4782
|
|
|
4785
4783
|
//#endregion
|
|
4786
4784
|
//#region src/node/plugins/oxc.ts
|
|
4787
|
-
var import_picocolors$32 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
4788
4785
|
const IIFE_BEGIN_RE = /(?:(?:const|var)\s+\S+\s*=\s*|^|\n)\(?function\([^()]*\)\s*\{(?:\s*"use strict";)?/;
|
|
4789
4786
|
const UMD_BEGIN_RE = /\}\)\((?:this,\s*)?function\([^()]*\)\s*\{(?:\s*"use strict";)?/;
|
|
4790
4787
|
const jsxExtensionsRE = /\.(?:j|t)sx\b/;
|
|
@@ -4955,8 +4952,8 @@ function oxcPlugin(config) {
|
|
|
4955
4952
|
});
|
|
4956
4953
|
});
|
|
4957
4954
|
const { jsxInject, include, exclude, jsxRefreshInclude, jsxRefreshExclude, ...oxcTransformOptions } = config.oxc;
|
|
4958
|
-
const filter$1 = createFilter(include || /\.(m?ts|[jt]sx)$/, exclude || /\.js$/);
|
|
4959
|
-
const jsxRefreshFilter = jsxRefreshInclude || jsxRefreshExclude ? createFilter(jsxRefreshInclude, jsxRefreshExclude) : void 0;
|
|
4955
|
+
const filter$1 = createFilter$1(include || /\.(m?ts|[jt]sx)$/, exclude || /\.js$/);
|
|
4956
|
+
const jsxRefreshFilter = jsxRefreshInclude || jsxRefreshExclude ? createFilter$1(jsxRefreshInclude, jsxRefreshExclude) : void 0;
|
|
4960
4957
|
const jsxImportSource = typeof oxcTransformOptions.jsx === "object" && oxcTransformOptions.jsx.importSource || "react";
|
|
4961
4958
|
const jsxImportRuntime = `${jsxImportSource}/jsx-runtime`;
|
|
4962
4959
|
const jsxImportDevRuntime = `${jsxImportSource}/jsx-dev-runtime`;
|
|
@@ -5137,7 +5134,7 @@ function convertEsbuildConfigToOxcConfig(esbuildConfig, logger) {
|
|
|
5137
5134
|
return oxcOptions;
|
|
5138
5135
|
}
|
|
5139
5136
|
function warnDeprecatedShouldBeConvertedToPluginOptions(logger, name) {
|
|
5140
|
-
logger.warn(import_picocolors
|
|
5137
|
+
logger.warn(import_picocolors.default.yellow(`\`esbuild.${name}\` option was specified. But this option is deprecated and will be removed in future versions. This option can be achieved by using a plugin with transform hook, please use that instead.`));
|
|
5141
5138
|
}
|
|
5142
5139
|
|
|
5143
5140
|
//#endregion
|
|
@@ -5294,7 +5291,7 @@ var SourceMap = class {
|
|
|
5294
5291
|
this.sources = properties.sources;
|
|
5295
5292
|
this.sourcesContent = properties.sourcesContent;
|
|
5296
5293
|
this.names = properties.names;
|
|
5297
|
-
this.mappings = encode(properties.mappings);
|
|
5294
|
+
this.mappings = encode$1(properties.mappings);
|
|
5298
5295
|
if (typeof properties.x_google_ignoreList !== "undefined") this.x_google_ignoreList = properties.x_google_ignoreList;
|
|
5299
5296
|
if (typeof properties.debugId !== "undefined") this.debugId = properties.debugId;
|
|
5300
5297
|
}
|
|
@@ -5332,7 +5329,7 @@ function getRelativePath(from, to) {
|
|
|
5332
5329
|
return fromParts.concat(toParts).join("/");
|
|
5333
5330
|
}
|
|
5334
5331
|
const toString = Object.prototype.toString;
|
|
5335
|
-
function isObject
|
|
5332
|
+
function isObject(thing) {
|
|
5336
5333
|
return toString.call(thing) === "[object Object]";
|
|
5337
5334
|
}
|
|
5338
5335
|
function getLocator(source) {
|
|
@@ -5621,7 +5618,7 @@ var MagicString = class MagicString {
|
|
|
5621
5618
|
}
|
|
5622
5619
|
indent(indentStr, options) {
|
|
5623
5620
|
const pattern = /^[^\r\n]/gm;
|
|
5624
|
-
if (isObject
|
|
5621
|
+
if (isObject(indentStr)) {
|
|
5625
5622
|
options = indentStr;
|
|
5626
5623
|
indentStr = void 0;
|
|
5627
5624
|
}
|
|
@@ -6112,7 +6109,7 @@ function resolveCustomResolver(customResolver) {
|
|
|
6112
6109
|
if (customResolver) return getHookFunction(customResolver.resolveId);
|
|
6113
6110
|
return null;
|
|
6114
6111
|
}
|
|
6115
|
-
function alias(options = {}) {
|
|
6112
|
+
function alias$1(options = {}) {
|
|
6116
6113
|
const entries = getEntries(options);
|
|
6117
6114
|
if (entries.length === 0) return {
|
|
6118
6115
|
name: "alias",
|
|
@@ -6619,7 +6616,6 @@ function checkPublicFile(url$4, config) {
|
|
|
6619
6616
|
|
|
6620
6617
|
//#endregion
|
|
6621
6618
|
//#region src/node/plugins/asset.ts
|
|
6622
|
-
var import_picocolors$31 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
6623
6619
|
const assetUrlRE = /__VITE_ASSET__([\w$]+)__(?:\$_(.*?)__)?/g;
|
|
6624
6620
|
const jsSourceMapRE = /\.[cm]?js\.map$/;
|
|
6625
6621
|
const noInlineRE = /[?&]no-inline\b/;
|
|
@@ -6673,27 +6669,27 @@ function assetPlugin(config) {
|
|
|
6673
6669
|
},
|
|
6674
6670
|
resolveId: {
|
|
6675
6671
|
filter: { id: [
|
|
6676
|
-
urlRE,
|
|
6672
|
+
urlRE$1,
|
|
6677
6673
|
DEFAULT_ASSETS_RE,
|
|
6678
6674
|
...makeIdFiltersToMatchWithQuery(config.rawAssetsInclude).map((v) => typeof v === "string" ? picomatch.makeRe(v, { dot: true }) : v)
|
|
6679
6675
|
] },
|
|
6680
6676
|
handler(id) {
|
|
6681
|
-
if (!config.assetsInclude(cleanUrl(id)) && !urlRE.test(id)) return;
|
|
6677
|
+
if (!config.assetsInclude(cleanUrl(id)) && !urlRE$1.test(id)) return;
|
|
6682
6678
|
if (checkPublicFile(id, config)) return id;
|
|
6683
6679
|
}
|
|
6684
6680
|
},
|
|
6685
6681
|
load: {
|
|
6686
6682
|
filter: { id: {
|
|
6687
6683
|
include: [
|
|
6688
|
-
rawRE,
|
|
6689
|
-
urlRE,
|
|
6684
|
+
rawRE$1,
|
|
6685
|
+
urlRE$1,
|
|
6690
6686
|
DEFAULT_ASSETS_RE,
|
|
6691
6687
|
...makeIdFiltersToMatchWithQuery(config.rawAssetsInclude)
|
|
6692
6688
|
],
|
|
6693
6689
|
exclude: /^\0/
|
|
6694
6690
|
} },
|
|
6695
6691
|
async handler(id) {
|
|
6696
|
-
if (rawRE.test(id)) {
|
|
6692
|
+
if (rawRE$1.test(id)) {
|
|
6697
6693
|
const file = checkPublicFile(id, config) || cleanUrl(id);
|
|
6698
6694
|
this.addWatchFile(file);
|
|
6699
6695
|
return {
|
|
@@ -6701,9 +6697,9 @@ function assetPlugin(config) {
|
|
|
6701
6697
|
moduleType: "js"
|
|
6702
6698
|
};
|
|
6703
6699
|
}
|
|
6704
|
-
if (!urlRE.test(id) && !config.assetsInclude(cleanUrl(id))) return;
|
|
6700
|
+
if (!urlRE$1.test(id) && !config.assetsInclude(cleanUrl(id))) return;
|
|
6705
6701
|
id = removeUrlQuery(id);
|
|
6706
|
-
let url$4 = await fileToUrl(this, id);
|
|
6702
|
+
let url$4 = await fileToUrl$1(this, id);
|
|
6707
6703
|
if (!url$4.startsWith("data:") && this.environment.mode === "dev") {
|
|
6708
6704
|
const mod = this.environment.moduleGraph.getModuleById(id);
|
|
6709
6705
|
if (mod && mod.lastHMRTimestamp > 0) url$4 = injectQuery(url$4, `t=${mod.lastHMRTimestamp}`);
|
|
@@ -6751,7 +6747,7 @@ function assetPlugin(config) {
|
|
|
6751
6747
|
}
|
|
6752
6748
|
};
|
|
6753
6749
|
}
|
|
6754
|
-
async function fileToUrl(pluginContext, id) {
|
|
6750
|
+
async function fileToUrl$1(pluginContext, id) {
|
|
6755
6751
|
const { environment } = pluginContext;
|
|
6756
6752
|
if (!environment.config.isBundled) return fileToDevUrl(environment, id);
|
|
6757
6753
|
else return fileToBuiltUrl(pluginContext, id);
|
|
@@ -6825,7 +6821,7 @@ async function fileToBuiltUrl(pluginContext, id, skipPublicCheck = false, forceI
|
|
|
6825
6821
|
source: content
|
|
6826
6822
|
});
|
|
6827
6823
|
if (environment.config.command === "build" && noInlineRE.test(postfix)) postfix = postfix.replace(noInlineRE, "").replace(/^&/, "?");
|
|
6828
|
-
if (environment.config.experimental.bundledDev) {
|
|
6824
|
+
if (environment.config.command === "serve" && environment.config.experimental.bundledDev) {
|
|
6829
6825
|
const outputUrl = toOutputFilePathInJS(environment, pluginContext.getFileName(referenceId), "asset", "assets/dummy.js", "js", () => {
|
|
6830
6826
|
throw new Error("unreachable");
|
|
6831
6827
|
});
|
|
@@ -6861,7 +6857,7 @@ function shouldInline(environment, file, id, content, buildPluginContext, forceI
|
|
|
6861
6857
|
return content.length < limit && !isGitLfsPlaceholder(content);
|
|
6862
6858
|
}
|
|
6863
6859
|
function assetToDataURL(environment, file, content) {
|
|
6864
|
-
if (environment.config.build.lib && isGitLfsPlaceholder(content)) environment.logger.warn(import_picocolors
|
|
6860
|
+
if (environment.config.build.lib && isGitLfsPlaceholder(content)) environment.logger.warn(import_picocolors.default.yellow(`Inlined file ${file} was not downloaded via Git LFS`));
|
|
6865
6861
|
if (file.endsWith(".svg")) return svgToDataURL(content);
|
|
6866
6862
|
else return `data:${lookup(file) ?? "application/octet-stream"};base64,${content.toString("base64")}`;
|
|
6867
6863
|
}
|
|
@@ -6961,7 +6957,6 @@ function extractJsonErrorPosition(errorMessage, inputLength) {
|
|
|
6961
6957
|
|
|
6962
6958
|
//#endregion
|
|
6963
6959
|
//#region src/node/plugins/optimizedDeps.ts
|
|
6964
|
-
var import_picocolors$30 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
6965
6960
|
const debug$13 = createDebugger("vite:optimize-deps");
|
|
6966
6961
|
function optimizedDepsPlugin() {
|
|
6967
6962
|
return {
|
|
@@ -6993,7 +6988,7 @@ function optimizedDepsPlugin() {
|
|
|
6993
6988
|
if (info.browserHash !== currentInfo?.browserHash) throwOutdatedRequest(id);
|
|
6994
6989
|
}
|
|
6995
6990
|
}
|
|
6996
|
-
debug$13?.(`load ${import_picocolors
|
|
6991
|
+
debug$13?.(`load ${import_picocolors.default.cyan(file)}`);
|
|
6997
6992
|
try {
|
|
6998
6993
|
return await fsp.readFile(file, "utf-8");
|
|
6999
6994
|
} catch {
|
|
@@ -7464,7 +7459,6 @@ function resolveEnvPrefix({ envPrefix = "VITE_" }) {
|
|
|
7464
7459
|
|
|
7465
7460
|
//#endregion
|
|
7466
7461
|
//#region src/node/deprecations.ts
|
|
7467
|
-
var import_picocolors$29 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
7468
7462
|
const docsURL = "https://vite.dev";
|
|
7469
7463
|
const deprecationCode = {
|
|
7470
7464
|
removePluginHookSsrArgument: "changes/this-environment-in-hooks",
|
|
@@ -7499,16 +7493,16 @@ function warnFutureDeprecation(config, type, extraMessage, stacktrace = true) {
|
|
|
7499
7493
|
if (_ignoreDeprecationWarnings || !config.future || config.future[type] !== "warn") return;
|
|
7500
7494
|
let msg = `[vite future] ${deprecationMessages[type]}`;
|
|
7501
7495
|
if (extraMessage) msg += ` ${extraMessage}`;
|
|
7502
|
-
msg = import_picocolors
|
|
7496
|
+
msg = import_picocolors.default.yellow(msg);
|
|
7503
7497
|
const docs = `${docsURL}/changes/${deprecationCode[type].toLowerCase()}`;
|
|
7504
|
-
msg += import_picocolors
|
|
7498
|
+
msg += import_picocolors.default.gray(`\n ${stacktrace ? "├" : "└"}─── `) + import_picocolors.default.underline(docs) + "\n";
|
|
7505
7499
|
if (stacktrace) {
|
|
7506
7500
|
const stack = (/* @__PURE__ */ new Error()).stack;
|
|
7507
7501
|
if (stack) {
|
|
7508
7502
|
let stacks = stack.split("\n").slice(3).filter((i) => !i.includes("/node_modules/vite/dist/"));
|
|
7509
7503
|
if (stacks.length === 0) stacks.push("No stack trace found.");
|
|
7510
7504
|
stacks = stacks.map((i, idx) => ` ${idx === stacks.length - 1 ? "└" : "│"} ${i.trim()}`);
|
|
7511
|
-
msg += import_picocolors
|
|
7505
|
+
msg += import_picocolors.default.dim(stacks.join("\n")) + "\n";
|
|
7512
7506
|
}
|
|
7513
7507
|
}
|
|
7514
7508
|
config.logger.warnOnce(msg);
|
|
@@ -7523,7 +7517,6 @@ function ignoreDeprecationWarnings(fn) {
|
|
|
7523
7517
|
|
|
7524
7518
|
//#endregion
|
|
7525
7519
|
//#region src/node/server/middlewares/error.ts
|
|
7526
|
-
var import_picocolors$28 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
7527
7520
|
function prepareError(err$2) {
|
|
7528
7521
|
return {
|
|
7529
7522
|
message: stripVTControlCharacters(err$2.message),
|
|
@@ -7536,10 +7529,10 @@ function prepareError(err$2) {
|
|
|
7536
7529
|
};
|
|
7537
7530
|
}
|
|
7538
7531
|
function buildErrorMessage(err$2, args = [], includeStack = true) {
|
|
7539
|
-
if (err$2.plugin) args.push(` Plugin: ${import_picocolors
|
|
7532
|
+
if (err$2.plugin) args.push(` Plugin: ${import_picocolors.default.magenta(err$2.plugin)}`);
|
|
7540
7533
|
const loc = err$2.loc ? `:${err$2.loc.line}:${err$2.loc.column}` : "";
|
|
7541
|
-
if (err$2.id) args.push(` File: ${import_picocolors
|
|
7542
|
-
if (err$2.frame) args.push(import_picocolors
|
|
7534
|
+
if (err$2.id) args.push(` File: ${import_picocolors.default.cyan(err$2.id)}${loc}`);
|
|
7535
|
+
if (err$2.frame) args.push(import_picocolors.default.yellow(pad(err$2.frame)));
|
|
7543
7536
|
if (includeStack && err$2.stack) args.push(pad(cleanStack(err$2.stack)));
|
|
7544
7537
|
return args.join("\n");
|
|
7545
7538
|
}
|
|
@@ -7547,7 +7540,7 @@ function cleanStack(stack) {
|
|
|
7547
7540
|
return stack.split(/\n/).filter((l) => /^\s*at/.test(l)).join("\n");
|
|
7548
7541
|
}
|
|
7549
7542
|
function logError(server, err$2) {
|
|
7550
|
-
const msg = buildErrorMessage(err$2, [import_picocolors
|
|
7543
|
+
const msg = buildErrorMessage(err$2, [import_picocolors.default.red(`Internal server error: ${err$2.message}`)]);
|
|
7551
7544
|
server.config.logger.error(msg, {
|
|
7552
7545
|
clear: true,
|
|
7553
7546
|
timestamp: true,
|
|
@@ -12944,7 +12937,6 @@ var require_launch_editor_middleware = /* @__PURE__ */ __commonJSMin(((exports,
|
|
|
12944
12937
|
|
|
12945
12938
|
//#endregion
|
|
12946
12939
|
//#region src/node/http.ts
|
|
12947
|
-
var import_picocolors$27 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
12948
12940
|
async function resolveHttpServer(app, httpsOptions) {
|
|
12949
12941
|
if (!httpsOptions) {
|
|
12950
12942
|
const { createServer: createServer$3 } = await import("node:http");
|
|
@@ -13007,7 +12999,7 @@ function setClientErrorHandler(server, logger) {
|
|
|
13007
12999
|
let msg = "400 Bad Request";
|
|
13008
13000
|
if (err$2.code === "HPE_HEADER_OVERFLOW") {
|
|
13009
13001
|
msg = "431 Request Header Fields Too Large";
|
|
13010
|
-
logger.warn(import_picocolors
|
|
13002
|
+
logger.warn(import_picocolors.default.yellow("Server responded with status code 431. See https://vite.dev/guide/troubleshooting.html#_431-request-header-fields-too-large."));
|
|
13011
13003
|
}
|
|
13012
13004
|
if (err$2.code === "ECONNRESET" || !socket.writable) return;
|
|
13013
13005
|
socket.end(`HTTP/1.1 ${msg}\r\n\r\n`);
|
|
@@ -13028,22 +13020,33 @@ function calculateOffsetOnce() {
|
|
|
13028
13020
|
}
|
|
13029
13021
|
function ssrRewriteStacktrace(stack, moduleGraph) {
|
|
13030
13022
|
calculateOffsetOnce();
|
|
13031
|
-
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
|
|
13035
|
-
|
|
13036
|
-
|
|
13037
|
-
|
|
13038
|
-
|
|
13023
|
+
let alreadyRewritten = false;
|
|
13024
|
+
return {
|
|
13025
|
+
result: stack.split("\n").map((line) => {
|
|
13026
|
+
return line.replace(/^ {4}at (?:(\S.*?)\s\()?(.+?):(\d+)(?::(\d+))?\)?/, (input, varName, id, originalLine, originalColumn) => {
|
|
13027
|
+
if (!id) return input;
|
|
13028
|
+
const rawSourceMap = moduleGraph.getModuleById(id)?.transformResult?.map;
|
|
13029
|
+
if (!rawSourceMap) return input;
|
|
13030
|
+
const traced = new TraceMap(rawSourceMap);
|
|
13031
|
+
const line$1 = Number(originalLine) - offset;
|
|
13032
|
+
const column = Number(originalColumn) - 1;
|
|
13033
|
+
if (line$1 <= 0 || column < 0) {
|
|
13034
|
+
alreadyRewritten = true;
|
|
13035
|
+
return input;
|
|
13036
|
+
}
|
|
13037
|
+
const pos = originalPositionFor$1(traced, {
|
|
13038
|
+
line: line$1,
|
|
13039
|
+
column
|
|
13040
|
+
});
|
|
13041
|
+
if (!pos.source) return input;
|
|
13042
|
+
const trimmedVarName = varName?.trim();
|
|
13043
|
+
const source = `${path.resolve(path.dirname(id), pos.source)}:${pos.line}:${pos.column + 1}`;
|
|
13044
|
+
if (!trimmedVarName || trimmedVarName === "eval") return ` at ${source}`;
|
|
13045
|
+
else return ` at ${trimmedVarName} (${source})`;
|
|
13039
13046
|
});
|
|
13040
|
-
|
|
13041
|
-
|
|
13042
|
-
|
|
13043
|
-
if (!trimmedVarName || trimmedVarName === "eval") return ` at ${source}`;
|
|
13044
|
-
else return ` at ${trimmedVarName} (${source})`;
|
|
13045
|
-
});
|
|
13046
|
-
}).join("\n");
|
|
13047
|
+
}).join("\n"),
|
|
13048
|
+
alreadyRewritten
|
|
13049
|
+
};
|
|
13047
13050
|
}
|
|
13048
13051
|
function rebindErrorStacktrace(e$1, stacktrace) {
|
|
13049
13052
|
const { configurable, writable } = Object.getOwnPropertyDescriptor(e$1, "stack");
|
|
@@ -13059,7 +13062,9 @@ const rewroteStacktraces = /* @__PURE__ */ new WeakSet();
|
|
|
13059
13062
|
function ssrFixStacktrace(e$1, moduleGraph) {
|
|
13060
13063
|
if (!e$1.stack) return;
|
|
13061
13064
|
if (rewroteStacktraces.has(e$1)) return;
|
|
13062
|
-
|
|
13065
|
+
const { result: stacktrace, alreadyRewritten } = ssrRewriteStacktrace(e$1.stack, moduleGraph);
|
|
13066
|
+
rebindErrorStacktrace(e$1, stacktrace);
|
|
13067
|
+
if (alreadyRewritten) e$1.message += " (The stacktrace appears to be already rewritten by something else, but was passed to vite.ssrFixStacktrace. This may cause incorrect stacktraces.)";
|
|
13063
13068
|
rewroteStacktraces.add(e$1);
|
|
13064
13069
|
}
|
|
13065
13070
|
|
|
@@ -13125,7 +13130,6 @@ function createServerModuleRunner(environment, options = {}) {
|
|
|
13125
13130
|
|
|
13126
13131
|
//#endregion
|
|
13127
13132
|
//#region src/node/ssr/ssrModuleLoader.ts
|
|
13128
|
-
var import_picocolors$26 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
13129
13133
|
async function ssrLoadModule(url$4, server, fixStacktrace) {
|
|
13130
13134
|
const environment = server.environments.ssr;
|
|
13131
13135
|
server._ssrCompatModuleRunner ||= new SSRCompatModuleRunner(environment);
|
|
@@ -13139,7 +13143,7 @@ async function instantiateModule(url$4, runner, environment, fixStacktrace) {
|
|
|
13139
13143
|
return await runner.import(url$4);
|
|
13140
13144
|
} catch (e$1) {
|
|
13141
13145
|
if (e$1.stack && fixStacktrace) ssrFixStacktrace(e$1, environment.moduleGraph);
|
|
13142
|
-
environment.logger.error(buildErrorMessage(e$1, [import_picocolors
|
|
13146
|
+
environment.logger.error(buildErrorMessage(e$1, [import_picocolors.default.red(`Error when evaluating SSR module ${url$4}: ${e$1.message}`)]), {
|
|
13143
13147
|
timestamp: true,
|
|
13144
13148
|
clear: environment.config.clearScreen,
|
|
13145
13149
|
error: e$1
|
|
@@ -13396,7 +13400,7 @@ function isNode(value$1) {
|
|
|
13396
13400
|
* }} walker
|
|
13397
13401
|
* @returns {Node | null}
|
|
13398
13402
|
*/
|
|
13399
|
-
function walk(ast, { enter, leave }) {
|
|
13403
|
+
function walk$1(ast, { enter, leave }) {
|
|
13400
13404
|
return new SyncWalker(enter, leave).visit(ast, null);
|
|
13401
13405
|
}
|
|
13402
13406
|
|
|
@@ -13532,7 +13536,7 @@ async function ssrTransformScript(code, inMap, url$4, originalCode) {
|
|
|
13532
13536
|
else s.appendLeft(node.end, `${ssrExportAllKey}(${importId});\n`);
|
|
13533
13537
|
}
|
|
13534
13538
|
}
|
|
13535
|
-
walk
|
|
13539
|
+
walk(ast, {
|
|
13536
13540
|
onStatements(statements) {
|
|
13537
13541
|
for (let i = 0; i < statements.length - 1; i++) {
|
|
13538
13542
|
const stmt = statements[i];
|
|
@@ -13591,7 +13595,7 @@ const isNodeInPattern = (node) => isNodeInPatternWeakSet.has(node);
|
|
|
13591
13595
|
* Same logic from \@vue/compiler-core & \@vue/compiler-sfc
|
|
13592
13596
|
* Except this is using acorn AST
|
|
13593
13597
|
*/
|
|
13594
|
-
function walk
|
|
13598
|
+
function walk(root, { onIdentifier, onImportMeta, onDynamicImport, onStatements }) {
|
|
13595
13599
|
const parentStack = [];
|
|
13596
13600
|
const varKindStack = [];
|
|
13597
13601
|
const scopeMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -13621,7 +13625,7 @@ function walk$1(root, { onIdentifier, onImportMeta, onDynamicImport, onStatement
|
|
|
13621
13625
|
else if (p.type === "AssignmentPattern") handlePattern(p.left, parentScope);
|
|
13622
13626
|
else setScope(parentScope, p.name);
|
|
13623
13627
|
}
|
|
13624
|
-
walk(root, {
|
|
13628
|
+
walk$1(root, {
|
|
13625
13629
|
enter(node, parent) {
|
|
13626
13630
|
if (node.type === "ImportDeclaration") return this.skip();
|
|
13627
13631
|
if (node.type === "Program" || node.type === "BlockStatement" || node.type === "StaticBlock") onStatements(node.body);
|
|
@@ -13643,7 +13647,7 @@ function walk$1(root, { onIdentifier, onImportMeta, onDynamicImport, onStatement
|
|
|
13643
13647
|
handlePattern(p, node);
|
|
13644
13648
|
return;
|
|
13645
13649
|
}
|
|
13646
|
-
walk(p.type === "AssignmentPattern" ? p.left : p, { enter(child, parent$1) {
|
|
13650
|
+
walk$1(p.type === "AssignmentPattern" ? p.left : p, { enter(child, parent$1) {
|
|
13647
13651
|
if (parent$1?.type === "AssignmentPattern" && parent$1.right === child) return this.skip();
|
|
13648
13652
|
if (child.type !== "Identifier") return;
|
|
13649
13653
|
if (isStaticPropertyKey(child, parent$1)) return;
|
|
@@ -14552,7 +14556,6 @@ var require_cross_spawn = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
14552
14556
|
*
|
|
14553
14557
|
*/
|
|
14554
14558
|
var import_cross_spawn = /* @__PURE__ */ __toESM(require_cross_spawn(), 1);
|
|
14555
|
-
var import_picocolors$25 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
14556
14559
|
/**
|
|
14557
14560
|
* Reads the BROWSER environment variable and decides what to do with it.
|
|
14558
14561
|
*/
|
|
@@ -14568,7 +14571,7 @@ function executeNodeScript(scriptPath, url$4, logger) {
|
|
|
14568
14571
|
...extraArgs,
|
|
14569
14572
|
url$4
|
|
14570
14573
|
], { stdio: "inherit" }).on("close", (code) => {
|
|
14571
|
-
if (code !== 0) logger.error(import_picocolors
|
|
14574
|
+
if (code !== 0) logger.error(import_picocolors.default.red(`\nThe script specified as BROWSER environment variable failed.\n\n${import_picocolors.default.cyan(scriptPath)} exited with code ${code}.`), { error: null });
|
|
14572
14575
|
});
|
|
14573
14576
|
}
|
|
14574
14577
|
const supportedChromiumBrowsers = [
|
|
@@ -14620,7 +14623,6 @@ function execAsync(command, options) {
|
|
|
14620
14623
|
|
|
14621
14624
|
//#endregion
|
|
14622
14625
|
//#region src/node/shortcuts.ts
|
|
14623
|
-
var import_picocolors$24 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
14624
14626
|
function bindCLIShortcuts(server, opts, enabled = process.stdin.isTTY && !process.env.CI) {
|
|
14625
14627
|
if (!server.httpServer || !enabled) return;
|
|
14626
14628
|
const isDev = isDevServer(server);
|
|
@@ -14632,7 +14634,7 @@ function bindCLIShortcuts(server, opts, enabled = process.stdin.isTTY && !proces
|
|
|
14632
14634
|
...opts,
|
|
14633
14635
|
customShortcuts
|
|
14634
14636
|
};
|
|
14635
|
-
if (opts?.print) server.config.logger.info(import_picocolors
|
|
14637
|
+
if (opts?.print) server.config.logger.info(import_picocolors.default.dim(import_picocolors.default.green(" ➜")) + import_picocolors.default.dim(" press ") + import_picocolors.default.bold("h + enter") + import_picocolors.default.dim(" to show help"));
|
|
14636
14638
|
const shortcuts = customShortcuts.concat(isDev ? BASE_DEV_SHORTCUTS : BASE_PREVIEW_SHORTCUTS);
|
|
14637
14639
|
let actionRunning = false;
|
|
14638
14640
|
const onInput = async (input) => {
|
|
@@ -14644,7 +14646,7 @@ function bindCLIShortcuts(server, opts, enabled = process.stdin.isTTY && !proces
|
|
|
14644
14646
|
if (loggedKeys.has(shortcut$1.key)) continue;
|
|
14645
14647
|
loggedKeys.add(shortcut$1.key);
|
|
14646
14648
|
if (shortcut$1.action == null) continue;
|
|
14647
|
-
server.config.logger.info(import_picocolors
|
|
14649
|
+
server.config.logger.info(import_picocolors.default.dim(" press ") + import_picocolors.default.bold(`${shortcut$1.key} + enter`) + import_picocolors.default.dim(` to ${shortcut$1.description}`));
|
|
14648
14650
|
}
|
|
14649
14651
|
return;
|
|
14650
14652
|
}
|
|
@@ -14732,7 +14734,6 @@ const BASE_PREVIEW_SHORTCUTS = [{
|
|
|
14732
14734
|
|
|
14733
14735
|
//#endregion
|
|
14734
14736
|
//#region src/node/watch.ts
|
|
14735
|
-
var import_picocolors$23 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
14736
14737
|
function getResolvedOutDirs(root, outDir, outputOptions) {
|
|
14737
14738
|
const resolvedOutDir = path.resolve(root, outDir);
|
|
14738
14739
|
if (!outputOptions) return new Set([resolvedOutDir]);
|
|
@@ -14741,7 +14742,7 @@ function getResolvedOutDirs(root, outDir, outputOptions) {
|
|
|
14741
14742
|
function resolveEmptyOutDir(emptyOutDir, root, outDirs, logger) {
|
|
14742
14743
|
if (emptyOutDir != null) return emptyOutDir;
|
|
14743
14744
|
for (const outDir of outDirs) if (!normalizePath(outDir).startsWith(withTrailingSlash(root))) {
|
|
14744
|
-
logger?.warn(import_picocolors
|
|
14745
|
+
logger?.warn(import_picocolors.default.yellow(`\n${import_picocolors.default.bold(`(!)`)} outDir ${import_picocolors.default.white(import_picocolors.default.dim(outDir))} is not inside project root and will not be emptied.\nUse --emptyOutDir to override.\n`));
|
|
14745
14746
|
return false;
|
|
14746
14747
|
}
|
|
14747
14748
|
return true;
|
|
@@ -18392,7 +18393,6 @@ function generateDefaultErrorMessage(hostname) {
|
|
|
18392
18393
|
|
|
18393
18394
|
//#endregion
|
|
18394
18395
|
//#region src/node/server/ws.ts
|
|
18395
|
-
var import_picocolors$22 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
18396
18396
|
const WebSocketServerRaw = process.versions.bun ? import.meta.require("ws").WebSocketServer : import_websocket_server.default;
|
|
18397
18397
|
const HMR_HEADER = "vite-hmr";
|
|
18398
18398
|
const isWebSocketServer = Symbol("isWebSocketServer");
|
|
@@ -18431,7 +18431,7 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
|
18431
18431
|
send: noop$1
|
|
18432
18432
|
};
|
|
18433
18433
|
let wsHttpServer = void 0;
|
|
18434
|
-
const hmr = isObject(config.server.hmr) && config.server.hmr;
|
|
18434
|
+
const hmr = isObject$1(config.server.hmr) && config.server.hmr;
|
|
18435
18435
|
const hmrServer = hmr && hmr.server;
|
|
18436
18436
|
const hmrPort = hmr && hmr.port;
|
|
18437
18437
|
const wsServer = hmrServer || (!hmrPort || hmrPort === config.server.port) && server;
|
|
@@ -18491,8 +18491,8 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
|
18491
18491
|
handleUpgrade(req$1, socket, head, protocol === "vite-ping");
|
|
18492
18492
|
});
|
|
18493
18493
|
wsHttpServer.on("error", (e$1) => {
|
|
18494
|
-
if (e$1.code === "EADDRINUSE") config.logger.error(import_picocolors
|
|
18495
|
-
else config.logger.error(import_picocolors
|
|
18494
|
+
if (e$1.code === "EADDRINUSE") config.logger.error(import_picocolors.default.red(`WebSocket server error: Port ${e$1.port} is already in use`), { error: e$1 });
|
|
18495
|
+
else config.logger.error(import_picocolors.default.red(`WebSocket server error:\n${e$1.stack || e$1.message}`), { error: e$1 });
|
|
18496
18496
|
});
|
|
18497
18497
|
}
|
|
18498
18498
|
const emitCustomEvent = (event, data, socket) => {
|
|
@@ -18512,7 +18512,7 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
|
18512
18512
|
emitCustomEvent(parsed.event, parsed.data, socket);
|
|
18513
18513
|
});
|
|
18514
18514
|
socket.on("error", (err$2) => {
|
|
18515
|
-
config.logger.error(`${import_picocolors
|
|
18515
|
+
config.logger.error(`${import_picocolors.default.red(`ws error:`)}\n${err$2.stack}`, {
|
|
18516
18516
|
timestamp: true,
|
|
18517
18517
|
error: err$2
|
|
18518
18518
|
});
|
|
@@ -18528,8 +18528,8 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
|
18528
18528
|
}
|
|
18529
18529
|
});
|
|
18530
18530
|
wss.on("error", (e$1) => {
|
|
18531
|
-
if (e$1.code === "EADDRINUSE") config.logger.error(import_picocolors
|
|
18532
|
-
else config.logger.error(import_picocolors
|
|
18531
|
+
if (e$1.code === "EADDRINUSE") config.logger.error(import_picocolors.default.red(`WebSocket server error: Port ${e$1.port} is already in use`), { error: e$1 });
|
|
18532
|
+
else config.logger.error(import_picocolors.default.red(`WebSocket server error:\n${e$1.stack || e$1.message}`), { error: e$1 });
|
|
18533
18533
|
});
|
|
18534
18534
|
function getSocketClient(socket) {
|
|
18535
18535
|
if (!clientsMap.has(socket)) clientsMap.set(socket, {
|
|
@@ -20069,14 +20069,13 @@ var require_lib = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
20069
20069
|
|
|
20070
20070
|
//#endregion
|
|
20071
20071
|
//#region src/node/server/middlewares/proxy.ts
|
|
20072
|
-
var import_lib$
|
|
20073
|
-
var import_picocolors$21 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
20072
|
+
var import_lib$1 = /* @__PURE__ */ __toESM(require_lib(), 1);
|
|
20074
20073
|
const debug$11 = createDebugger("vite:proxy");
|
|
20075
20074
|
const rewriteOriginHeader = (proxyReq, options, config) => {
|
|
20076
20075
|
if (options.rewriteWsOrigin) {
|
|
20077
20076
|
const { target } = options;
|
|
20078
20077
|
if (proxyReq.headersSent) {
|
|
20079
|
-
config.logger.warn(import_picocolors
|
|
20078
|
+
config.logger.warn(import_picocolors.default.yellow(`Unable to rewrite Origin header as headers are already sent.`));
|
|
20080
20079
|
return;
|
|
20081
20080
|
}
|
|
20082
20081
|
if (proxyReq.getHeader("origin") && target) {
|
|
@@ -20094,17 +20093,17 @@ function proxyMiddleware(httpServer, options, config) {
|
|
|
20094
20093
|
target: opts,
|
|
20095
20094
|
changeOrigin: true
|
|
20096
20095
|
};
|
|
20097
|
-
const proxy = import_lib$
|
|
20096
|
+
const proxy = import_lib$1.createProxyServer(opts);
|
|
20098
20097
|
if (opts.configure) opts.configure(proxy, opts);
|
|
20099
20098
|
proxy.on("error", (err$2, _req, res) => {
|
|
20100
20099
|
if ("req" in res) {
|
|
20101
|
-
config.logger.error(`${import_picocolors
|
|
20100
|
+
config.logger.error(`${import_picocolors.default.red(`http proxy error: ${res.req.url}`)}\n${err$2.stack}`, {
|
|
20102
20101
|
timestamp: true,
|
|
20103
20102
|
error: err$2
|
|
20104
20103
|
});
|
|
20105
20104
|
if (!res.headersSent && !res.writableEnded) res.writeHead(500, { "Content-Type": "text/plain" }).end();
|
|
20106
20105
|
} else {
|
|
20107
|
-
config.logger.error(`${import_picocolors
|
|
20106
|
+
config.logger.error(`${import_picocolors.default.red(`ws proxy error:`)}\n${err$2.stack}`, {
|
|
20108
20107
|
timestamp: true,
|
|
20109
20108
|
error: err$2
|
|
20110
20109
|
});
|
|
@@ -20114,7 +20113,7 @@ function proxyMiddleware(httpServer, options, config) {
|
|
|
20114
20113
|
proxy.on("proxyReqWs", (proxyReq, _req, socket, options$1) => {
|
|
20115
20114
|
rewriteOriginHeader(proxyReq, options$1, config);
|
|
20116
20115
|
socket.on("error", (err$2) => {
|
|
20117
|
-
config.logger.error(`${import_picocolors
|
|
20116
|
+
config.logger.error(`${import_picocolors.default.red(`ws proxy socket error:`)}\n${err$2.stack}`, {
|
|
20118
20117
|
timestamp: true,
|
|
20119
20118
|
error: err$2
|
|
20120
20119
|
});
|
|
@@ -20140,7 +20139,7 @@ function proxyMiddleware(httpServer, options, config) {
|
|
|
20140
20139
|
return;
|
|
20141
20140
|
}
|
|
20142
20141
|
} catch (err$2) {
|
|
20143
|
-
config.logger.error(`${import_picocolors
|
|
20142
|
+
config.logger.error(`${import_picocolors.default.red(`ws proxy bypass error:`)}\n${err$2.stack}`, {
|
|
20144
20143
|
timestamp: true,
|
|
20145
20144
|
error: err$2
|
|
20146
20145
|
});
|
|
@@ -21545,7 +21544,7 @@ var require_convert_source_map = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
21545
21544
|
|
|
21546
21545
|
//#endregion
|
|
21547
21546
|
//#region src/node/server/sourcemap.ts
|
|
21548
|
-
var import_convert_source_map
|
|
21547
|
+
var import_convert_source_map = /* @__PURE__ */ __toESM(require_convert_source_map(), 1);
|
|
21549
21548
|
const debug$10 = createDebugger("vite:sourcemap", { onlyWhenFocused: true });
|
|
21550
21549
|
const virtualSourceRE = /^(?:dep:|browser-external:|virtual:)|\0/;
|
|
21551
21550
|
async function computeSourceRoute(map$1, file) {
|
|
@@ -21607,9 +21606,9 @@ function applySourcemapIgnoreList(map$1, sourcemapPath, sourcemapIgnoreList, log
|
|
|
21607
21606
|
}
|
|
21608
21607
|
}
|
|
21609
21608
|
async function extractSourcemapFromFile(code, filePath) {
|
|
21610
|
-
const map$1 = (import_convert_source_map
|
|
21609
|
+
const map$1 = (import_convert_source_map.fromSource(code) || await import_convert_source_map.fromMapFileSource(code, createConvertSourceMapReadMap(filePath)))?.toObject();
|
|
21611
21610
|
if (map$1) return {
|
|
21612
|
-
code: code.replace(import_convert_source_map
|
|
21611
|
+
code: code.replace(import_convert_source_map.default.mapFileCommentRegex, blankReplacer),
|
|
21613
21612
|
map: map$1
|
|
21614
21613
|
};
|
|
21615
21614
|
}
|
|
@@ -21645,7 +21644,7 @@ function createIdResolver(config, options) {
|
|
|
21645
21644
|
async function resolve$4(environment, id, importer) {
|
|
21646
21645
|
let pluginContainer = pluginContainerMap.get(environment);
|
|
21647
21646
|
if (!pluginContainer) {
|
|
21648
|
-
pluginContainer = await createEnvironmentPluginContainer(environment, [alias({ entries: environment.config.resolve.alias }), ...config.experimental.enableNativePlugin ? oxcResolvePlugin({
|
|
21647
|
+
pluginContainer = await createEnvironmentPluginContainer(environment, [alias$1({ entries: environment.config.resolve.alias }), ...config.experimental.enableNativePlugin ? oxcResolvePlugin({
|
|
21649
21648
|
root: config.root,
|
|
21650
21649
|
isProduction: config.isProduction,
|
|
21651
21650
|
isBuild: config.command === "build",
|
|
@@ -21672,7 +21671,7 @@ function createIdResolver(config, options) {
|
|
|
21672
21671
|
async function resolveAlias(environment, id, importer) {
|
|
21673
21672
|
let pluginContainer = aliasOnlyPluginContainerMap.get(environment);
|
|
21674
21673
|
if (!pluginContainer) {
|
|
21675
|
-
pluginContainer = await createEnvironmentPluginContainer(environment, [alias({ entries: environment.config.resolve.alias })], void 0, false);
|
|
21674
|
+
pluginContainer = await createEnvironmentPluginContainer(environment, [alias$1({ entries: environment.config.resolve.alias })], void 0, false);
|
|
21676
21675
|
aliasOnlyPluginContainerMap.set(environment, pluginContainer);
|
|
21677
21676
|
}
|
|
21678
21677
|
return await pluginContainer.resolveId(id, importer, { scan: scan$1 });
|
|
@@ -21684,12 +21683,11 @@ function createIdResolver(config, options) {
|
|
|
21684
21683
|
|
|
21685
21684
|
//#endregion
|
|
21686
21685
|
//#region src/node/baseEnvironment.ts
|
|
21687
|
-
var import_picocolors$20 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
21688
21686
|
const environmentColors = [
|
|
21689
|
-
import_picocolors
|
|
21690
|
-
import_picocolors
|
|
21691
|
-
import_picocolors
|
|
21692
|
-
import_picocolors
|
|
21687
|
+
import_picocolors.default.blue,
|
|
21688
|
+
import_picocolors.default.magenta,
|
|
21689
|
+
import_picocolors.default.green,
|
|
21690
|
+
import_picocolors.default.gray
|
|
21693
21691
|
];
|
|
21694
21692
|
var PartialEnvironment = class {
|
|
21695
21693
|
name;
|
|
@@ -21716,7 +21714,7 @@ var PartialEnvironment = class {
|
|
|
21716
21714
|
if (prop in target) return this._options[prop];
|
|
21717
21715
|
return this._topLevelConfig[prop];
|
|
21718
21716
|
} });
|
|
21719
|
-
const environment = import_picocolors
|
|
21717
|
+
const environment = import_picocolors.default.dim(`(${this.name})`);
|
|
21720
21718
|
const infoColor = environmentColors[[...this.name].reduce((acc, c) => acc + c.charCodeAt(0), 0) % environmentColors.length || 0];
|
|
21721
21719
|
this.logger = {
|
|
21722
21720
|
get hasWarned() {
|
|
@@ -21731,19 +21729,19 @@ var PartialEnvironment = class {
|
|
|
21731
21729
|
warn(msg, opts) {
|
|
21732
21730
|
return topLevelConfig.logger.warn(msg, {
|
|
21733
21731
|
...opts,
|
|
21734
|
-
environment: import_picocolors
|
|
21732
|
+
environment: import_picocolors.default.yellow(environment)
|
|
21735
21733
|
});
|
|
21736
21734
|
},
|
|
21737
21735
|
warnOnce(msg, opts) {
|
|
21738
21736
|
return topLevelConfig.logger.warnOnce(msg, {
|
|
21739
21737
|
...opts,
|
|
21740
|
-
environment: import_picocolors
|
|
21738
|
+
environment: import_picocolors.default.yellow(environment)
|
|
21741
21739
|
});
|
|
21742
21740
|
},
|
|
21743
21741
|
error(msg, opts) {
|
|
21744
21742
|
return topLevelConfig.logger.error(msg, {
|
|
21745
21743
|
...opts,
|
|
21746
|
-
environment: import_picocolors
|
|
21744
|
+
environment: import_picocolors.default.red(environment)
|
|
21747
21745
|
});
|
|
21748
21746
|
},
|
|
21749
21747
|
clearScreen(type) {
|
|
@@ -21983,7 +21981,6 @@ function getChunkOriginalFileName(chunk, root, isLegacy) {
|
|
|
21983
21981
|
//#endregion
|
|
21984
21982
|
//#region src/node/plugins/css.ts
|
|
21985
21983
|
var import_src = /* @__PURE__ */ __toESM(require_src(), 1);
|
|
21986
|
-
var import_picocolors$19 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
21987
21984
|
const decoder = new TextDecoder();
|
|
21988
21985
|
const _cssConfigDefaults = Object.freeze({
|
|
21989
21986
|
transformer: "postcss",
|
|
@@ -22062,7 +22059,7 @@ function cssPlugin(config) {
|
|
|
22062
22059
|
load: {
|
|
22063
22060
|
filter: { id: CSS_LANGS_RE },
|
|
22064
22061
|
async handler(id) {
|
|
22065
|
-
if (urlRE.test(id)) {
|
|
22062
|
+
if (urlRE$1.test(id)) {
|
|
22066
22063
|
if (isModuleCSSRequest(id)) throw new Error(`?url is not supported with CSS modules. (tried to import ${JSON.stringify(id)})`);
|
|
22067
22064
|
if (isBuild) {
|
|
22068
22065
|
id = injectQuery(removeUrlQuery(id), "transform-only");
|
|
@@ -22087,7 +22084,7 @@ function cssPlugin(config) {
|
|
|
22087
22084
|
let resolved = await resolveUrl(id$1, importer);
|
|
22088
22085
|
if (resolved) {
|
|
22089
22086
|
if (fragment) resolved += "#" + fragment;
|
|
22090
|
-
let url$5 = await fileToUrl(this, resolved);
|
|
22087
|
+
let url$5 = await fileToUrl$1(this, resolved);
|
|
22091
22088
|
if (!url$5.startsWith("data:") && this.environment.mode === "dev") {
|
|
22092
22089
|
const mod = [...this.environment.moduleGraph.getModulesByFile(resolved) ?? []].find((mod$1) => mod$1.type === "asset");
|
|
22093
22090
|
if (mod?.lastHMRTimestamp) url$5 = injectQuery(url$5, `t=${mod.lastHMRTimestamp}`);
|
|
@@ -22462,7 +22459,7 @@ function isCssScopeToRendered(cssScopeTo, renderedModules) {
|
|
|
22462
22459
|
* @param outputFormat The module output format to decide whether to replace `import` or `require`
|
|
22463
22460
|
*/
|
|
22464
22461
|
function getEmptyChunkReplacer(pureCssChunkNames, outputFormat) {
|
|
22465
|
-
const emptyChunkFiles = pureCssChunkNames.map((file) => escapeRegex(path.basename(file))).join("|");
|
|
22462
|
+
const emptyChunkFiles = pureCssChunkNames.map((file) => escapeRegex$1(path.basename(file))).join("|");
|
|
22466
22463
|
const emptyChunkRE = new RegExp(outputFormat === "es" ? `\\bimport\\s*["'][^"']*(?:${emptyChunkFiles})["'];` : `(\\b|,\\s*)require\\(\\s*["'\`][^"'\`]*(?:${emptyChunkFiles})["'\`]\\)(;|,)`, "g");
|
|
22467
22464
|
return (code) => code.replace(emptyChunkRE, (m, p1, p2) => {
|
|
22468
22465
|
if (outputFormat === "es") return `/* empty css ${"".padEnd(m.length - 15)}*/`;
|
|
@@ -22604,7 +22601,7 @@ async function compilePostCSS(environment, id, code, deps, lang, workerControlle
|
|
|
22604
22601
|
if (publicFile) return publicFile;
|
|
22605
22602
|
const resolved = await atImportResolvers.css(environment, id$1, path.join(basedir, "*"));
|
|
22606
22603
|
if (resolved) return path.resolve(resolved);
|
|
22607
|
-
if (!path.isAbsolute(id$1)) environment.logger.error(import_picocolors
|
|
22604
|
+
if (!path.isAbsolute(id$1)) environment.logger.error(import_picocolors.default.red(`Unable to resolve \`@import "${id$1}"\` from ${basedir}`));
|
|
22608
22605
|
return id$1;
|
|
22609
22606
|
},
|
|
22610
22607
|
async load(id$1) {
|
|
@@ -22692,7 +22689,7 @@ async function runPostCSS(id, code, plugins, options, deps, logger, enableSource
|
|
|
22692
22689
|
line: warning.endLine,
|
|
22693
22690
|
column: warning.endColumn - 1
|
|
22694
22691
|
} : void 0)}`;
|
|
22695
|
-
logger.warn(import_picocolors
|
|
22692
|
+
logger.warn(import_picocolors.default.yellow(msg));
|
|
22696
22693
|
}
|
|
22697
22694
|
} catch (e$1) {
|
|
22698
22695
|
e$1.message = `[postcss] ${e$1.message}`;
|
|
@@ -22773,7 +22770,7 @@ async function resolvePostcssConfig(config) {
|
|
|
22773
22770
|
let result = postcssConfigCache.get(config);
|
|
22774
22771
|
if (result !== void 0) return await result;
|
|
22775
22772
|
const inlineOptions = config.css.postcss;
|
|
22776
|
-
if (isObject(inlineOptions)) {
|
|
22773
|
+
if (isObject$1(inlineOptions)) {
|
|
22777
22774
|
const options = { ...inlineOptions };
|
|
22778
22775
|
delete options.plugins;
|
|
22779
22776
|
result = {
|
|
@@ -22906,7 +22903,7 @@ async function minifyCSS(css, config, inlined) {
|
|
|
22906
22903
|
});
|
|
22907
22904
|
if (warnings.length) {
|
|
22908
22905
|
const msgs = await formatMessages(warnings, { kind: "warning" });
|
|
22909
|
-
config.logger.warn(import_picocolors
|
|
22906
|
+
config.logger.warn(import_picocolors.default.yellow(`[esbuild css minify]\n${msgs.join("\n")}`));
|
|
22910
22907
|
}
|
|
22911
22908
|
return inlined ? code.trimEnd() : code;
|
|
22912
22909
|
} catch (e$1) {
|
|
@@ -22933,7 +22930,7 @@ async function minifyCSS(css, config, inlined) {
|
|
|
22933
22930
|
line: warning.loc.line,
|
|
22934
22931
|
column: warning.loc.column - 1
|
|
22935
22932
|
})}`;
|
|
22936
|
-
config.logger.warn(import_picocolors
|
|
22933
|
+
config.logger.warn(import_picocolors.default.yellow(msg));
|
|
22937
22934
|
}
|
|
22938
22935
|
return decoder.decode(code) + (inlined ? "" : "\n");
|
|
22939
22936
|
} catch (e$1) {
|
|
@@ -23227,6 +23224,7 @@ const makeLessWorker = (environment, resolvers, maxWorkers) => {
|
|
|
23227
23224
|
plugins: [viteResolverPlugin, ...options.plugins || []],
|
|
23228
23225
|
...options.enableSourcemap ? { sourceMap: {
|
|
23229
23226
|
outputSourceFiles: true,
|
|
23227
|
+
disableSourcemapAnnotation: true,
|
|
23230
23228
|
sourceMapFileInline: false
|
|
23231
23229
|
} } : {}
|
|
23232
23230
|
});
|
|
@@ -23495,7 +23493,7 @@ async function compileLightningCSS(environment, id, src, deps, workerController,
|
|
|
23495
23493
|
line: warning.loc.line,
|
|
23496
23494
|
column: warning.loc.column - 1
|
|
23497
23495
|
})}`;
|
|
23498
|
-
environment.logger.warn(import_picocolors
|
|
23496
|
+
environment.logger.warn(import_picocolors.default.yellow(msg));
|
|
23499
23497
|
}
|
|
23500
23498
|
let css = decoder.decode(res.code);
|
|
23501
23499
|
for (const dep of res.dependencies) switch (dep.type) {
|
|
@@ -23605,7 +23603,15 @@ const esMap = {
|
|
|
23605
23603
|
"chrome110",
|
|
23606
23604
|
"edge110",
|
|
23607
23605
|
"safari16.4",
|
|
23606
|
+
"firefox146",
|
|
23608
23607
|
"opera96"
|
|
23608
|
+
],
|
|
23609
|
+
2024: [
|
|
23610
|
+
"chrome119",
|
|
23611
|
+
"edge119",
|
|
23612
|
+
"safari17.4",
|
|
23613
|
+
"firefox145",
|
|
23614
|
+
"opera105"
|
|
23609
23615
|
]
|
|
23610
23616
|
};
|
|
23611
23617
|
const esRE = /es(\d{4})/;
|
|
@@ -23654,7 +23660,6 @@ function resolveLibCssFilename(libOptions, root, packageCache) {
|
|
|
23654
23660
|
|
|
23655
23661
|
//#endregion
|
|
23656
23662
|
//#region src/node/plugins/importAnalysisBuild.ts
|
|
23657
|
-
var import_convert_source_map$1 = /* @__PURE__ */ __toESM(require_convert_source_map(), 1);
|
|
23658
23663
|
/**
|
|
23659
23664
|
* A flag for injected helpers. This flag will be set to `false` if the output
|
|
23660
23665
|
* target is not native es - so that injected helper logic can be conditionally
|
|
@@ -23770,7 +23775,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
23770
23775
|
await init;
|
|
23771
23776
|
let imports = [];
|
|
23772
23777
|
try {
|
|
23773
|
-
imports = parse$
|
|
23778
|
+
imports = parse$3(source)[0];
|
|
23774
23779
|
} catch (_e) {
|
|
23775
23780
|
const e$1 = _e;
|
|
23776
23781
|
const { message, showCodeFrame } = createParseErrorInfo(importer, source);
|
|
@@ -23851,7 +23856,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
23851
23856
|
const code = chunk.code;
|
|
23852
23857
|
let imports;
|
|
23853
23858
|
try {
|
|
23854
|
-
imports = parse$
|
|
23859
|
+
imports = parse$3(code)[0].filter((i) => i.d > -1);
|
|
23855
23860
|
} catch (e$1) {
|
|
23856
23861
|
const loc = numberToPos(code, e$1.idx);
|
|
23857
23862
|
this.error({
|
|
@@ -23890,7 +23895,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
23890
23895
|
const code = chunk.code;
|
|
23891
23896
|
let imports;
|
|
23892
23897
|
try {
|
|
23893
|
-
imports = parse$
|
|
23898
|
+
imports = parse$3(code)[0].filter((i) => i.d > -1);
|
|
23894
23899
|
} catch (e$1) {
|
|
23895
23900
|
const loc = numberToPos(code, e$1.idx);
|
|
23896
23901
|
this.error({
|
|
@@ -24008,7 +24013,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
24008
24013
|
const originalDebugId = chunk.map.debugId;
|
|
24009
24014
|
chunk.map = map$1;
|
|
24010
24015
|
if (buildSourcemap === "inline") {
|
|
24011
|
-
chunk.code = chunk.code.replace(import_convert_source_map
|
|
24016
|
+
chunk.code = chunk.code.replace(import_convert_source_map.default.mapFileCommentRegex, "");
|
|
24012
24017
|
chunk.code += `\n//# sourceMappingURL=${genSourceMapUrl(map$1)}`;
|
|
24013
24018
|
} else {
|
|
24014
24019
|
if (originalDebugId) map$1.debugId = originalDebugId;
|
|
@@ -24100,8 +24105,7 @@ function polyfill() {
|
|
|
24100
24105
|
|
|
24101
24106
|
//#endregion
|
|
24102
24107
|
//#region src/node/plugins/html.ts
|
|
24103
|
-
var
|
|
24104
|
-
var import_escape_html$1 = /* @__PURE__ */ __toESM(require_escape_html(), 1);
|
|
24108
|
+
var import_escape_html = /* @__PURE__ */ __toESM(require_escape_html(), 1);
|
|
24105
24109
|
const htmlProxyRE = /[?&]html-proxy=?(?:&inline-css)?(?:&style-attr)?&index=(\d+)\.(?:js|css)$/;
|
|
24106
24110
|
const isHtmlProxyRE = /[?&]html-proxy\b/;
|
|
24107
24111
|
const inlineCSSRE = /__VITE_INLINE_CSS__([a-z\d]{8}_\d+)__/g;
|
|
@@ -24175,7 +24179,7 @@ async function traverseHtml(html, filePath, warn, visitor) {
|
|
|
24175
24179
|
handleParseError(e$1, html, filePath, warnings);
|
|
24176
24180
|
}
|
|
24177
24181
|
}), visitor);
|
|
24178
|
-
for (const message of Object.values(warnings)) warn(import_picocolors
|
|
24182
|
+
for (const message of Object.values(warnings)) warn(import_picocolors.default.yellow(`\n${message}`));
|
|
24179
24183
|
}
|
|
24180
24184
|
function getScriptInfo(node) {
|
|
24181
24185
|
let src;
|
|
@@ -24605,7 +24609,7 @@ function preImportMapHook(config) {
|
|
|
24605
24609
|
if (importMapAppendIndex < 0) return;
|
|
24606
24610
|
if (importMapAppendIndex < importMapIndex) {
|
|
24607
24611
|
const relativeHtml = normalizePath(path.relative(config.root, ctx.filename));
|
|
24608
|
-
config.logger.warnOnce(import_picocolors
|
|
24612
|
+
config.logger.warnOnce(import_picocolors.default.yellow(import_picocolors.default.bold(`(!) <script type="importmap"> should come before <script type="module"> and <link rel="modulepreload"> in /${relativeHtml}`)));
|
|
24609
24613
|
}
|
|
24610
24614
|
};
|
|
24611
24615
|
}
|
|
@@ -24660,7 +24664,7 @@ function htmlEnvHook(config) {
|
|
|
24660
24664
|
else {
|
|
24661
24665
|
if (envPrefix.some((prefix) => key.startsWith(prefix))) {
|
|
24662
24666
|
const relativeHtml = normalizePath(path.relative(config.root, ctx.filename));
|
|
24663
|
-
config.logger.warn(import_picocolors
|
|
24667
|
+
config.logger.warn(import_picocolors.default.yellow(import_picocolors.default.bold(`(!) ${text} is not defined in env variables found in /${relativeHtml}. Is the variable mistyped?`)));
|
|
24664
24668
|
}
|
|
24665
24669
|
return text;
|
|
24666
24670
|
}
|
|
@@ -24727,7 +24731,7 @@ function headTagInsertCheck(tags, ctx) {
|
|
|
24727
24731
|
const disallowedTags = tags.filter((tagDescriptor) => !elementsAllowedInHead.has(tagDescriptor.tag));
|
|
24728
24732
|
if (disallowedTags.length) {
|
|
24729
24733
|
const dedupedTags = unique(disallowedTags.map((tagDescriptor) => `<${tagDescriptor.tag}>`));
|
|
24730
|
-
logger?.warn(import_picocolors
|
|
24734
|
+
logger?.warn(import_picocolors.default.yellow(import_picocolors.default.bold(`[${dedupedTags.join(",")}] can not be used inside the <head> Element, please check the 'injectTo' value`)));
|
|
24731
24735
|
}
|
|
24732
24736
|
}
|
|
24733
24737
|
async function applyHtmlTransforms(html, hooks, pluginContext, ctx) {
|
|
@@ -24825,7 +24829,7 @@ function serializeTags(tags, indent = "") {
|
|
|
24825
24829
|
function serializeAttrs(attrs) {
|
|
24826
24830
|
let res = "";
|
|
24827
24831
|
for (const key in attrs) if (typeof attrs[key] === "boolean") res += attrs[key] ? ` ${key}` : ``;
|
|
24828
|
-
else res += ` ${key}="${(0, import_escape_html
|
|
24832
|
+
else res += ` ${key}="${(0, import_escape_html.default)(attrs[key])}"`;
|
|
24829
24833
|
return res;
|
|
24830
24834
|
}
|
|
24831
24835
|
function incrementIndent(indent = "") {
|
|
@@ -24895,7 +24899,7 @@ function definePlugin(config) {
|
|
|
24895
24899
|
if (Object.keys(importMetaKeys).length) patternKeys.push("import.meta.env", "import.meta.hot");
|
|
24896
24900
|
return [
|
|
24897
24901
|
define,
|
|
24898
|
-
patternKeys.length ? new RegExp(patternKeys.map((key) => escapeRegex(key).replaceAll(escapedDotRE, "\\??\\.")).join("|")) : null,
|
|
24902
|
+
patternKeys.length ? new RegExp(patternKeys.map((key) => escapeRegex$1(key).replaceAll(escapedDotRE, "\\??\\.")).join("|")) : null,
|
|
24899
24903
|
importMetaEnvVal
|
|
24900
24904
|
];
|
|
24901
24905
|
}
|
|
@@ -25044,7 +25048,7 @@ async function createClientConfigValueReplacer(config) {
|
|
|
25044
25048
|
const devBase = config.base;
|
|
25045
25049
|
const serverHost = `${resolvedServerHostname}:${resolvedServerPort}${devBase}`;
|
|
25046
25050
|
let hmrConfig = config.server.hmr;
|
|
25047
|
-
hmrConfig = isObject(hmrConfig) ? hmrConfig : void 0;
|
|
25051
|
+
hmrConfig = isObject$1(hmrConfig) ? hmrConfig : void 0;
|
|
25048
25052
|
const host = hmrConfig?.host || null;
|
|
25049
25053
|
const protocol = hmrConfig?.protocol || null;
|
|
25050
25054
|
const timeout = hmrConfig?.timeout || 3e4;
|
|
@@ -25157,7 +25161,6 @@ function inlineSourceMap(mod, result, startOffset) {
|
|
|
25157
25161
|
|
|
25158
25162
|
//#endregion
|
|
25159
25163
|
//#region src/node/optimizer/optimizer.ts
|
|
25160
|
-
var import_picocolors$17 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
25161
25164
|
const debug$9 = createDebugger("vite:deps");
|
|
25162
25165
|
/**
|
|
25163
25166
|
* The amount to wait for requests to register newly found dependencies before triggering
|
|
@@ -25188,14 +25191,14 @@ function createDepsOptimizer(environment) {
|
|
|
25188
25191
|
let newDepsToLogHandle;
|
|
25189
25192
|
const logNewlyDiscoveredDeps = () => {
|
|
25190
25193
|
if (newDepsToLog.length) {
|
|
25191
|
-
logger.info(import_picocolors
|
|
25194
|
+
logger.info(import_picocolors.default.green(`✨ new dependencies optimized: ${depsLogString(newDepsToLog)}`), { timestamp: true });
|
|
25192
25195
|
newDepsToLog = [];
|
|
25193
25196
|
}
|
|
25194
25197
|
};
|
|
25195
25198
|
let discoveredDepsWhileScanning = [];
|
|
25196
25199
|
const logDiscoveredDepsWhileScanning = () => {
|
|
25197
25200
|
if (discoveredDepsWhileScanning.length) {
|
|
25198
|
-
logger.info(import_picocolors
|
|
25201
|
+
logger.info(import_picocolors.default.green(`✨ discovered while scanning: ${depsLogString(discoveredDepsWhileScanning)}`), { timestamp: true });
|
|
25199
25202
|
discoveredDepsWhileScanning = [];
|
|
25200
25203
|
}
|
|
25201
25204
|
};
|
|
@@ -25245,14 +25248,14 @@ function createDepsOptimizer(environment) {
|
|
|
25245
25248
|
else depsOptimizer.scanProcessing = new Promise((resolve$4) => {
|
|
25246
25249
|
(async () => {
|
|
25247
25250
|
try {
|
|
25248
|
-
debug$9?.(import_picocolors
|
|
25251
|
+
debug$9?.(import_picocolors.default.green(`scanning for dependencies...`));
|
|
25249
25252
|
let deps;
|
|
25250
25253
|
try {
|
|
25251
25254
|
discover = discoverProjectDependencies(devToScanEnvironment(environment));
|
|
25252
25255
|
deps = await discover.result;
|
|
25253
25256
|
discover = void 0;
|
|
25254
25257
|
} catch (e$1) {
|
|
25255
|
-
environment.logger.error(import_picocolors
|
|
25258
|
+
environment.logger.error(import_picocolors.default.red("(!) Failed to run dependency scan. Skipping dependency pre-bundling. " + e$1.stack));
|
|
25256
25259
|
return;
|
|
25257
25260
|
}
|
|
25258
25261
|
const manuallyIncluded = Object.keys(manuallyIncludedDepsInfo);
|
|
@@ -25355,14 +25358,14 @@ function createDepsOptimizer(environment) {
|
|
|
25355
25358
|
logNewlyDiscoveredDeps();
|
|
25356
25359
|
if (warnAboutMissedDependencies) {
|
|
25357
25360
|
logDiscoveredDepsWhileScanning();
|
|
25358
|
-
logger.info(import_picocolors
|
|
25361
|
+
logger.info(import_picocolors.default.magenta(`❗ add these dependencies to optimizeDeps.include to speed up cold start`), { timestamp: true });
|
|
25359
25362
|
warnAboutMissedDependencies = false;
|
|
25360
25363
|
}
|
|
25361
25364
|
}, 2 * debounceMs);
|
|
25362
|
-
} else debug$9(import_picocolors
|
|
25365
|
+
} else debug$9(import_picocolors.default.green(`✨ ${!isRerun ? `dependencies optimized` : `optimized dependencies unchanged`}`));
|
|
25363
25366
|
} else if (newDepsDiscovered) {
|
|
25364
25367
|
processingResult.cancel();
|
|
25365
|
-
debug$9?.(import_picocolors
|
|
25368
|
+
debug$9?.(import_picocolors.default.green(`✨ delaying reload as new dependencies have been found...`));
|
|
25366
25369
|
} else {
|
|
25367
25370
|
await commitProcessing();
|
|
25368
25371
|
if (!debug$9) {
|
|
@@ -25371,16 +25374,16 @@ function createDepsOptimizer(environment) {
|
|
|
25371
25374
|
logNewlyDiscoveredDeps();
|
|
25372
25375
|
if (warnAboutMissedDependencies) {
|
|
25373
25376
|
logDiscoveredDepsWhileScanning();
|
|
25374
|
-
logger.info(import_picocolors
|
|
25377
|
+
logger.info(import_picocolors.default.magenta(`❗ add these dependencies to optimizeDeps.include to avoid a full page reload during cold start`), { timestamp: true });
|
|
25375
25378
|
warnAboutMissedDependencies = false;
|
|
25376
25379
|
}
|
|
25377
25380
|
}
|
|
25378
|
-
logger.info(import_picocolors
|
|
25379
|
-
if (needsInteropMismatch.length > 0) logger.warn(`Mixed ESM and CJS detected in ${import_picocolors
|
|
25381
|
+
logger.info(import_picocolors.default.green(`✨ optimized dependencies changed. reloading`), { timestamp: true });
|
|
25382
|
+
if (needsInteropMismatch.length > 0) logger.warn(`Mixed ESM and CJS detected in ${import_picocolors.default.yellow(needsInteropMismatch.join(", "))}, add ${needsInteropMismatch.length === 1 ? "it" : "them"} to optimizeDeps.needsInterop to speed up cold start`, { timestamp: true });
|
|
25380
25383
|
fullReload();
|
|
25381
25384
|
}
|
|
25382
25385
|
} catch (e$1) {
|
|
25383
|
-
logger.error(import_picocolors
|
|
25386
|
+
logger.error(import_picocolors.default.red(`error while updating dependencies:\n${e$1.stack}`), {
|
|
25384
25387
|
timestamp: true,
|
|
25385
25388
|
error: e$1
|
|
25386
25389
|
});
|
|
@@ -25399,7 +25402,7 @@ function createDepsOptimizer(environment) {
|
|
|
25399
25402
|
}
|
|
25400
25403
|
async function rerun() {
|
|
25401
25404
|
const depsString = depsLogString(Object.keys(metadata.discovered));
|
|
25402
|
-
debug$9?.(import_picocolors
|
|
25405
|
+
debug$9?.(import_picocolors.default.green(`new dependencies found: ${depsString}`));
|
|
25403
25406
|
runOptimizer();
|
|
25404
25407
|
}
|
|
25405
25408
|
function getDiscoveredBrowserHash(hash, deps, missing) {
|
|
@@ -25440,7 +25443,7 @@ function createDepsOptimizer(environment) {
|
|
|
25440
25443
|
}
|
|
25441
25444
|
async function onCrawlEnd() {
|
|
25442
25445
|
waitingForCrawlEnd = false;
|
|
25443
|
-
debug$9?.(import_picocolors
|
|
25446
|
+
debug$9?.(import_picocolors.default.green(`✨ static imports crawl ended`));
|
|
25444
25447
|
if (closed) return;
|
|
25445
25448
|
await depsOptimizer.scanProcessing;
|
|
25446
25449
|
if (optimizationResult && !options.noDiscovery) {
|
|
@@ -25451,7 +25454,7 @@ function createDepsOptimizer(environment) {
|
|
|
25451
25454
|
const crawlDeps = Object.keys(metadata.discovered);
|
|
25452
25455
|
const scanDeps = Object.keys(result.metadata.optimized);
|
|
25453
25456
|
if (scanDeps.length === 0 && crawlDeps.length === 0) {
|
|
25454
|
-
debug$9?.(import_picocolors
|
|
25457
|
+
debug$9?.(import_picocolors.default.green(`✨ no dependencies found by the scanner or crawling static imports`));
|
|
25455
25458
|
startNextDiscoveredBatch();
|
|
25456
25459
|
runOptimizer(result);
|
|
25457
25460
|
return;
|
|
@@ -25461,17 +25464,17 @@ function createDepsOptimizer(environment) {
|
|
|
25461
25464
|
if (needsInteropMismatch.length > 0 || scannerMissedDeps) {
|
|
25462
25465
|
result.cancel();
|
|
25463
25466
|
for (const dep of scanDeps) if (!crawlDeps.includes(dep)) addMissingDep(dep, result.metadata.optimized[dep].src);
|
|
25464
|
-
if (scannerMissedDeps) debug$9?.(import_picocolors
|
|
25465
|
-
debug$9?.(import_picocolors
|
|
25467
|
+
if (scannerMissedDeps) debug$9?.(import_picocolors.default.yellow(`✨ new dependencies were found while crawling that weren't detected by the scanner`));
|
|
25468
|
+
debug$9?.(import_picocolors.default.green(`✨ re-running optimizer`));
|
|
25466
25469
|
debouncedProcessing(0);
|
|
25467
25470
|
} else {
|
|
25468
|
-
debug$9?.(import_picocolors
|
|
25471
|
+
debug$9?.(import_picocolors.default.green(`✨ using post-scan optimizer result, the scanner found every used dependency`));
|
|
25469
25472
|
startNextDiscoveredBatch();
|
|
25470
25473
|
runOptimizer(result);
|
|
25471
25474
|
}
|
|
25472
25475
|
} else if (!holdUntilCrawlEnd) {
|
|
25473
25476
|
if (newDepsDiscovered) {
|
|
25474
|
-
debug$9?.(import_picocolors
|
|
25477
|
+
debug$9?.(import_picocolors.default.green(`✨ new dependencies were found while crawling static imports, re-running optimizer`));
|
|
25475
25478
|
warnAboutMissedDependencies = true;
|
|
25476
25479
|
debouncedProcessing(0);
|
|
25477
25480
|
}
|
|
@@ -25479,7 +25482,7 @@ function createDepsOptimizer(environment) {
|
|
|
25479
25482
|
const crawlDeps = Object.keys(metadata.discovered);
|
|
25480
25483
|
currentlyProcessing = false;
|
|
25481
25484
|
if (crawlDeps.length === 0) {
|
|
25482
|
-
debug$9?.(import_picocolors
|
|
25485
|
+
debug$9?.(import_picocolors.default.green(`✨ no dependencies found while crawling the static imports`));
|
|
25483
25486
|
firstRunCalled = true;
|
|
25484
25487
|
}
|
|
25485
25488
|
debouncedProcessing(0);
|
|
@@ -25518,7 +25521,7 @@ function findInteropMismatches(discovered, optimized) {
|
|
|
25518
25521
|
if (!depInfo) continue;
|
|
25519
25522
|
if (depInfo.needsInterop !== discoveredDepInfo.needsInterop) {
|
|
25520
25523
|
needsInteropMismatch.push(dep);
|
|
25521
|
-
debug$9?.(import_picocolors
|
|
25524
|
+
debug$9?.(import_picocolors.default.cyan(`✨ needsInterop mismatch detected for ${dep}`));
|
|
25522
25525
|
}
|
|
25523
25526
|
}
|
|
25524
25527
|
return needsInteropMismatch;
|
|
@@ -25847,7 +25850,7 @@ function totalist(dir, callback, pre = "") {
|
|
|
25847
25850
|
* @param {Request} req
|
|
25848
25851
|
* @returns {ParsedURL|void}
|
|
25849
25852
|
*/
|
|
25850
|
-
function parse$
|
|
25853
|
+
function parse$1(req$1) {
|
|
25851
25854
|
let raw = req$1.url;
|
|
25852
25855
|
if (raw == null) return;
|
|
25853
25856
|
let prev = req$1._parsedUrl;
|
|
@@ -25955,7 +25958,7 @@ function toHeaders(name, stats, isEtag) {
|
|
|
25955
25958
|
if (isEtag) headers["ETag"] = `W/"${stats.size}-${stats.mtime.getTime()}"`;
|
|
25956
25959
|
return headers;
|
|
25957
25960
|
}
|
|
25958
|
-
function build_default(dir, opts = {}) {
|
|
25961
|
+
function build_default$1(dir, opts = {}) {
|
|
25959
25962
|
dir = resolve(dir || ".");
|
|
25960
25963
|
let isNotFound = opts.onNoMatch || is404;
|
|
25961
25964
|
let setHeaders = opts.setHeaders || noop;
|
|
@@ -25995,7 +25998,7 @@ function build_default(dir, opts = {}) {
|
|
|
25995
25998
|
let lookup$1 = opts.dev ? viaLocal.bind(0, dir.endsWith(sep) ? dir : dir + sep, isEtag) : viaCache.bind(0, FILES);
|
|
25996
25999
|
return function(req$1, res, next) {
|
|
25997
26000
|
let extns = [""];
|
|
25998
|
-
let pathname = parse$
|
|
26001
|
+
let pathname = parse$1(req$1).pathname;
|
|
25999
26002
|
let val = req$1.headers["accept-encoding"] || "";
|
|
26000
26003
|
if (gzips && val.includes("gzip")) extns.unshift(...gzips);
|
|
26001
26004
|
if (brots && /(br|brotli)/i.test(val)) extns.unshift(...brots);
|
|
@@ -26017,7 +26020,6 @@ function build_default(dir, opts = {}) {
|
|
|
26017
26020
|
|
|
26018
26021
|
//#endregion
|
|
26019
26022
|
//#region src/node/server/middlewares/static.ts
|
|
26020
|
-
var import_escape_html = /* @__PURE__ */ __toESM(require_escape_html(), 1);
|
|
26021
26023
|
const knownJavascriptExtensionRE = /\.(?:[tj]sx?|[cm][tj]s)$/;
|
|
26022
26024
|
const ERR_DENIED_FILE = "ERR_DENIED_FILE";
|
|
26023
26025
|
const sirvOptions = ({ config, getHeaders, disableFsServeCheck }) => {
|
|
@@ -26045,7 +26047,7 @@ const sirvOptions = ({ config, getHeaders, disableFsServeCheck }) => {
|
|
|
26045
26047
|
};
|
|
26046
26048
|
function servePublicMiddleware(server, publicFiles) {
|
|
26047
26049
|
const dir = server.config.publicDir;
|
|
26048
|
-
const serve = build_default(dir, sirvOptions({
|
|
26050
|
+
const serve = build_default$1(dir, sirvOptions({
|
|
26049
26051
|
config: server.config,
|
|
26050
26052
|
getHeaders: () => server.config.server.headers,
|
|
26051
26053
|
disableFsServeCheck: true
|
|
@@ -26058,13 +26060,13 @@ function servePublicMiddleware(server, publicFiles) {
|
|
|
26058
26060
|
return normalizePath(filePath);
|
|
26059
26061
|
};
|
|
26060
26062
|
return function viteServePublicMiddleware(req$1, res, next) {
|
|
26061
|
-
if (publicFiles && !publicFiles.has(toFilePath(req$1.url)) || isImportRequest(req$1.url) || isInternalRequest(req$1.url) || urlRE.test(req$1.url)) return next();
|
|
26063
|
+
if (publicFiles && !publicFiles.has(toFilePath(req$1.url)) || isImportRequest(req$1.url) || isInternalRequest(req$1.url) || urlRE$1.test(req$1.url)) return next();
|
|
26062
26064
|
serve(req$1, res, next);
|
|
26063
26065
|
};
|
|
26064
26066
|
}
|
|
26065
26067
|
function serveStaticMiddleware(server) {
|
|
26066
26068
|
const dir = server.config.root;
|
|
26067
|
-
const serve = build_default(dir, sirvOptions({
|
|
26069
|
+
const serve = build_default$1(dir, sirvOptions({
|
|
26068
26070
|
config: server.config,
|
|
26069
26071
|
getHeaders: () => server.config.server.headers
|
|
26070
26072
|
}));
|
|
@@ -26101,7 +26103,7 @@ function serveStaticMiddleware(server) {
|
|
|
26101
26103
|
};
|
|
26102
26104
|
}
|
|
26103
26105
|
function serveRawFsMiddleware(server) {
|
|
26104
|
-
const serveFromRoot = build_default("/", sirvOptions({
|
|
26106
|
+
const serveFromRoot = build_default$1("/", sirvOptions({
|
|
26105
26107
|
config: server.config,
|
|
26106
26108
|
getHeaders: () => server.config.server.headers
|
|
26107
26109
|
}));
|
|
@@ -26186,8 +26188,7 @@ function renderRestrictedErrorHTML(msg) {
|
|
|
26186
26188
|
|
|
26187
26189
|
//#endregion
|
|
26188
26190
|
//#region src/node/server/transformRequest.ts
|
|
26189
|
-
var import_etag
|
|
26190
|
-
var import_picocolors$16 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
26191
|
+
var import_etag = /* @__PURE__ */ __toESM(require_etag(), 1);
|
|
26191
26192
|
const ERR_LOAD_URL = "ERR_LOAD_URL";
|
|
26192
26193
|
const ERR_LOAD_PUBLIC_URL = "ERR_LOAD_PUBLIC_URL";
|
|
26193
26194
|
const ERR_DENIED_ID = "ERR_DENIED_ID";
|
|
@@ -26291,7 +26292,7 @@ async function loadAndTransform(environment, id, url$4, options, timestamp, mod,
|
|
|
26291
26292
|
}
|
|
26292
26293
|
} else {
|
|
26293
26294
|
debugLoad?.(`${timeFrom(loadStart)} [plugin] ${prettyUrl}`);
|
|
26294
|
-
if (isObject(loadResult)) {
|
|
26295
|
+
if (isObject$1(loadResult)) {
|
|
26295
26296
|
code = loadResult.code;
|
|
26296
26297
|
map$1 = loadResult.map;
|
|
26297
26298
|
moduleType = loadResult.moduleType;
|
|
@@ -26320,7 +26321,7 @@ async function loadAndTransform(environment, id, url$4, options, timestamp, mod,
|
|
|
26320
26321
|
moduleType
|
|
26321
26322
|
});
|
|
26322
26323
|
const originalCode = code;
|
|
26323
|
-
if (transformResult.code === originalCode) debugTransform?.(timeFrom(transformStart) + import_picocolors
|
|
26324
|
+
if (transformResult.code === originalCode) debugTransform?.(timeFrom(transformStart) + import_picocolors.default.dim(` [skipped] ${prettyUrl}`));
|
|
26324
26325
|
else {
|
|
26325
26326
|
debugTransform?.(`${timeFrom(transformStart)} ${prettyUrl}`);
|
|
26326
26327
|
code = transformResult.code;
|
|
@@ -26352,7 +26353,7 @@ async function loadAndTransform(environment, id, url$4, options, timestamp, mod,
|
|
|
26352
26353
|
const result = environment.config.dev.moduleRunnerTransform ? await ssrTransform(code, normalizedMap, url$4, originalCode, { json: { stringify: topLevelConfig.json.stringify === true && topLevelConfig.json.namedExports !== true } }) : {
|
|
26353
26354
|
code,
|
|
26354
26355
|
map: normalizedMap,
|
|
26355
|
-
etag: (0, import_etag
|
|
26356
|
+
etag: (0, import_etag.default)(code, { weak: true })
|
|
26356
26357
|
};
|
|
26357
26358
|
if (timestamp > mod.lastInvalidationTimestamp) moduleGraph.updateModuleTransformResult(mod, result);
|
|
26358
26359
|
return result;
|
|
@@ -26375,7 +26376,7 @@ async function handleModuleSoftInvalidation(environment, mod, timestamp) {
|
|
|
26375
26376
|
await init;
|
|
26376
26377
|
const source = transformResult.code;
|
|
26377
26378
|
const s = new MagicString(source);
|
|
26378
|
-
const [imports] = parse$
|
|
26379
|
+
const [imports] = parse$3(source, mod.id || void 0);
|
|
26379
26380
|
for (const imp of imports) {
|
|
26380
26381
|
let rawUrl = source.slice(imp.s, imp.e);
|
|
26381
26382
|
if (rawUrl === "import.meta") continue;
|
|
@@ -26399,7 +26400,7 @@ async function handleModuleSoftInvalidation(environment, mod, timestamp) {
|
|
|
26399
26400
|
result = {
|
|
26400
26401
|
...transformResult,
|
|
26401
26402
|
code,
|
|
26402
|
-
etag: (0, import_etag
|
|
26403
|
+
etag: (0, import_etag.default)(code, { weak: true })
|
|
26403
26404
|
};
|
|
26404
26405
|
}
|
|
26405
26406
|
if (timestamp > mod.lastInvalidationTimestamp) environment.moduleGraph.updateModuleTransformResult(mod, result);
|
|
@@ -26428,7 +26429,6 @@ function getModuleTypeFromId(id) {
|
|
|
26428
26429
|
|
|
26429
26430
|
//#endregion
|
|
26430
26431
|
//#region src/node/server/warmup.ts
|
|
26431
|
-
var import_picocolors$15 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
26432
26432
|
function warmupFiles(server, environment) {
|
|
26433
26433
|
const { root } = server.config;
|
|
26434
26434
|
mapFiles(environment.config.dev.warmup, root).then((files) => {
|
|
@@ -26442,13 +26442,13 @@ async function warmupFile(server, environment, file) {
|
|
|
26442
26442
|
const html = await fsp.readFile(file, "utf-8");
|
|
26443
26443
|
await server.transformIndexHtml(url$4, html);
|
|
26444
26444
|
} catch (e$1) {
|
|
26445
|
-
environment.logger.error(`Pre-transform error (${import_picocolors
|
|
26445
|
+
environment.logger.error(`Pre-transform error (${import_picocolors.default.cyan(file)}): ${e$1.message}`, {
|
|
26446
26446
|
error: e$1,
|
|
26447
26447
|
timestamp: true
|
|
26448
26448
|
});
|
|
26449
26449
|
}
|
|
26450
26450
|
} else {
|
|
26451
|
-
const url$4 = fileToUrl
|
|
26451
|
+
const url$4 = fileToUrl(file, server.config.root);
|
|
26452
26452
|
await environment.warmupRequest(url$4);
|
|
26453
26453
|
}
|
|
26454
26454
|
}
|
|
@@ -26457,7 +26457,7 @@ function htmlFileToUrl(file, root) {
|
|
|
26457
26457
|
if (url$4[0] === ".") return;
|
|
26458
26458
|
return "/" + normalizePath(url$4);
|
|
26459
26459
|
}
|
|
26460
|
-
function fileToUrl
|
|
26460
|
+
function fileToUrl(file, root) {
|
|
26461
26461
|
const url$4 = path.relative(root, file);
|
|
26462
26462
|
if (url$4[0] === ".") return path.posix.join(FS_PREFIX, normalizePath(file));
|
|
26463
26463
|
return "/" + normalizePath(url$4);
|
|
@@ -26480,7 +26480,6 @@ async function mapFiles(files, root) {
|
|
|
26480
26480
|
|
|
26481
26481
|
//#endregion
|
|
26482
26482
|
//#region src/node/server/environment.ts
|
|
26483
|
-
var import_picocolors$14 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
26484
26483
|
var DevEnvironment = class extends BaseEnvironment {
|
|
26485
26484
|
mode = "dev";
|
|
26486
26485
|
moduleGraph;
|
|
@@ -26599,7 +26598,7 @@ var DevEnvironment = class extends BaseEnvironment {
|
|
|
26599
26598
|
const mod = this.moduleGraph.urlToModuleMap.get(m.path);
|
|
26600
26599
|
if (mod && mod.isSelfAccepting && mod.lastHMRTimestamp > 0 && !mod.lastHMRInvalidationReceived) {
|
|
26601
26600
|
mod.lastHMRInvalidationReceived = true;
|
|
26602
|
-
this.logger.info(import_picocolors
|
|
26601
|
+
this.logger.info(import_picocolors.default.yellow(`hmr invalidate `) + import_picocolors.default.dim(m.path) + (m.message ? ` ${m.message}` : ""), { timestamp: true });
|
|
26603
26602
|
const file = getShortName(mod.file, this.config.root);
|
|
26604
26603
|
updateModules(this, file, [...mod.importers].filter((imp) => imp !== mod), mod.lastHMRTimestamp, m.firstInvalidatedBy);
|
|
26605
26604
|
}
|
|
@@ -26680,8 +26679,6 @@ function setupOnCrawlEnd() {
|
|
|
26680
26679
|
|
|
26681
26680
|
//#endregion
|
|
26682
26681
|
//#region src/node/server/environments/fullBundleEnvironment.ts
|
|
26683
|
-
var import_picocolors$13 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
26684
|
-
var import_etag$1 = /* @__PURE__ */ __toESM(require_etag(), 1);
|
|
26685
26682
|
const debug$8 = createDebugger("vite:full-bundle-mode");
|
|
26686
26683
|
var MemoryFiles = class {
|
|
26687
26684
|
files = /* @__PURE__ */ new Map();
|
|
@@ -26717,7 +26714,7 @@ var FullBundleDevEnvironment = class extends DevEnvironment {
|
|
|
26717
26714
|
type: "full-reload",
|
|
26718
26715
|
path: "*"
|
|
26719
26716
|
});
|
|
26720
|
-
this.logger.info(import_picocolors
|
|
26717
|
+
this.logger.info(import_picocolors.default.green(`page reload`), { timestamp: true });
|
|
26721
26718
|
});
|
|
26722
26719
|
memoryFiles = new MemoryFiles();
|
|
26723
26720
|
constructor(name, config, context) {
|
|
@@ -26766,7 +26763,7 @@ var FullBundleDevEnvironment = class extends DevEnvironment {
|
|
|
26766
26763
|
},
|
|
26767
26764
|
onOutput: (result) => {
|
|
26768
26765
|
if (result instanceof Error) {
|
|
26769
|
-
this.logger.error(import_picocolors
|
|
26766
|
+
this.logger.error(import_picocolors.default.red(`✘ Build error: ${result.message}`), { error: result });
|
|
26770
26767
|
this.hot.send({
|
|
26771
26768
|
type: "error",
|
|
26772
26769
|
err: prepareError(result)
|
|
@@ -26777,7 +26774,7 @@ var FullBundleDevEnvironment = class extends DevEnvironment {
|
|
|
26777
26774
|
const source = outputFile.type === "chunk" ? outputFile.code : outputFile.source;
|
|
26778
26775
|
return {
|
|
26779
26776
|
source,
|
|
26780
|
-
etag: (0, import_etag
|
|
26777
|
+
etag: (0, import_etag.default)(Buffer.from(source), { weak: true })
|
|
26781
26778
|
};
|
|
26782
26779
|
});
|
|
26783
26780
|
},
|
|
@@ -26826,7 +26823,7 @@ var FullBundleDevEnvironment = class extends DevEnvironment {
|
|
|
26826
26823
|
return;
|
|
26827
26824
|
}
|
|
26828
26825
|
if (!update) return;
|
|
26829
|
-
if (update.type === "Patch") this.logger.info(import_picocolors
|
|
26826
|
+
if (update.type === "Patch") this.logger.info(import_picocolors.default.yellow(`hmr invalidate `) + import_picocolors.default.dim(m.path) + (m.message ? ` ${m.message}` : ""), { timestamp: true });
|
|
26830
26827
|
this.handleHmrOutput(client, [m.path], update, { firstInvalidatedBy: m.firstInvalidatedBy });
|
|
26831
26828
|
})();
|
|
26832
26829
|
}
|
|
@@ -26849,7 +26846,7 @@ var FullBundleDevEnvironment = class extends DevEnvironment {
|
|
|
26849
26846
|
const chunkMetadataMap = new ChunkMetadataMap();
|
|
26850
26847
|
const rolldownOptions = resolveRolldownOptions(this, chunkMetadataMap);
|
|
26851
26848
|
rolldownOptions.experimental ??= {};
|
|
26852
|
-
rolldownOptions.experimental.
|
|
26849
|
+
rolldownOptions.experimental.devMode = { implement: await getHmrImplementation(this.getTopLevelConfig()) };
|
|
26853
26850
|
if (rolldownOptions.optimization) rolldownOptions.optimization.inlineConst = false;
|
|
26854
26851
|
if (Array.isArray(rolldownOptions.output)) for (const output of rolldownOptions.output) {
|
|
26855
26852
|
output.entryFileNames = "assets/[name].js";
|
|
@@ -26872,8 +26869,8 @@ var FullBundleDevEnvironment = class extends DevEnvironment {
|
|
|
26872
26869
|
if (hmrOutput.type === "Noop") return;
|
|
26873
26870
|
const shortFile = files.map((file) => getShortName(file, this.config.root)).join(", ");
|
|
26874
26871
|
if (hmrOutput.type === "FullReload") {
|
|
26875
|
-
const reason = hmrOutput.reason ? import_picocolors
|
|
26876
|
-
this.logger.info(import_picocolors
|
|
26872
|
+
const reason = hmrOutput.reason ? import_picocolors.default.dim(` (${hmrOutput.reason})`) : "";
|
|
26873
|
+
this.logger.info(import_picocolors.default.green(`trigger page reload `) + import_picocolors.default.dim(shortFile) + reason, {
|
|
26877
26874
|
clear: !invalidateInformation,
|
|
26878
26875
|
timestamp: true
|
|
26879
26876
|
});
|
|
@@ -26902,7 +26899,7 @@ var FullBundleDevEnvironment = class extends DevEnvironment {
|
|
|
26902
26899
|
type: "update",
|
|
26903
26900
|
updates
|
|
26904
26901
|
});
|
|
26905
|
-
this.logger.info(import_picocolors
|
|
26902
|
+
this.logger.info(import_picocolors.default.green(`hmr update `) + import_picocolors.default.dim([...new Set(updates.map((u) => u.path))].join(", ")), {
|
|
26906
26903
|
clear: !invalidateInformation,
|
|
26907
26904
|
timestamp: true
|
|
26908
26905
|
});
|
|
@@ -26991,10 +26988,8 @@ function htmlFallbackMiddleware(root, spaFallback, clientEnvironment) {
|
|
|
26991
26988
|
|
|
26992
26989
|
//#endregion
|
|
26993
26990
|
//#region src/node/server/send.ts
|
|
26994
|
-
var import_convert_source_map = /* @__PURE__ */ __toESM(require_convert_source_map(), 1);
|
|
26995
|
-
var import_etag = /* @__PURE__ */ __toESM(require_etag(), 1);
|
|
26996
26991
|
const debug$6 = createDebugger("vite:send", { onlyWhenFocused: true });
|
|
26997
|
-
const alias
|
|
26992
|
+
const alias = {
|
|
26998
26993
|
js: "text/javascript",
|
|
26999
26994
|
css: "text/css",
|
|
27000
26995
|
html: "text/html",
|
|
@@ -27008,7 +27003,7 @@ function send(req$1, res, content, type, options) {
|
|
|
27008
27003
|
res.end();
|
|
27009
27004
|
return;
|
|
27010
27005
|
}
|
|
27011
|
-
res.setHeader("Content-Type", alias
|
|
27006
|
+
res.setHeader("Content-Type", alias[type] || type);
|
|
27012
27007
|
res.setHeader("Cache-Control", cacheControl);
|
|
27013
27008
|
res.setHeader("Etag", etag);
|
|
27014
27009
|
if (headers) for (const name in headers) res.setHeader(name, headers[name]);
|
|
@@ -27033,7 +27028,6 @@ function send(req$1, res, content, type, options) {
|
|
|
27033
27028
|
|
|
27034
27029
|
//#endregion
|
|
27035
27030
|
//#region src/node/server/middlewares/transform.ts
|
|
27036
|
-
var import_picocolors$12 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
27037
27031
|
const debugCache = createDebugger("vite:cache");
|
|
27038
27032
|
const knownIgnoreList = new Set(["/", "/favicon.ico"]);
|
|
27039
27033
|
const documentFetchDests = new Set([
|
|
@@ -27046,12 +27040,12 @@ function isDocumentFetchDest(req$1) {
|
|
|
27046
27040
|
const fetchDest = req$1.headers["sec-fetch-dest"];
|
|
27047
27041
|
return fetchDest !== void 0 && documentFetchDests.has(fetchDest);
|
|
27048
27042
|
}
|
|
27049
|
-
const urlRE
|
|
27050
|
-
const rawRE
|
|
27043
|
+
const urlRE = /[?&]url\b/;
|
|
27044
|
+
const rawRE = /[?&]raw\b/;
|
|
27051
27045
|
const inlineRE$1 = /[?&]inline\b/;
|
|
27052
27046
|
const svgRE = /\.svg\b/;
|
|
27053
27047
|
function isServerAccessDeniedForTransform(config, id) {
|
|
27054
|
-
if (rawRE
|
|
27048
|
+
if (rawRE.test(id) || urlRE.test(id) || inlineRE$1.test(id) || svgRE.test(id)) return checkLoadingAccess(config, id) !== "allowed";
|
|
27055
27049
|
return false;
|
|
27056
27050
|
}
|
|
27057
27051
|
/**
|
|
@@ -27090,7 +27084,7 @@ function transformMiddleware(server) {
|
|
|
27090
27084
|
url$4 = decodeURI(removeTimestampQuery(req$1.url)).replace(NULL_BYTE_PLACEHOLDER, "\0");
|
|
27091
27085
|
} catch (e$1) {
|
|
27092
27086
|
if (e$1 instanceof URIError) {
|
|
27093
|
-
server.config.logger.warn(import_picocolors
|
|
27087
|
+
server.config.logger.warn(import_picocolors.default.yellow(`Malformed URI sequence in request URL: ${removeTimestampQuery(req$1.url)}`));
|
|
27094
27088
|
return next();
|
|
27095
27089
|
}
|
|
27096
27090
|
return next(e$1);
|
|
@@ -27182,7 +27176,7 @@ function transformMiddleware(server) {
|
|
|
27182
27176
|
res.statusCode = 404;
|
|
27183
27177
|
res.end();
|
|
27184
27178
|
}
|
|
27185
|
-
server.config.logger.warn(import_picocolors
|
|
27179
|
+
server.config.logger.warn(import_picocolors.default.yellow(e$1.message));
|
|
27186
27180
|
return;
|
|
27187
27181
|
}
|
|
27188
27182
|
if (e$1?.code === ERR_LOAD_URL) return next();
|
|
@@ -27207,11 +27201,11 @@ function transformMiddleware(server) {
|
|
|
27207
27201
|
let warning;
|
|
27208
27202
|
if (isImportRequest(url$4)) {
|
|
27209
27203
|
const rawUrl = removeImportQuery(url$4);
|
|
27210
|
-
if (urlRE
|
|
27204
|
+
if (urlRE.test(url$4)) warning = `Assets in the public directory are served at the root path.\nInstead of ${import_picocolors.default.cyan(rawUrl)}, use ${import_picocolors.default.cyan(rawUrl.replace(publicPath, "/"))}.`;
|
|
27211
27205
|
else warning = `Assets in public directory cannot be imported from JavaScript.
|
|
27212
|
-
If you intend to import that asset, put the file in the src directory, and use ${import_picocolors
|
|
27213
|
-
} else warning = `Files in the public directory are served at the root path.\nInstead of ${import_picocolors
|
|
27214
|
-
server.config.logger.warn(import_picocolors
|
|
27206
|
+
If you intend to import that asset, put the file in the src directory, and use ${import_picocolors.default.cyan(rawUrl.replace(publicPath, "/src/"))} instead of ${import_picocolors.default.cyan(rawUrl)}.\nIf you intend to use the URL of that asset, use ${import_picocolors.default.cyan(injectQuery(rawUrl.replace(publicPath, "/"), "url"))}.`;
|
|
27207
|
+
} else warning = `Files in the public directory are served at the root path.\nInstead of ${import_picocolors.default.cyan(url$4)}, use ${import_picocolors.default.cyan(url$4.replace(publicPath, "/"))}.`;
|
|
27208
|
+
server.config.logger.warn(import_picocolors.default.yellow(warning));
|
|
27215
27209
|
}
|
|
27216
27210
|
}
|
|
27217
27211
|
|
|
@@ -28035,9 +28029,9 @@ function memoryFilesMiddleware(server) {
|
|
|
28035
28029
|
*/
|
|
28036
28030
|
function rejectNoCorsRequestMiddleware() {
|
|
28037
28031
|
return function viteRejectNoCorsRequestMiddleware(req$1, res, next) {
|
|
28038
|
-
if (req$1.headers["sec-fetch-mode"] === "no-cors" && req$1.headers["sec-fetch-site"] !== "same-origin") {
|
|
28032
|
+
if (req$1.headers["sec-fetch-mode"] === "no-cors" && req$1.headers["sec-fetch-site"] !== "same-origin" && req$1.headers["sec-fetch-dest"] === "script") {
|
|
28039
28033
|
res.statusCode = 403;
|
|
28040
|
-
res.end("Cross-origin requests must be made with CORS mode enabled.");
|
|
28034
|
+
res.end("Cross-origin requests for classic scripts must be made with CORS mode enabled. Make sure to set the \"crossorigin\" attribute on your <script> tag.");
|
|
28041
28035
|
return;
|
|
28042
28036
|
}
|
|
28043
28037
|
return next();
|
|
@@ -28046,9 +28040,8 @@ function rejectNoCorsRequestMiddleware() {
|
|
|
28046
28040
|
|
|
28047
28041
|
//#endregion
|
|
28048
28042
|
//#region src/node/server/index.ts
|
|
28049
|
-
var import_connect
|
|
28050
|
-
var import_lib
|
|
28051
|
-
var import_picocolors$11 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
28043
|
+
var import_connect = /* @__PURE__ */ __toESM(require_connect(), 1);
|
|
28044
|
+
var import_lib = /* @__PURE__ */ __toESM(require_lib$1(), 1);
|
|
28052
28045
|
var import_chokidar = /* @__PURE__ */ __toESM(require_chokidar(), 1);
|
|
28053
28046
|
var import_launch_editor_middleware = /* @__PURE__ */ __toESM(require_launch_editor_middleware(), 1);
|
|
28054
28047
|
const usedConfigs = /* @__PURE__ */ new WeakSet();
|
|
@@ -28070,7 +28063,7 @@ async function _createServer(inlineConfig = {}, options) {
|
|
|
28070
28063
|
disableGlobbing: true,
|
|
28071
28064
|
...serverConfig.watch
|
|
28072
28065
|
}, resolvedOutDirs, emptyOutDir, config.cacheDir);
|
|
28073
|
-
const middlewares = (0, import_connect
|
|
28066
|
+
const middlewares = (0, import_connect.default)();
|
|
28074
28067
|
const httpServer = middlewareMode ? null : await resolveHttpServer(middlewares, httpsOptions);
|
|
28075
28068
|
const ws = createWebSocketServer(httpServer, config, httpsOptions);
|
|
28076
28069
|
const publicFiles = await initPublicFilesPromise;
|
|
@@ -28166,7 +28159,7 @@ async function _createServer(inlineConfig = {}, options) {
|
|
|
28166
28159
|
},
|
|
28167
28160
|
ssrRewriteStacktrace(stack) {
|
|
28168
28161
|
warnFutureDeprecation(config, "removeSsrLoadModule", "ssrRewriteStacktrace doesn't need to be used for Environment Module Runners.");
|
|
28169
|
-
return ssrRewriteStacktrace(stack, server.environments.ssr.moduleGraph);
|
|
28162
|
+
return ssrRewriteStacktrace(stack, server.environments.ssr.moduleGraph).result;
|
|
28170
28163
|
},
|
|
28171
28164
|
async reloadModule(module$1) {
|
|
28172
28165
|
warnFutureDeprecation(config, "removeServerReloadModule");
|
|
@@ -28290,7 +28283,7 @@ async function _createServer(inlineConfig = {}, options) {
|
|
|
28290
28283
|
middlewares.use(rejectInvalidRequestMiddleware());
|
|
28291
28284
|
middlewares.use(rejectNoCorsRequestMiddleware());
|
|
28292
28285
|
const { cors } = serverConfig;
|
|
28293
|
-
if (cors !== false) middlewares.use((0, import_lib
|
|
28286
|
+
if (cors !== false) middlewares.use((0, import_lib.default)(typeof cors === "boolean" ? {} : cors));
|
|
28294
28287
|
const { allowedHosts } = serverConfig;
|
|
28295
28288
|
if (allowedHosts !== true && !serverConfig.https) middlewares.use(hostValidationMiddleware(allowedHosts, false));
|
|
28296
28289
|
const configureServerContext = new BasicMinimalPluginContext({
|
|
@@ -28302,7 +28295,7 @@ async function _createServer(inlineConfig = {}, options) {
|
|
|
28302
28295
|
if (!config.experimental.bundledDev) middlewares.use(cachedTransformMiddleware(server));
|
|
28303
28296
|
const { proxy } = serverConfig;
|
|
28304
28297
|
if (proxy) {
|
|
28305
|
-
const middlewareServer = (isObject(middlewareMode) ? middlewareMode.server : null) || httpServer;
|
|
28298
|
+
const middlewareServer = (isObject$1(middlewareMode) ? middlewareMode.server : null) || httpServer;
|
|
28306
28299
|
middlewares.use(proxyMiddleware(middlewareServer, proxy, config));
|
|
28307
28300
|
}
|
|
28308
28301
|
if (config.base !== "/") middlewares.use(baseMiddleware(config.rawBase, !!middlewareMode));
|
|
@@ -28424,7 +28417,7 @@ function resolveServerOptions(root, raw, logger) {
|
|
|
28424
28417
|
const _server = mergeWithDefaults({
|
|
28425
28418
|
..._serverConfigDefaults,
|
|
28426
28419
|
host: void 0,
|
|
28427
|
-
sourcemapIgnoreList: isInNodeModules
|
|
28420
|
+
sourcemapIgnoreList: isInNodeModules$1
|
|
28428
28421
|
}, raw ?? {});
|
|
28429
28422
|
const server = {
|
|
28430
28423
|
..._server,
|
|
@@ -28450,7 +28443,7 @@ function resolveServerOptions(root, raw, logger) {
|
|
|
28450
28443
|
server.fs.allow = allowDirs;
|
|
28451
28444
|
if (server.origin?.endsWith("/")) {
|
|
28452
28445
|
server.origin = server.origin.slice(0, -1);
|
|
28453
|
-
logger.warn(import_picocolors
|
|
28446
|
+
logger.warn(import_picocolors.default.yellow(`${import_picocolors.default.bold("(!)")} server.origin should not end with "/". Using "${server.origin}" instead.`));
|
|
28454
28447
|
}
|
|
28455
28448
|
if (process.env.__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS && Array.isArray(server.allowedHosts)) {
|
|
28456
28449
|
const additionalHost = process.env.__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS;
|
|
@@ -28511,7 +28504,6 @@ async function restartServerWithUrls(server) {
|
|
|
28511
28504
|
|
|
28512
28505
|
//#endregion
|
|
28513
28506
|
//#region src/node/server/hmr.ts
|
|
28514
|
-
var import_picocolors$10 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
28515
28507
|
const debugHmr = createDebugger("vite:hmr");
|
|
28516
28508
|
const whitespaceRE = /\s/;
|
|
28517
28509
|
const normalizedClientDir = normalizePath(CLIENT_DIR);
|
|
@@ -28655,19 +28647,19 @@ async function handleHMRUpdate(type, file, server) {
|
|
|
28655
28647
|
const isConfigDependency = config.configFileDependencies.some((name) => file === name);
|
|
28656
28648
|
const isEnv = config.envDir !== false && getEnvFilesForMode(config.mode, config.envDir).includes(file);
|
|
28657
28649
|
if (isConfig || isConfigDependency || isEnv) {
|
|
28658
|
-
debugHmr?.(`[config change] ${import_picocolors
|
|
28659
|
-
config.logger.info(import_picocolors
|
|
28650
|
+
debugHmr?.(`[config change] ${import_picocolors.default.dim(shortFile)}`);
|
|
28651
|
+
config.logger.info(import_picocolors.default.green(`${normalizePath(path.relative(process.cwd(), file))} changed, restarting server...`), {
|
|
28660
28652
|
clear: true,
|
|
28661
28653
|
timestamp: true
|
|
28662
28654
|
});
|
|
28663
28655
|
try {
|
|
28664
28656
|
await restartServerWithUrls(server);
|
|
28665
28657
|
} catch (e$1) {
|
|
28666
|
-
config.logger.error(import_picocolors
|
|
28658
|
+
config.logger.error(import_picocolors.default.red(e$1));
|
|
28667
28659
|
}
|
|
28668
28660
|
return;
|
|
28669
28661
|
}
|
|
28670
|
-
debugHmr?.(`[file change] ${import_picocolors
|
|
28662
|
+
debugHmr?.(`[file change] ${import_picocolors.default.dim(shortFile)}`);
|
|
28671
28663
|
if (file.startsWith(withTrailingSlash(normalizedClientDir))) {
|
|
28672
28664
|
environments.forEach(({ hot }) => hot.send({
|
|
28673
28665
|
type: "full-reload",
|
|
@@ -28752,7 +28744,7 @@ async function handleHMRUpdate(type, file, server) {
|
|
|
28752
28744
|
if (error$1) throw error$1;
|
|
28753
28745
|
if (!options.modules.length) {
|
|
28754
28746
|
if (file.endsWith(".html") && environment.name === "client") {
|
|
28755
|
-
environment.logger.info(import_picocolors
|
|
28747
|
+
environment.logger.info(import_picocolors.default.green(`page reload `) + import_picocolors.default.dim(shortFile), {
|
|
28756
28748
|
clear: true,
|
|
28757
28749
|
timestamp: true
|
|
28758
28750
|
});
|
|
@@ -28760,7 +28752,7 @@ async function handleHMRUpdate(type, file, server) {
|
|
|
28760
28752
|
type: "full-reload",
|
|
28761
28753
|
path: config.server.middlewareMode ? "*" : "/" + normalizePath(path.relative(config.root, file))
|
|
28762
28754
|
});
|
|
28763
|
-
} else debugHmr?.(`(${environment.name}) [no modules matched] ${import_picocolors
|
|
28755
|
+
} else debugHmr?.(`(${environment.name}) [no modules matched] ${import_picocolors.default.dim(shortFile)}`);
|
|
28764
28756
|
return;
|
|
28765
28757
|
}
|
|
28766
28758
|
updateModules(environment, shortFile, options.modules, timestamp);
|
|
@@ -28806,8 +28798,8 @@ function updateModules(environment, file, modules, timestamp, firstInvalidatedBy
|
|
|
28806
28798
|
}
|
|
28807
28799
|
const isClientHtmlChange = file.endsWith(".html") && environment.name === "client" && modules.every((mod) => mod.type !== "js");
|
|
28808
28800
|
if (needFullReload || isClientHtmlChange) {
|
|
28809
|
-
const reason = typeof needFullReload === "string" ? import_picocolors
|
|
28810
|
-
environment.logger.info(import_picocolors
|
|
28801
|
+
const reason = typeof needFullReload === "string" ? import_picocolors.default.dim(` (${needFullReload})`) : "";
|
|
28802
|
+
environment.logger.info(import_picocolors.default.green(`page reload `) + import_picocolors.default.dim(file) + reason, {
|
|
28811
28803
|
clear: !firstInvalidatedBy,
|
|
28812
28804
|
timestamp: true
|
|
28813
28805
|
});
|
|
@@ -28819,10 +28811,10 @@ function updateModules(environment, file, modules, timestamp, firstInvalidatedBy
|
|
|
28819
28811
|
return;
|
|
28820
28812
|
}
|
|
28821
28813
|
if (updates.length === 0) {
|
|
28822
|
-
debugHmr?.(import_picocolors
|
|
28814
|
+
debugHmr?.(import_picocolors.default.yellow(`no update happened `) + import_picocolors.default.dim(file));
|
|
28823
28815
|
return;
|
|
28824
28816
|
}
|
|
28825
|
-
environment.logger.info(import_picocolors
|
|
28817
|
+
environment.logger.info(import_picocolors.default.green(`hmr update `) + import_picocolors.default.dim([...new Set(updates.map((u) => u.path))].join(", ")), {
|
|
28826
28818
|
clear: !firstInvalidatedBy,
|
|
28827
28819
|
timestamp: true
|
|
28828
28820
|
});
|
|
@@ -28839,7 +28831,7 @@ function propagateUpdate(node, traversedModules, boundaries, currentChain = [nod
|
|
|
28839
28831
|
if (traversedModules.has(node)) return false;
|
|
28840
28832
|
traversedModules.add(node);
|
|
28841
28833
|
if (node.id && node.isSelfAccepting === void 0) {
|
|
28842
|
-
debugHmr?.(`[propagate update] stop propagation because not analyzed: ${import_picocolors
|
|
28834
|
+
debugHmr?.(`[propagate update] stop propagation because not analyzed: ${import_picocolors.default.dim(node.id)}`);
|
|
28843
28835
|
return false;
|
|
28844
28836
|
}
|
|
28845
28837
|
if (node.isSelfAccepting) {
|
|
@@ -28900,7 +28892,7 @@ function isNodeWithinCircularImports(node, nodeChain, currentChain = [node], tra
|
|
|
28900
28892
|
...[...currentChain].reverse(),
|
|
28901
28893
|
...nodeChain.slice(importerIndex, -1).reverse()
|
|
28902
28894
|
];
|
|
28903
|
-
debugHmr(import_picocolors
|
|
28895
|
+
debugHmr(import_picocolors.default.yellow(`circular imports detected: `) + importChain.map((m) => import_picocolors.default.dim(m.url)).join(" -> "));
|
|
28904
28896
|
}
|
|
28905
28897
|
return true;
|
|
28906
28898
|
}
|
|
@@ -28916,7 +28908,7 @@ function handlePrunedModules(mods, { hot }) {
|
|
|
28916
28908
|
mods.forEach((mod) => {
|
|
28917
28909
|
mod.lastHMRTimestamp = t$1;
|
|
28918
28910
|
mod.lastHMRInvalidationReceived = false;
|
|
28919
|
-
debugHmr?.(`[dispose] ${import_picocolors
|
|
28911
|
+
debugHmr?.(`[dispose] ${import_picocolors.default.dim(mod.file)}`);
|
|
28920
28912
|
});
|
|
28921
28913
|
hot.send({
|
|
28922
28914
|
type: "prune",
|
|
@@ -29067,7 +29059,7 @@ function createIsConfiguredAsExternal(environment) {
|
|
|
29067
29059
|
const { config } = environment;
|
|
29068
29060
|
const { root, resolve: resolve$4 } = config;
|
|
29069
29061
|
const { external, noExternal } = resolve$4;
|
|
29070
|
-
const noExternalFilter = typeof noExternal !== "boolean" && !(Array.isArray(noExternal) && noExternal.length === 0) && createFilter(void 0, noExternal, { resolve: false });
|
|
29062
|
+
const noExternalFilter = typeof noExternal !== "boolean" && !(Array.isArray(noExternal) && noExternal.length === 0) && createFilter$1(void 0, noExternal, { resolve: false });
|
|
29071
29063
|
const targetConditions = resolve$4.externalConditions;
|
|
29072
29064
|
const resolveOptions = {
|
|
29073
29065
|
...resolve$4,
|
|
@@ -29081,7 +29073,7 @@ function createIsConfiguredAsExternal(environment) {
|
|
|
29081
29073
|
try {
|
|
29082
29074
|
const resolved = tryNodeResolve(id, config.command === "build" ? void 0 : importer, resolveOptions, void 0, false);
|
|
29083
29075
|
if (!resolved) return false;
|
|
29084
|
-
if (!configuredAsExternal && !isInNodeModules(resolved.id)) return false;
|
|
29076
|
+
if (!configuredAsExternal && !isInNodeModules$1(resolved.id)) return false;
|
|
29085
29077
|
return canExternalizeFile(resolved.id);
|
|
29086
29078
|
} catch {
|
|
29087
29079
|
debug$5?.(`Failed to node resolve "${id}". Skipping externalizing it by default.`);
|
|
@@ -29116,7 +29108,6 @@ function canExternalizeFile(filePath) {
|
|
|
29116
29108
|
|
|
29117
29109
|
//#endregion
|
|
29118
29110
|
//#region src/node/plugins/worker.ts
|
|
29119
|
-
var import_picocolors$9 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
29120
29111
|
var WorkerOutputCache = class {
|
|
29121
29112
|
/**
|
|
29122
29113
|
* worker bundle information for each input id
|
|
@@ -29142,7 +29133,7 @@ var WorkerOutputCache = class {
|
|
|
29142
29133
|
saveAsset(asset, logger) {
|
|
29143
29134
|
const duplicateAsset = this.assets.get(asset.fileName);
|
|
29144
29135
|
if (duplicateAsset) {
|
|
29145
|
-
if (!isSameContent(duplicateAsset.source, asset.source)) logger.warn(`\n` + import_picocolors
|
|
29136
|
+
if (!isSameContent(duplicateAsset.source, asset.source)) logger.warn(`\n` + import_picocolors.default.yellow(`The emitted file ${JSON.stringify(asset.fileName)} overwrites a previously emitted file of the same name.`));
|
|
29146
29137
|
}
|
|
29147
29138
|
this.assets.set(asset.fileName, asset);
|
|
29148
29139
|
}
|
|
@@ -29272,7 +29263,7 @@ function webWorkerPostPlugin(config) {
|
|
|
29272
29263
|
await init;
|
|
29273
29264
|
let imports;
|
|
29274
29265
|
try {
|
|
29275
|
-
imports = parse$
|
|
29266
|
+
imports = parse$3(code)[0];
|
|
29276
29267
|
} catch {
|
|
29277
29268
|
return;
|
|
29278
29269
|
}
|
|
@@ -29366,11 +29357,11 @@ function webWorkerPlugin(config) {
|
|
|
29366
29357
|
for (const file of result.watchedFiles) this.addWatchFile(file);
|
|
29367
29358
|
}
|
|
29368
29359
|
else {
|
|
29369
|
-
let url$4 = await fileToUrl(this, cleanUrl(id));
|
|
29360
|
+
let url$4 = await fileToUrl$1(this, cleanUrl(id));
|
|
29370
29361
|
url$4 = injectQuery(url$4, `${WORKER_FILE_ID}&type=${workerType}`);
|
|
29371
29362
|
urlCode = JSON.stringify(url$4);
|
|
29372
29363
|
}
|
|
29373
|
-
if (urlRE.test(id)) return {
|
|
29364
|
+
if (urlRE$1.test(id)) return {
|
|
29374
29365
|
code: `export default ${urlCode}`,
|
|
29375
29366
|
map: { mappings: "" }
|
|
29376
29367
|
};
|
|
@@ -29494,7 +29485,7 @@ function preAliasPlugin(config) {
|
|
|
29494
29485
|
if (resolved && !depsOptimizer.isOptimizedDepFile(resolved.id)) {
|
|
29495
29486
|
const optimizeDeps$1 = depsOptimizer.options;
|
|
29496
29487
|
const resolvedId = cleanUrl(resolved.id);
|
|
29497
|
-
if (!(resolvedId === id || resolvedId.includes("\0")) && fs.existsSync(resolvedId) && !moduleListContains(optimizeDeps$1.exclude, id) && path.isAbsolute(resolvedId) && (isInNodeModules(resolvedId) || optimizeDeps$1.include?.includes(id)) && isOptimizable(resolvedId, optimizeDeps$1) && (!ssr || optimizeAliasReplacementForSSR(resolvedId, optimizeDeps$1))) {
|
|
29488
|
+
if (!(resolvedId === id || resolvedId.includes("\0")) && fs.existsSync(resolvedId) && !moduleListContains(optimizeDeps$1.exclude, id) && path.isAbsolute(resolvedId) && (isInNodeModules$1(resolvedId) || optimizeDeps$1.include?.includes(id)) && isOptimizable(resolvedId, optimizeDeps$1) && (!ssr || optimizeAliasReplacementForSSR(resolvedId, optimizeDeps$1))) {
|
|
29498
29489
|
const optimizedInfo = depsOptimizer.registerMissingImport(id, resolvedId);
|
|
29499
29490
|
return { id: depsOptimizer.getOptimizedDepId(optimizedInfo) };
|
|
29500
29491
|
}
|
|
@@ -29526,7 +29517,6 @@ function getAliasPatternMatcher(entries) {
|
|
|
29526
29517
|
|
|
29527
29518
|
//#endregion
|
|
29528
29519
|
//#region src/node/plugins/importAnalysis.ts
|
|
29529
|
-
var import_picocolors$8 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
29530
29520
|
const debug$4 = createDebugger("vite:import-analysis");
|
|
29531
29521
|
const clientDir = normalizePath(CLIENT_DIR);
|
|
29532
29522
|
const skipRE = /\.(?:map|json)(?:$|\?)/;
|
|
@@ -29632,7 +29622,7 @@ function importAnalysisPlugin(config) {
|
|
|
29632
29622
|
const ssr = environment.config.consumer === "server";
|
|
29633
29623
|
const moduleGraph = environment.moduleGraph;
|
|
29634
29624
|
if (canSkipImportAnalysis(importer)) {
|
|
29635
|
-
debug$4?.(import_picocolors
|
|
29625
|
+
debug$4?.(import_picocolors.default.dim(`[skipped] ${prettifyUrl(importer, root)}`));
|
|
29636
29626
|
return null;
|
|
29637
29627
|
}
|
|
29638
29628
|
const msAtStart = debug$4 ? performance$1.now() : 0;
|
|
@@ -29641,7 +29631,7 @@ function importAnalysisPlugin(config) {
|
|
|
29641
29631
|
let exports$1;
|
|
29642
29632
|
source = stripBomTag(source);
|
|
29643
29633
|
try {
|
|
29644
|
-
[imports, exports$1] = parse$
|
|
29634
|
+
[imports, exports$1] = parse$3(source);
|
|
29645
29635
|
} catch (_e) {
|
|
29646
29636
|
const e$1 = _e;
|
|
29647
29637
|
const { message, showCodeFrame } = createParseErrorInfo(importer, source);
|
|
@@ -29652,7 +29642,7 @@ function importAnalysisPlugin(config) {
|
|
|
29652
29642
|
if (!importerModule) throwOutdatedRequest(importer);
|
|
29653
29643
|
if (!imports.length && !this._addedImports) {
|
|
29654
29644
|
importerModule.isSelfAccepting = false;
|
|
29655
|
-
debug$4?.(`${timeFrom(msAtStart)} ${import_picocolors
|
|
29645
|
+
debug$4?.(`${timeFrom(msAtStart)} ${import_picocolors.default.dim(`[no imports] ${prettifyUrl(importer, root)}`)}`);
|
|
29656
29646
|
return source;
|
|
29657
29647
|
}
|
|
29658
29648
|
let hasHMR = false;
|
|
@@ -29743,7 +29733,7 @@ function importAnalysisPlugin(config) {
|
|
|
29743
29733
|
if (isBuiltin(environment.config.resolve.builtins, specifier)) return;
|
|
29744
29734
|
}
|
|
29745
29735
|
if (specifier === clientPublicPath) return;
|
|
29746
|
-
if (specifier[0] === "/" && !(config.assetsInclude(cleanUrl(specifier)) || urlRE.test(specifier)) && checkPublicFile(specifier, config)) throw new Error(`Cannot import non-asset file ${specifier} which is inside /public. JS/CSS files inside /public are copied as-is on build and can only be referenced via <script src> or <link href> in html. If you want to get the URL of that file, use ${injectQuery(specifier, "url")} instead.`);
|
|
29736
|
+
if (specifier[0] === "/" && !(config.assetsInclude(cleanUrl(specifier)) || urlRE$1.test(specifier)) && checkPublicFile(specifier, config)) throw new Error(`Cannot import non-asset file ${specifier} which is inside /public. JS/CSS files inside /public are copied as-is on build and can only be referenced via <script src> or <link href> in html. If you want to get the URL of that file, use ${injectQuery(specifier, "url")} instead.`);
|
|
29747
29737
|
let [url$4, resolvedId] = await normalizeUrl(specifier, start);
|
|
29748
29738
|
resolvedId = resolvedId || url$4;
|
|
29749
29739
|
config.safeModulePaths.add(fsPathFromUrl(stripBase(url$4, base)));
|
|
@@ -29754,7 +29744,7 @@ function importAnalysisPlugin(config) {
|
|
|
29754
29744
|
const depInfo = optimizedDepInfoFromFile(depsOptimizer.metadata, file);
|
|
29755
29745
|
const needsInterop$1 = await optimizedDepNeedsInterop(environment, depsOptimizer.metadata, file);
|
|
29756
29746
|
if (needsInterop$1 === void 0) {
|
|
29757
|
-
if (depInfo?.isDynamicEntry) config.logger.error(import_picocolors
|
|
29747
|
+
if (depInfo?.isDynamicEntry) config.logger.error(import_picocolors.default.red(`Vite Error, ${url$4} optimized info should be defined`));
|
|
29758
29748
|
} else if (needsInterop$1) {
|
|
29759
29749
|
debug$4?.(`${url$4} needs interop`);
|
|
29760
29750
|
interopNamedImports(str(), importSpecifier, url$4, index, importer, isNodeMode(), config);
|
|
@@ -29780,8 +29770,8 @@ function importAnalysisPlugin(config) {
|
|
|
29780
29770
|
environment.warmupRequest(url$5);
|
|
29781
29771
|
}
|
|
29782
29772
|
} else if (!importer.startsWith(withTrailingSlash(clientDir))) {
|
|
29783
|
-
if (!isInNodeModules(importer)) {
|
|
29784
|
-
if (!hasViteIgnoreRE.test(source.slice(dynamicIndex + 1, end))) this.warn(`\n` + import_picocolors
|
|
29773
|
+
if (!isInNodeModules$1(importer)) {
|
|
29774
|
+
if (!hasViteIgnoreRE.test(source.slice(dynamicIndex + 1, end))) this.warn(`\n` + import_picocolors.default.cyan(importerModule.file) + `\n` + import_picocolors.default.reset(generateCodeFrame(source, start, end)) + import_picocolors.default.yellow(`\nThe above dynamic import cannot be analyzed by Vite.\nSee ${import_picocolors.default.blue(`https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars#limitations`)} for supported dynamic import formats. If this is intended to be left as-is, you can use the /* @vite-ignore */ comment inside the import() call to suppress this warning.\n`));
|
|
29785
29775
|
}
|
|
29786
29776
|
if (!ssr) {
|
|
29787
29777
|
if (!urlIsStringRE.test(rawUrl) || isExplicitImportRequired(rawUrl.slice(1, -1))) {
|
|
@@ -29837,7 +29827,7 @@ function importAnalysisPlugin(config) {
|
|
|
29837
29827
|
const prunedImports = await moduleGraph.updateModuleInfo(importerModule, importedUrls, importedBindings, normalizedAcceptedUrls, isPartiallySelfAccepting ? acceptedExports : null, isSelfAccepting, staticImportedUrls);
|
|
29838
29828
|
if (prunedImports) handlePrunedModules(prunedImports, environment);
|
|
29839
29829
|
}
|
|
29840
|
-
debug$4?.(`${timeFrom(msAtStart)} ${import_picocolors
|
|
29830
|
+
debug$4?.(`${timeFrom(msAtStart)} ${import_picocolors.default.dim(`[${importedUrls.size} imports rewritten] ${prettifyUrl(importer, root)}`)}`);
|
|
29841
29831
|
if (s) return transformStableResult(s, importer, config);
|
|
29842
29832
|
else return source;
|
|
29843
29833
|
}
|
|
@@ -29895,7 +29885,7 @@ function getLineBreaks(str) {
|
|
|
29895
29885
|
*/
|
|
29896
29886
|
function transformCjsImport(importExp, url$4, rawUrl, importIndex, importer, isNodeMode, config) {
|
|
29897
29887
|
const node = parseAst(importExp).body[0];
|
|
29898
|
-
if (config.command === "serve" && node.type === "ExportAllDeclaration" && !node.exported) config.logger.warn(import_picocolors
|
|
29888
|
+
if (config.command === "serve" && node.type === "ExportAllDeclaration" && !node.exported) config.logger.warn(import_picocolors.default.yellow(`\nUnable to interop \`${importExp}\` in ${importer}, this may lose module exports. Please export "${rawUrl}" as ESM or use named exports instead, e.g. \`export { A, B } from "${rawUrl}"\``));
|
|
29899
29889
|
else if (node.type === "ImportDeclaration" || node.type === "ExportNamedDeclaration") {
|
|
29900
29890
|
if (!node.specifiers.length) return `import "${url$4}"`;
|
|
29901
29891
|
const importNames = [];
|
|
@@ -29998,7 +29988,7 @@ const wasmHelperPlugin = (config) => {
|
|
|
29998
29988
|
filter: { id: [exactRegex(wasmHelperId), wasmInitRE] },
|
|
29999
29989
|
async handler(id) {
|
|
30000
29990
|
if (id === wasmHelperId) return `export default ${wasmHelperCode}`;
|
|
30001
|
-
const url$4 = await fileToUrl(this, id);
|
|
29991
|
+
const url$4 = await fileToUrl$1(this, id);
|
|
30002
29992
|
return `
|
|
30003
29993
|
import initWasm from "${wasmHelperId}"
|
|
30004
29994
|
export default opts => initWasm(opts, ${JSON.stringify(url$4)})
|
|
@@ -30138,7 +30128,7 @@ function workerImportMetaUrlPlugin(config) {
|
|
|
30138
30128
|
builtUrl = result.entryUrlPlaceholder;
|
|
30139
30129
|
for (const file$1 of result.watchedFiles) this.addWatchFile(file$1);
|
|
30140
30130
|
} else {
|
|
30141
|
-
builtUrl = await fileToUrl(this, cleanUrl(file));
|
|
30131
|
+
builtUrl = await fileToUrl$1(this, cleanUrl(file));
|
|
30142
30132
|
builtUrl = injectQuery(builtUrl, `${WORKER_FILE_ID}&type=${workerType}`);
|
|
30143
30133
|
}
|
|
30144
30134
|
s.update(expStart, expEnd, `new URL(/* @vite-ignore */ ${JSON.stringify(builtUrl)}, '' + import.meta.url)`);
|
|
@@ -30232,9 +30222,9 @@ function assetImportMetaUrlPlugin(config) {
|
|
|
30232
30222
|
if (file) try {
|
|
30233
30223
|
if (publicDir && isParentDirectory(publicDir, file)) {
|
|
30234
30224
|
const publicPath = "/" + path.posix.relative(publicDir, file);
|
|
30235
|
-
builtUrl = await fileToUrl(this, publicPath);
|
|
30225
|
+
builtUrl = await fileToUrl$1(this, publicPath);
|
|
30236
30226
|
} else {
|
|
30237
|
-
builtUrl = await fileToUrl(this, file);
|
|
30227
|
+
builtUrl = await fileToUrl$1(this, file);
|
|
30238
30228
|
if (tryStatSync(file)?.isFile()) this.addWatchFile(file);
|
|
30239
30229
|
}
|
|
30240
30230
|
} catch {}
|
|
@@ -30355,7 +30345,7 @@ function parseDynamicImportPattern(strings) {
|
|
|
30355
30345
|
let globParams = null;
|
|
30356
30346
|
if (search) {
|
|
30357
30347
|
search = "?" + search;
|
|
30358
|
-
if (workerOrSharedWorkerRE.test(search) || urlRE.test(search) || rawRE.test(search)) globParams = {
|
|
30348
|
+
if (workerOrSharedWorkerRE.test(search) || urlRE$1.test(search) || rawRE$1.test(search)) globParams = {
|
|
30359
30349
|
query: search,
|
|
30360
30350
|
import: "*"
|
|
30361
30351
|
};
|
|
@@ -30402,12 +30392,13 @@ function dynamicImportVarsPlugin(config) {
|
|
|
30402
30392
|
exclude,
|
|
30403
30393
|
resolver(id, importer) {
|
|
30404
30394
|
return resolve$4(environment, id, importer);
|
|
30405
|
-
}
|
|
30395
|
+
},
|
|
30396
|
+
isV2: config.nativePluginEnabledLevel >= 2 ? { sourcemap: !!environment.config.build.sourcemap } : void 0
|
|
30406
30397
|
});
|
|
30407
30398
|
});
|
|
30408
30399
|
const getFilter = perEnvironmentState((environment) => {
|
|
30409
30400
|
const { include, exclude } = environment.config.build.dynamicImportVarsOptions;
|
|
30410
|
-
return createFilter(include, exclude);
|
|
30401
|
+
return createFilter$1(include, exclude);
|
|
30411
30402
|
});
|
|
30412
30403
|
return {
|
|
30413
30404
|
name: "vite:dynamic-import-vars",
|
|
@@ -30434,7 +30425,7 @@ function dynamicImportVarsPlugin(config) {
|
|
|
30434
30425
|
await init;
|
|
30435
30426
|
let imports = [];
|
|
30436
30427
|
try {
|
|
30437
|
-
imports = parse$
|
|
30428
|
+
imports = parse$3(source)[0];
|
|
30438
30429
|
} catch {
|
|
30439
30430
|
return null;
|
|
30440
30431
|
}
|
|
@@ -30469,11 +30460,11 @@ function dynamicImportVarsPlugin(config) {
|
|
|
30469
30460
|
|
|
30470
30461
|
//#endregion
|
|
30471
30462
|
//#region src/node/plugins/importMetaGlob.ts
|
|
30472
|
-
var import_picocolors$7 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
30473
30463
|
function importGlobPlugin(config) {
|
|
30474
30464
|
if (config.isBundled && config.nativePluginEnabledLevel >= 1) return viteImportGlobPlugin({
|
|
30475
30465
|
root: config.root,
|
|
30476
|
-
restoreQueryExtension: config.experimental.importGlobRestoreExtension
|
|
30466
|
+
restoreQueryExtension: config.experimental.importGlobRestoreExtension,
|
|
30467
|
+
isV2: config.nativePluginEnabledLevel >= 2 ? { sourcemap: !!config.build.sourcemap } : void 0
|
|
30477
30468
|
});
|
|
30478
30469
|
const importGlobMaps = /* @__PURE__ */ new Map();
|
|
30479
30470
|
return {
|
|
@@ -30565,7 +30556,7 @@ function parseGlobOptions(rawOpts, optsStartIndex, logger) {
|
|
|
30565
30556
|
}
|
|
30566
30557
|
if (opts.as && logger) {
|
|
30567
30558
|
const importSuggestion = forceDefaultAs.includes(opts.as) ? `, import: 'default'` : "";
|
|
30568
|
-
logger.warn(import_picocolors
|
|
30559
|
+
logger.warn(import_picocolors.default.yellow(`The glob option "as" has been deprecated in favour of "query". Please update \`as: '${opts.as}'\` to \`query: '?${opts.as}'${importSuggestion}\`.`));
|
|
30569
30560
|
}
|
|
30570
30561
|
if (opts.as && forceDefaultAs.includes(opts.as)) {
|
|
30571
30562
|
if (opts.import && opts.import !== "default" && opts.import !== "*") throw err(`Option "import" can only be "default" or "*" when "as" is "${opts.as}", but got "${opts.import}"`, optsStartIndex);
|
|
@@ -30830,7 +30821,7 @@ function patternToCodeFilter(pattern) {
|
|
|
30830
30821
|
};
|
|
30831
30822
|
return (code) => code.includes(pattern);
|
|
30832
30823
|
}
|
|
30833
|
-
function createFilter
|
|
30824
|
+
function createFilter(exclude, include) {
|
|
30834
30825
|
if (!exclude && !include) return;
|
|
30835
30826
|
return (input) => {
|
|
30836
30827
|
if (exclude?.some((filter$1) => filter$1(input))) return false;
|
|
@@ -30851,14 +30842,14 @@ function createIdFilter(filter$1, cwd = process.cwd()) {
|
|
|
30851
30842
|
const { exclude, include } = normalizeFilter(filter$1);
|
|
30852
30843
|
const excludeFilter = exclude?.map((p) => patternToIdFilter(p, cwd));
|
|
30853
30844
|
const includeFilter = include?.map((p) => patternToIdFilter(p, cwd));
|
|
30854
|
-
return createFilter
|
|
30845
|
+
return createFilter(excludeFilter, includeFilter);
|
|
30855
30846
|
}
|
|
30856
30847
|
function createCodeFilter(filter$1) {
|
|
30857
30848
|
if (!filter$1) return;
|
|
30858
30849
|
const { exclude, include } = normalizeFilter(filter$1);
|
|
30859
30850
|
const excludeFilter = exclude?.map(patternToCodeFilter);
|
|
30860
30851
|
const includeFilter = include?.map(patternToCodeFilter);
|
|
30861
|
-
return createFilter
|
|
30852
|
+
return createFilter(excludeFilter, includeFilter);
|
|
30862
30853
|
}
|
|
30863
30854
|
function createModuleTypeFilter(filter$1) {
|
|
30864
30855
|
if (!filter$1) return;
|
|
@@ -30893,7 +30884,7 @@ function esbuildBannerFooterCompatPlugin(config) {
|
|
|
30893
30884
|
if (!options) return;
|
|
30894
30885
|
const { include, exclude, banner, footer } = options;
|
|
30895
30886
|
if (!banner && !footer) return;
|
|
30896
|
-
const filter$1 = createFilter(include || /\.(m?ts|[jt]sx)$/, exclude || /\.js$/);
|
|
30887
|
+
const filter$1 = createFilter$1(include || /\.(m?ts|[jt]sx)$/, exclude || /\.js$/);
|
|
30897
30888
|
return {
|
|
30898
30889
|
name: "vite:esbuild-banner-footer-compat",
|
|
30899
30890
|
transform(code, id) {
|
|
@@ -30938,7 +30929,7 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
|
|
|
30938
30929
|
find: item.find,
|
|
30939
30930
|
replacement: item.replacement
|
|
30940
30931
|
};
|
|
30941
|
-
}) }) : alias({
|
|
30932
|
+
}) }) : alias$1({
|
|
30942
30933
|
entries: config.resolve.alias,
|
|
30943
30934
|
customResolver: viteAliasCustomResolver
|
|
30944
30935
|
}),
|
|
@@ -31105,7 +31096,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
31105
31096
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31106
31097
|
SOFTWARE.
|
|
31107
31098
|
*/
|
|
31108
|
-
var import_picocolors$6 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
31109
31099
|
const EMPTY_OBJECT = Object.freeze({});
|
|
31110
31100
|
const debugSourcemapCombineFilter = process.env.DEBUG_VITE_SOURCEMAP_COMBINE_FILTER;
|
|
31111
31101
|
const debugSourcemapCombine = createDebugger("vite:sourcemap-combine", { onlyWhenFocused: true });
|
|
@@ -31288,7 +31278,7 @@ var EnvironmentPluginContainer = class {
|
|
|
31288
31278
|
const key = rawId + id;
|
|
31289
31279
|
if (!this._seenResolves[key]) {
|
|
31290
31280
|
this._seenResolves[key] = true;
|
|
31291
|
-
debugResolve(`${timeFrom(resolveStart)} ${import_picocolors
|
|
31281
|
+
debugResolve(`${timeFrom(resolveStart)} ${import_picocolors.default.cyan(rawId)} -> ${import_picocolors.default.dim(id)}`);
|
|
31292
31282
|
}
|
|
31293
31283
|
}
|
|
31294
31284
|
if (id) {
|
|
@@ -31318,7 +31308,7 @@ var EnvironmentPluginContainer = class {
|
|
|
31318
31308
|
const handler = getHookHandler(plugin.load);
|
|
31319
31309
|
const result = await this.handleHookPromise(handler.call(ctx, id, options));
|
|
31320
31310
|
if (result != null) {
|
|
31321
|
-
if (isObject(result)) ctx._updateModuleInfo(id, result);
|
|
31311
|
+
if (isObject$1(result)) ctx._updateModuleInfo(id, result);
|
|
31322
31312
|
this._updateModuleLoadAddedImports(id, ctx._addedImports);
|
|
31323
31313
|
return result;
|
|
31324
31314
|
}
|
|
@@ -31364,7 +31354,7 @@ var EnvironmentPluginContainer = class {
|
|
|
31364
31354
|
}
|
|
31365
31355
|
if (!result) continue;
|
|
31366
31356
|
debugPluginTransform?.(timeFrom(start), plugin.name, prettifyUrl(id, this.environment.config.root));
|
|
31367
|
-
if (isObject(result)) {
|
|
31357
|
+
if (isObject$1(result)) {
|
|
31368
31358
|
if (result.code !== void 0) {
|
|
31369
31359
|
code = result.code;
|
|
31370
31360
|
if (result.map) {
|
|
@@ -31423,7 +31413,7 @@ var BasicMinimalPluginContext = class {
|
|
|
31423
31413
|
}
|
|
31424
31414
|
warn(rawLog) {
|
|
31425
31415
|
const log$1 = this._normalizeRawLog(rawLog);
|
|
31426
|
-
const msg = buildErrorMessage(log$1, [import_picocolors
|
|
31416
|
+
const msg = buildErrorMessage(log$1, [import_picocolors.default.yellow(`warning: ${log$1.message}`)], false);
|
|
31427
31417
|
this._logger.warn(msg, {
|
|
31428
31418
|
clear: true,
|
|
31429
31419
|
timestamp: true
|
|
@@ -31581,7 +31571,7 @@ var PluginContext = class extends MinimalPluginContext {
|
|
|
31581
31571
|
try {
|
|
31582
31572
|
errLocation = numberToPos(this._activeCode, pos);
|
|
31583
31573
|
} catch (err2) {
|
|
31584
|
-
this.environment.logger.error(import_picocolors
|
|
31574
|
+
this.environment.logger.error(import_picocolors.default.red(`Error in error handler:\n${err2.stack || err2.message}\n`), { error: err2 });
|
|
31585
31575
|
throw err$2;
|
|
31586
31576
|
}
|
|
31587
31577
|
err$2.loc = err$2.loc || {
|
|
@@ -31611,7 +31601,7 @@ var PluginContext = class extends MinimalPluginContext {
|
|
|
31611
31601
|
if (this instanceof TransformPluginContext && typeof err$2.loc?.line === "number" && typeof err$2.loc.column === "number") {
|
|
31612
31602
|
const rawSourceMap = this._getCombinedSourcemap();
|
|
31613
31603
|
if (rawSourceMap && "version" in rawSourceMap) {
|
|
31614
|
-
const { source, line, column } = originalPositionFor(new TraceMap(rawSourceMap), {
|
|
31604
|
+
const { source, line, column } = originalPositionFor$1(new TraceMap(rawSourceMap), {
|
|
31615
31605
|
line: Number(err$2.loc.line),
|
|
31616
31606
|
column: Number(err$2.loc.column)
|
|
31617
31607
|
});
|
|
@@ -31638,7 +31628,7 @@ var PluginContext = class extends MinimalPluginContext {
|
|
|
31638
31628
|
return err$2;
|
|
31639
31629
|
}
|
|
31640
31630
|
_warnIncompatibleMethod(method) {
|
|
31641
|
-
this.environment.logger.warn(import_picocolors
|
|
31631
|
+
this.environment.logger.warn(import_picocolors.default.cyan(`[plugin:${this._plugin.name}] `) + import_picocolors.default.yellow(`context method ${import_picocolors.default.bold(`${method}()`)} is not supported in serve mode. This plugin is likely not vite-compatible.`));
|
|
31642
31632
|
}
|
|
31643
31633
|
};
|
|
31644
31634
|
var ResolveIdContext = class extends PluginContext {
|
|
@@ -31792,7 +31782,6 @@ function createPluginContainer(environments) {
|
|
|
31792
31782
|
|
|
31793
31783
|
//#endregion
|
|
31794
31784
|
//#region src/node/optimizer/scan.ts
|
|
31795
|
-
var import_picocolors$5 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
31796
31785
|
var ScanEnvironment = class extends BaseEnvironment {
|
|
31797
31786
|
mode = "scan";
|
|
31798
31787
|
get pluginContainer() {
|
|
@@ -31845,11 +31834,11 @@ function scanImports(environment) {
|
|
|
31845
31834
|
async function scan$1() {
|
|
31846
31835
|
const entries = await computeEntries(environment);
|
|
31847
31836
|
if (!entries.length) {
|
|
31848
|
-
if (!config.optimizeDeps.entries && !config.optimizeDeps.include) environment.logger.warn(import_picocolors
|
|
31837
|
+
if (!config.optimizeDeps.entries && !config.optimizeDeps.include) environment.logger.warn(import_picocolors.default.yellow("(!) Could not auto-determine entry point from rollupOptions or html files and there are no explicit optimizeDeps.include patterns. Skipping dependency pre-bundling."));
|
|
31849
31838
|
return;
|
|
31850
31839
|
}
|
|
31851
31840
|
if (scanContext.cancelled) return;
|
|
31852
|
-
debug$3?.(`Crawling dependencies using entries: ${entries.map((entry) => `\n ${import_picocolors
|
|
31841
|
+
debug$3?.(`Crawling dependencies using entries: ${entries.map((entry) => `\n ${import_picocolors.default.dim(entry)}`).join("")}`);
|
|
31853
31842
|
const deps = {};
|
|
31854
31843
|
const missing = {};
|
|
31855
31844
|
const context = await prepareRolldownScanner(environment, entries, deps, missing);
|
|
@@ -31861,14 +31850,14 @@ function scanImports(environment) {
|
|
|
31861
31850
|
missing
|
|
31862
31851
|
};
|
|
31863
31852
|
} catch (e$1) {
|
|
31864
|
-
e$1.message = import_picocolors
|
|
31853
|
+
e$1.message = import_picocolors.default.red(`\
|
|
31865
31854
|
Failed to scan for dependencies from entries:
|
|
31866
31855
|
${entries.join("\n")}
|
|
31867
31856
|
|
|
31868
31857
|
`) + e$1.message;
|
|
31869
31858
|
throw e$1;
|
|
31870
31859
|
} finally {
|
|
31871
|
-
if (debug$3) debug$3(`Scan completed in ${(performance$1.now() - start).toFixed(2)}ms: ${Object.keys(orderedDependencies(deps)).sort().map((id) => `\n ${import_picocolors
|
|
31860
|
+
if (debug$3) debug$3(`Scan completed in ${(performance$1.now() - start).toFixed(2)}ms: ${Object.keys(orderedDependencies(deps)).sort().map((id) => `\n ${import_picocolors.default.cyan(id)} -> ${import_picocolors.default.dim(deps[id])}`).join("") || import_picocolors.default.dim("no dependencies found")}`);
|
|
31872
31861
|
}
|
|
31873
31862
|
}
|
|
31874
31863
|
return {
|
|
@@ -31895,7 +31884,7 @@ async function computeEntries(environment) {
|
|
|
31895
31884
|
};
|
|
31896
31885
|
if (typeof buildInput === "string") entries = [await resolvePath(buildInput)];
|
|
31897
31886
|
else if (Array.isArray(buildInput)) entries = await Promise.all(buildInput.map(resolvePath));
|
|
31898
|
-
else if (isObject(buildInput)) entries = await Promise.all(Object.values(buildInput).map(resolvePath));
|
|
31887
|
+
else if (isObject$1(buildInput)) entries = await Promise.all(Object.values(buildInput).map(resolvePath));
|
|
31899
31888
|
else throw new Error("invalid rollupOptions.input value.");
|
|
31900
31889
|
} else entries = await globEntries("**/*.html", environment);
|
|
31901
31890
|
entries = entries.filter((entry) => isScannable(entry, environment.config.optimizeDeps.extensions) && fs.existsSync(entry));
|
|
@@ -32077,7 +32066,7 @@ function rolldownScanPlugin(environment, depImports, missing, entries) {
|
|
|
32077
32066
|
if (htmlTypesRE.test(id)) {
|
|
32078
32067
|
const resolved$1 = await resolve$4(id, importer);
|
|
32079
32068
|
if (!resolved$1) return;
|
|
32080
|
-
if (isInNodeModules(resolved$1) && isOptimizable(resolved$1, optimizeDepsOptions)) return;
|
|
32069
|
+
if (isInNodeModules$1(resolved$1) && isOptimizable(resolved$1, optimizeDepsOptions)) return;
|
|
32081
32070
|
if (shouldExternalizeDep(resolved$1, id)) return externalUnlessEntry({ path: id });
|
|
32082
32071
|
return resolved$1;
|
|
32083
32072
|
}
|
|
@@ -32087,7 +32076,7 @@ function rolldownScanPlugin(environment, depImports, missing, entries) {
|
|
|
32087
32076
|
const resolved$1 = await resolve$4(id, importer);
|
|
32088
32077
|
if (resolved$1) {
|
|
32089
32078
|
if (shouldExternalizeDep(resolved$1, id)) return externalUnlessEntry({ path: id });
|
|
32090
|
-
if (isInNodeModules(resolved$1) || include?.includes(id)) {
|
|
32079
|
+
if (isInNodeModules$1(resolved$1) || include?.includes(id)) {
|
|
32091
32080
|
if (isOptimizable(resolved$1, optimizeDepsOptions)) depImports[id] = resolved$1;
|
|
32092
32081
|
return externalUnlessEntry({ path: id });
|
|
32093
32082
|
} else if (isScannable(resolved$1, optimizeDepsOptions.extensions)) return path.resolve(resolved$1);
|
|
@@ -32209,7 +32198,7 @@ function expandGlobIds(id, config) {
|
|
|
32209
32198
|
const exportsValue = getFirstExportStringValue(exports$1[key]);
|
|
32210
32199
|
if (!exportsValue) continue;
|
|
32211
32200
|
const exportValuePattern = exportsValue.replace(/\*/g, "**/*");
|
|
32212
|
-
const exportsValueGlobRe = new RegExp(exportsValue.split("*").map(escapeRegex).join("(.*)"));
|
|
32201
|
+
const exportsValueGlobRe = new RegExp(exportsValue.split("*").map(escapeRegex$1).join("(.*)"));
|
|
32213
32202
|
possibleExportPaths.push(...globSync(exportValuePattern, {
|
|
32214
32203
|
cwd: pkgData.dir,
|
|
32215
32204
|
expandDirectories: false,
|
|
@@ -32408,7 +32397,7 @@ function rolldownDepPlugin(environment, qualified, external) {
|
|
|
32408
32397
|
}
|
|
32409
32398
|
}];
|
|
32410
32399
|
}
|
|
32411
|
-
const matchesEntireLine = (text) => `^${escapeRegex(text)}$`;
|
|
32400
|
+
const matchesEntireLine = (text) => `^${escapeRegex$1(text)}$`;
|
|
32412
32401
|
function rolldownCjsExternalPlugin(externals, platform$1) {
|
|
32413
32402
|
const filter$1 = new RegExp(externals.map(matchesEntireLine).join("|"));
|
|
32414
32403
|
return {
|
|
@@ -32446,7 +32435,6 @@ module.exports = ${isNodeBuiltin(idWithoutNamespace) ? "m.default" : "{ ...m }"}
|
|
|
32446
32435
|
|
|
32447
32436
|
//#endregion
|
|
32448
32437
|
//#region src/node/optimizer/index.ts
|
|
32449
|
-
var import_picocolors$4 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
32450
32438
|
const debug$2 = createDebugger("vite:deps");
|
|
32451
32439
|
const jsExtensionRE = /\.js$/i;
|
|
32452
32440
|
function isDepOptimizationDisabled(optimizeDeps$1) {
|
|
@@ -32460,7 +32448,7 @@ function isDepOptimizationDisabled(optimizeDeps$1) {
|
|
|
32460
32448
|
*/
|
|
32461
32449
|
async function optimizeDeps(config, force = config.optimizeDeps.force, asCommand = false) {
|
|
32462
32450
|
const log$1 = asCommand ? config.logger.info : debug$2;
|
|
32463
|
-
config.logger.warn(import_picocolors
|
|
32451
|
+
config.logger.warn(import_picocolors.default.yellow("manually calling optimizeDeps is deprecated. This is done automatically and does not need to be called manually."));
|
|
32464
32452
|
const environment = new ScanEnvironment("client", config);
|
|
32465
32453
|
await environment.init();
|
|
32466
32454
|
const cachedMetadata = await loadCachedDepOptimizationMetadata(environment, force, asCommand);
|
|
@@ -32468,7 +32456,7 @@ async function optimizeDeps(config, force = config.optimizeDeps.force, asCommand
|
|
|
32468
32456
|
const deps = await discoverProjectDependencies(environment).result;
|
|
32469
32457
|
await addManuallyIncludedOptimizeDeps(environment, deps);
|
|
32470
32458
|
const depsString = depsLogString(Object.keys(deps));
|
|
32471
|
-
log$1?.(import_picocolors
|
|
32459
|
+
log$1?.(import_picocolors.default.green(`Optimizing dependencies:\n ${depsString}`));
|
|
32472
32460
|
const result = await runOptimizeDeps(environment, toDiscoveredDependencies(environment, deps)).result;
|
|
32473
32461
|
await result.commit();
|
|
32474
32462
|
return result.metadata;
|
|
@@ -32525,7 +32513,7 @@ async function loadCachedDepOptimizationMetadata(environment, force = environmen
|
|
|
32525
32513
|
return cachedMetadata;
|
|
32526
32514
|
}
|
|
32527
32515
|
} else environment.logger.info("Forced re-optimization of dependencies", { timestamp: true });
|
|
32528
|
-
debug$2?.(`(${environment.name}) ${import_picocolors
|
|
32516
|
+
debug$2?.(`(${environment.name}) ${import_picocolors.default.green(`removing old cache dir ${depsCacheDir}`)}`);
|
|
32529
32517
|
await fsp.rm(depsCacheDir, {
|
|
32530
32518
|
recursive: true,
|
|
32531
32519
|
force: true
|
|
@@ -32541,7 +32529,7 @@ function discoverProjectDependencies(environment) {
|
|
|
32541
32529
|
cancel,
|
|
32542
32530
|
result: result.then(({ deps, missing }) => {
|
|
32543
32531
|
const missingIds = Object.keys(missing);
|
|
32544
|
-
if (missingIds.length) throw new Error(`The following dependencies are imported but could not be resolved:\n\n ${missingIds.map((id) => `${import_picocolors
|
|
32532
|
+
if (missingIds.length) throw new Error(`The following dependencies are imported but could not be resolved:\n\n ${missingIds.map((id) => `${import_picocolors.default.cyan(id)} ${import_picocolors.default.white(import_picocolors.default.dim(`(imported by ${missing[id]})`))}`).join(`\n `)}\n\nAre they installed?`);
|
|
32545
32533
|
return deps;
|
|
32546
32534
|
})
|
|
32547
32535
|
};
|
|
@@ -32562,7 +32550,7 @@ function toDiscoveredDependencies(environment, deps, timestamp) {
|
|
|
32562
32550
|
return discovered;
|
|
32563
32551
|
}
|
|
32564
32552
|
function depsLogString(qualifiedIds) {
|
|
32565
|
-
return import_picocolors
|
|
32553
|
+
return import_picocolors.default.yellow(qualifiedIds.join(`, `));
|
|
32566
32554
|
}
|
|
32567
32555
|
/**
|
|
32568
32556
|
* Internally, Vite uses this function to prepare a optimizeDeps run. When Vite starts, we can get
|
|
@@ -32573,7 +32561,7 @@ function runOptimizeDeps(environment, depsInfo) {
|
|
|
32573
32561
|
const depsCacheDir = getDepsCacheDir(environment);
|
|
32574
32562
|
const processingCacheDir = getProcessingDepsCacheDir(environment);
|
|
32575
32563
|
fs.mkdirSync(processingCacheDir, { recursive: true });
|
|
32576
|
-
debug$2?.(import_picocolors
|
|
32564
|
+
debug$2?.(import_picocolors.default.green(`creating package.json in ${processingCacheDir}`));
|
|
32577
32565
|
fs.writeFileSync(path.resolve(processingCacheDir, "package.json"), `{\n "type": "module"\n}\n`);
|
|
32578
32566
|
const metadata = initDepsOptimizerMetadata(environment);
|
|
32579
32567
|
metadata.browserHash = getOptimizedBrowserHash(metadata.hash, depsFromOptimizedDepInfo(depsInfo));
|
|
@@ -32583,7 +32571,7 @@ function runOptimizeDeps(environment, depsInfo) {
|
|
|
32583
32571
|
const cleanUp = () => {
|
|
32584
32572
|
if (!cleaned && !committed) {
|
|
32585
32573
|
cleaned = true;
|
|
32586
|
-
debug$2?.(import_picocolors
|
|
32574
|
+
debug$2?.(import_picocolors.default.green(`removing cache dir ${processingCacheDir}`));
|
|
32587
32575
|
try {
|
|
32588
32576
|
fs.rmSync(processingCacheDir, {
|
|
32589
32577
|
recursive: true,
|
|
@@ -32599,27 +32587,27 @@ function runOptimizeDeps(environment, depsInfo) {
|
|
|
32599
32587
|
if (cleaned) throw new Error("Can not commit a Deps Optimization run as it was cancelled");
|
|
32600
32588
|
committed = true;
|
|
32601
32589
|
const dataPath = path.join(processingCacheDir, METADATA_FILENAME);
|
|
32602
|
-
debug$2?.(import_picocolors
|
|
32590
|
+
debug$2?.(import_picocolors.default.green(`creating ${METADATA_FILENAME} in ${processingCacheDir}`));
|
|
32603
32591
|
fs.writeFileSync(dataPath, stringifyDepsOptimizerMetadata(metadata, depsCacheDir));
|
|
32604
32592
|
const temporaryPath = depsCacheDir + getTempSuffix();
|
|
32605
32593
|
const depsCacheDirPresent = fs.existsSync(depsCacheDir);
|
|
32606
32594
|
if (isWindows) {
|
|
32607
32595
|
if (depsCacheDirPresent) {
|
|
32608
|
-
debug$2?.(import_picocolors
|
|
32596
|
+
debug$2?.(import_picocolors.default.green(`renaming ${depsCacheDir} to ${temporaryPath}`));
|
|
32609
32597
|
await safeRename(depsCacheDir, temporaryPath);
|
|
32610
32598
|
}
|
|
32611
|
-
debug$2?.(import_picocolors
|
|
32599
|
+
debug$2?.(import_picocolors.default.green(`renaming ${processingCacheDir} to ${depsCacheDir}`));
|
|
32612
32600
|
await safeRename(processingCacheDir, depsCacheDir);
|
|
32613
32601
|
} else {
|
|
32614
32602
|
if (depsCacheDirPresent) {
|
|
32615
|
-
debug$2?.(import_picocolors
|
|
32603
|
+
debug$2?.(import_picocolors.default.green(`renaming ${depsCacheDir} to ${temporaryPath}`));
|
|
32616
32604
|
fs.renameSync(depsCacheDir, temporaryPath);
|
|
32617
32605
|
}
|
|
32618
|
-
debug$2?.(import_picocolors
|
|
32606
|
+
debug$2?.(import_picocolors.default.green(`renaming ${processingCacheDir} to ${depsCacheDir}`));
|
|
32619
32607
|
fs.renameSync(processingCacheDir, depsCacheDir);
|
|
32620
32608
|
}
|
|
32621
32609
|
if (depsCacheDirPresent) {
|
|
32622
|
-
debug$2?.(import_picocolors
|
|
32610
|
+
debug$2?.(import_picocolors.default.green(`removing cache temp dir ${temporaryPath}`));
|
|
32623
32611
|
fsp.rm(temporaryPath, {
|
|
32624
32612
|
recursive: true,
|
|
32625
32613
|
force: true
|
|
@@ -32674,7 +32662,7 @@ function runOptimizeDeps(environment, depsInfo) {
|
|
|
32674
32662
|
return successfulResult;
|
|
32675
32663
|
}).catch((e$1) => {
|
|
32676
32664
|
if (e$1.errors && e$1.message.includes("The build was canceled")) return cancelledResult;
|
|
32677
|
-
e$1.message = import_picocolors
|
|
32665
|
+
e$1.message = import_picocolors.default.red("Error during dependency optimization:\n\n") + e$1.message;
|
|
32678
32666
|
throw e$1;
|
|
32679
32667
|
});
|
|
32680
32668
|
});
|
|
@@ -32780,7 +32768,7 @@ async function addManuallyIncludedOptimizeDeps(environment, deps) {
|
|
|
32780
32768
|
const optimizeDepsInclude = optimizeDeps$1.include ?? [];
|
|
32781
32769
|
if (optimizeDepsInclude.length) {
|
|
32782
32770
|
const unableToOptimize = (id, msg) => {
|
|
32783
|
-
if (optimizeDepsInclude.includes(id)) logger.warn(`${msg}: ${import_picocolors
|
|
32771
|
+
if (optimizeDepsInclude.includes(id)) logger.warn(`${msg}: ${import_picocolors.default.cyan(id)}, present in ${environment.name} 'optimizeDeps.include'`);
|
|
32784
32772
|
};
|
|
32785
32773
|
const includes = [...optimizeDepsInclude];
|
|
32786
32774
|
for (let i = 0; i < includes.length; i++) {
|
|
@@ -32913,7 +32901,7 @@ async function extractExportsData(environment, filePath) {
|
|
|
32913
32901
|
};
|
|
32914
32902
|
}
|
|
32915
32903
|
});
|
|
32916
|
-
const [, exports$2, , hasModuleSyntax$1] = parse$
|
|
32904
|
+
const [, exports$2, , hasModuleSyntax$1] = parse$3((await (await rolldown({
|
|
32917
32905
|
...remainingRolldownOptions,
|
|
32918
32906
|
plugins,
|
|
32919
32907
|
input: [filePath],
|
|
@@ -32935,12 +32923,12 @@ async function extractExportsData(environment, filePath) {
|
|
|
32935
32923
|
let usedJsxLoader = false;
|
|
32936
32924
|
const entryContent = fs.readFileSync(filePath, "utf-8");
|
|
32937
32925
|
try {
|
|
32938
|
-
parseResult = parse$
|
|
32926
|
+
parseResult = parse$3(entryContent);
|
|
32939
32927
|
} catch {
|
|
32940
32928
|
const lang = rolldownOptions.moduleTypes?.[path.extname(filePath)] || "jsx";
|
|
32941
32929
|
debug$2?.(`Unable to parse: ${filePath}.\n Trying again with a ${lang} transform.`);
|
|
32942
32930
|
if (lang !== "jsx" && lang !== "tsx" && lang !== "ts") throw new Error(`Unable to parse : ${filePath}.`);
|
|
32943
|
-
parseResult = parse$
|
|
32931
|
+
parseResult = parse$3((await transformWithOxc(entryContent, filePath, { lang }, void 0, environment.config)).code);
|
|
32944
32932
|
usedJsxLoader = true;
|
|
32945
32933
|
}
|
|
32946
32934
|
const [, exports$1, , hasModuleSyntax] = parseResult;
|
|
@@ -33132,7 +33120,6 @@ const safeRename = promisify(function gracefulRename(from, to, cb) {
|
|
|
33132
33120
|
|
|
33133
33121
|
//#endregion
|
|
33134
33122
|
//#region src/node/plugins/resolve.ts
|
|
33135
|
-
var import_picocolors$3 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
33136
33123
|
const normalizedClientEntry = normalizePath(CLIENT_ENTRY);
|
|
33137
33124
|
const normalizedEnvEntry = normalizePath(ENV_ENTRY);
|
|
33138
33125
|
const ERR_RESOLVE_PACKAGE_ENTRY_FAIL = "ERR_RESOLVE_PACKAGE_ENTRY_FAIL";
|
|
@@ -33209,7 +33196,7 @@ function oxcResolvePlugin(resolveOptions, overrideEnvConfig) {
|
|
|
33209
33196
|
const exclude = depsOptimizer?.options.exclude;
|
|
33210
33197
|
const deepMatch = deepImportRE.exec(rawId);
|
|
33211
33198
|
const pkgId = deepMatch ? deepMatch[1] || deepMatch[2] : cleanUrl(rawId);
|
|
33212
|
-
const skipOptimization = depsOptimizer.options.noDiscovery || !isJsType || importer && isInNodeModules(importer) || exclude?.includes(pkgId) || exclude?.includes(rawId) || SPECIAL_QUERY_RE.test(resolvedId);
|
|
33199
|
+
const skipOptimization = depsOptimizer.options.noDiscovery || !isJsType || importer && isInNodeModules$1(importer) || exclude?.includes(pkgId) || exclude?.includes(rawId) || SPECIAL_QUERY_RE.test(resolvedId);
|
|
33213
33200
|
let newId = resolvedId;
|
|
33214
33201
|
if (skipOptimization) {
|
|
33215
33202
|
const versionHash = depsOptimizer.metadata.browserHash;
|
|
@@ -33318,7 +33305,7 @@ function resolvePlugin(resolveOptions) {
|
|
|
33318
33305
|
if (asSrc && depsOptimizer?.isOptimizedDepUrl(id)) return id.startsWith(FS_PREFIX) ? fsPathFromId(id) : normalizePath(path.resolve(root, id.slice(1)));
|
|
33319
33306
|
if (asSrc && id.startsWith(FS_PREFIX)) {
|
|
33320
33307
|
res = fsPathFromId(id);
|
|
33321
|
-
debug$1?.(`[@fs] ${import_picocolors
|
|
33308
|
+
debug$1?.(`[@fs] ${import_picocolors.default.cyan(id)} -> ${import_picocolors.default.dim(res)}`);
|
|
33322
33309
|
return {
|
|
33323
33310
|
id: ensureVersionQuery(res, id, options, depsOptimizer),
|
|
33324
33311
|
packageJsonPath: findNearestPackagePath(res, options.legacyInconsistentCjsInterop, options.packageCache, isBuild)
|
|
@@ -33326,7 +33313,7 @@ function resolvePlugin(resolveOptions) {
|
|
|
33326
33313
|
}
|
|
33327
33314
|
if (asSrc && id[0] === "/" && (rootInRoot || !id.startsWith(withTrailingSlash(root)))) {
|
|
33328
33315
|
if (res = tryFsResolve(path.resolve(root, id.slice(1)), options)) {
|
|
33329
|
-
debug$1?.(`[url] ${import_picocolors
|
|
33316
|
+
debug$1?.(`[url] ${import_picocolors.default.cyan(id)} -> ${import_picocolors.default.dim(res)}`);
|
|
33330
33317
|
return {
|
|
33331
33318
|
id: ensureVersionQuery(res, id, options, depsOptimizer),
|
|
33332
33319
|
packageJsonPath: findNearestPackagePath(res, options.legacyInconsistentCjsInterop, options.packageCache, isBuild)
|
|
@@ -33347,7 +33334,7 @@ function resolvePlugin(resolveOptions) {
|
|
|
33347
33334
|
if (options.mainFields.includes("browser") && (res = tryResolveBrowserMapping(fsPath, importer, options, true))) return res;
|
|
33348
33335
|
if (res = tryFsResolve(fsPath, options)) {
|
|
33349
33336
|
res = ensureVersionQuery(res, id, options, depsOptimizer);
|
|
33350
|
-
debug$1?.(`[relative] ${import_picocolors
|
|
33337
|
+
debug$1?.(`[relative] ${import_picocolors.default.cyan(id)} -> ${import_picocolors.default.dim(res)}`);
|
|
33351
33338
|
if (!options.idOnly && !options.scan && options.isBuild) {
|
|
33352
33339
|
const resPkg = findNearestPackageData(path.dirname(res), options.packageCache);
|
|
33353
33340
|
if (resPkg) return {
|
|
@@ -33366,7 +33353,7 @@ function resolvePlugin(resolveOptions) {
|
|
|
33366
33353
|
if (isWindows && id[0] === "/") {
|
|
33367
33354
|
const basedir = importer ? path.dirname(importer) : process.cwd();
|
|
33368
33355
|
if (res = tryFsResolve(path.resolve(basedir, id), options)) {
|
|
33369
|
-
debug$1?.(`[drive-relative] ${import_picocolors
|
|
33356
|
+
debug$1?.(`[drive-relative] ${import_picocolors.default.cyan(id)} -> ${import_picocolors.default.dim(res)}`);
|
|
33370
33357
|
return {
|
|
33371
33358
|
id: ensureVersionQuery(res, id, options, depsOptimizer),
|
|
33372
33359
|
packageJsonPath: findNearestPackagePath(res, options.legacyInconsistentCjsInterop, options.packageCache, isBuild)
|
|
@@ -33374,7 +33361,7 @@ function resolvePlugin(resolveOptions) {
|
|
|
33374
33361
|
}
|
|
33375
33362
|
}
|
|
33376
33363
|
if (isNonDriveRelativeAbsolutePath(id) && (res = tryFsResolve(id, options))) {
|
|
33377
|
-
debug$1?.(`[fs] ${import_picocolors
|
|
33364
|
+
debug$1?.(`[fs] ${import_picocolors.default.cyan(id)} -> ${import_picocolors.default.dim(res)}`);
|
|
33378
33365
|
return {
|
|
33379
33366
|
id: ensureVersionQuery(res, id, options, depsOptimizer),
|
|
33380
33367
|
packageJsonPath: findNearestPackagePath(res, options.legacyInconsistentCjsInterop, options.packageCache, isBuild)
|
|
@@ -33414,12 +33401,12 @@ function resolvePlugin(resolveOptions) {
|
|
|
33414
33401
|
message += `. Consider disabling environments.${this.environment.name}.noExternal or remove the built-in dependency.`;
|
|
33415
33402
|
this.error(message);
|
|
33416
33403
|
}
|
|
33417
|
-
if (!asSrc) debug$1?.(`externalized node built-in "${id}" to empty module. (imported by: ${import_picocolors
|
|
33404
|
+
if (!asSrc) debug$1?.(`externalized node built-in "${id}" to empty module. (imported by: ${import_picocolors.default.white(import_picocolors.default.dim(importer))})`);
|
|
33418
33405
|
else if (isProduction) this.warn(`Module "${id}" has been externalized for browser compatibility, imported by "${importer}". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.`);
|
|
33419
33406
|
return isProduction ? browserExternalId : `${browserExternalId}:${id}`;
|
|
33420
33407
|
}
|
|
33421
33408
|
}
|
|
33422
|
-
debug$1?.(`[fallthrough] ${import_picocolors
|
|
33409
|
+
debug$1?.(`[fallthrough] ${import_picocolors.default.dim(id)}`);
|
|
33423
33410
|
}
|
|
33424
33411
|
},
|
|
33425
33412
|
load: {
|
|
@@ -33476,7 +33463,7 @@ function resolveSubpathImports(id, importer, options) {
|
|
|
33476
33463
|
}
|
|
33477
33464
|
function ensureVersionQuery(resolved, id, options, depsOptimizer) {
|
|
33478
33465
|
if (!options.isBuild && !options.scan && depsOptimizer && !(resolved === normalizedClientEntry || resolved === normalizedEnvEntry)) {
|
|
33479
|
-
if ((isInNodeModules(id) || isInNodeModules(resolved)) && !DEP_VERSION_RE.test(resolved)) {
|
|
33466
|
+
if ((isInNodeModules$1(id) || isInNodeModules$1(resolved)) && !DEP_VERSION_RE.test(resolved)) {
|
|
33480
33467
|
const versionHash = depsOptimizer.metadata.browserHash;
|
|
33481
33468
|
if (versionHash && isOptimizable(resolved, depsOptimizer.options)) resolved = injectQuery(resolved, `v=${versionHash}`);
|
|
33482
33469
|
}
|
|
@@ -33485,7 +33472,7 @@ function ensureVersionQuery(resolved, id, options, depsOptimizer) {
|
|
|
33485
33472
|
}
|
|
33486
33473
|
function tryFsResolve(fsPath, options, tryIndex = true, skipPackageJson = false) {
|
|
33487
33474
|
const hashIndex = fsPath.indexOf("#");
|
|
33488
|
-
if (hashIndex >= 0 && isInNodeModules(fsPath)) {
|
|
33475
|
+
if (hashIndex >= 0 && isInNodeModules$1(fsPath)) {
|
|
33489
33476
|
const queryIndex = fsPath.indexOf("?");
|
|
33490
33477
|
if (queryIndex < 0 || queryIndex > hashIndex) {
|
|
33491
33478
|
const file$1 = queryIndex > hashIndex ? fsPath.slice(0, queryIndex) : fsPath;
|
|
@@ -33576,7 +33563,7 @@ function tryNodeResolve(id, importer, options, depsOptimizer, externalize) {
|
|
|
33576
33563
|
const index = resolved$1.id.indexOf(id);
|
|
33577
33564
|
if (index > -1) {
|
|
33578
33565
|
resolvedId = resolved$1.id.slice(index);
|
|
33579
|
-
debug$1?.(`[processResult] ${import_picocolors
|
|
33566
|
+
debug$1?.(`[processResult] ${import_picocolors.default.cyan(id)} -> ${import_picocolors.default.dim(resolvedId)}`);
|
|
33580
33567
|
}
|
|
33581
33568
|
}
|
|
33582
33569
|
return {
|
|
@@ -33590,10 +33577,10 @@ function tryNodeResolve(id, importer, options, depsOptimizer, externalize) {
|
|
|
33590
33577
|
moduleSideEffects: pkg.hasSideEffects(resolved),
|
|
33591
33578
|
packageJsonPath: findNearestPackagePath(resolved, options.legacyInconsistentCjsInterop, options.packageCache, isBuild)
|
|
33592
33579
|
});
|
|
33593
|
-
if (!isInNodeModules(resolved) || !depsOptimizer || options.scan) return { id: resolved };
|
|
33580
|
+
if (!isInNodeModules$1(resolved) || !depsOptimizer || options.scan) return { id: resolved };
|
|
33594
33581
|
const isJsType = isOptimizable(resolved, depsOptimizer.options);
|
|
33595
33582
|
const exclude = depsOptimizer.options.exclude;
|
|
33596
|
-
if (depsOptimizer.options.noDiscovery || !isJsType || importer && isInNodeModules(importer) || exclude?.includes(pkgId) || exclude?.includes(id) || SPECIAL_QUERY_RE.test(resolved)) {
|
|
33583
|
+
if (depsOptimizer.options.noDiscovery || !isJsType || importer && isInNodeModules$1(importer) || exclude?.includes(pkgId) || exclude?.includes(id) || SPECIAL_QUERY_RE.test(resolved)) {
|
|
33597
33584
|
const versionHash = depsOptimizer.metadata.browserHash;
|
|
33598
33585
|
if (versionHash && isJsType) resolved = injectQuery(resolved, `v=${versionHash}`);
|
|
33599
33586
|
} else {
|
|
@@ -33652,11 +33639,11 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
|
|
|
33652
33639
|
skipPackageJson = true;
|
|
33653
33640
|
} else {
|
|
33654
33641
|
const { browser: browserField } = data;
|
|
33655
|
-
if (options.mainFields.includes("browser") && isObject(browserField)) entry = mapWithBrowserField(entry, browserField) || entry;
|
|
33642
|
+
if (options.mainFields.includes("browser") && isObject$1(browserField)) entry = mapWithBrowserField(entry, browserField) || entry;
|
|
33656
33643
|
}
|
|
33657
33644
|
const resolvedEntryPoint = tryFsResolve(path.join(dir, entry), options, true, skipPackageJson);
|
|
33658
33645
|
if (resolvedEntryPoint) {
|
|
33659
|
-
debug$1?.(`[package entry] ${import_picocolors
|
|
33646
|
+
debug$1?.(`[package entry] ${import_picocolors.default.cyan(idWithoutPostfix)} -> ${import_picocolors.default.dim(resolvedEntryPoint)}${postfix !== "" ? ` (postfix: ${postfix})` : ""}`);
|
|
33660
33647
|
setResolvedCache(".", resolvedEntryPoint, options);
|
|
33661
33648
|
return resolvedEntryPoint + postfix;
|
|
33662
33649
|
}
|
|
@@ -33694,14 +33681,14 @@ function resolveDeepImport(id, { setResolvedCache, getResolvedCache, dir, data }
|
|
|
33694
33681
|
let relativeId = id;
|
|
33695
33682
|
const { exports: exportsField, browser: browserField } = data;
|
|
33696
33683
|
if (exportsField) {
|
|
33697
|
-
if (isObject(exportsField) && !Array.isArray(exportsField)) {
|
|
33684
|
+
if (isObject$1(exportsField) && !Array.isArray(exportsField)) {
|
|
33698
33685
|
const { file, postfix } = splitFileAndPostfix(relativeId);
|
|
33699
33686
|
const exportsId = resolveExportsOrImports(data, file, options, "exports", externalize);
|
|
33700
33687
|
if (exportsId !== void 0) relativeId = exportsId + postfix;
|
|
33701
33688
|
else relativeId = void 0;
|
|
33702
33689
|
} else relativeId = void 0;
|
|
33703
33690
|
if (!relativeId) throw new Error(`Package subpath '${relativeId}' is not defined by "exports" in ${path.join(dir, "package.json")}.`);
|
|
33704
|
-
} else if (options.mainFields.includes("browser") && isObject(browserField)) {
|
|
33691
|
+
} else if (options.mainFields.includes("browser") && isObject$1(browserField)) {
|
|
33705
33692
|
const { file, postfix } = splitFileAndPostfix(relativeId);
|
|
33706
33693
|
const mapped = mapWithBrowserField(file, browserField);
|
|
33707
33694
|
if (mapped) relativeId = mapped + postfix;
|
|
@@ -33713,7 +33700,7 @@ function resolveDeepImport(id, { setResolvedCache, getResolvedCache, dir, data }
|
|
|
33713
33700
|
if (relativeId) {
|
|
33714
33701
|
const resolved = tryFsResolve(path.join(dir, relativeId), options, !exportsField);
|
|
33715
33702
|
if (resolved) {
|
|
33716
|
-
debug$1?.(`[node/deep-import] ${import_picocolors
|
|
33703
|
+
debug$1?.(`[node/deep-import] ${import_picocolors.default.cyan(id)} -> ${import_picocolors.default.dim(resolved)}`);
|
|
33717
33704
|
setResolvedCache(id, resolved, options);
|
|
33718
33705
|
return resolved;
|
|
33719
33706
|
}
|
|
@@ -33722,11 +33709,11 @@ function resolveDeepImport(id, { setResolvedCache, getResolvedCache, dir, data }
|
|
|
33722
33709
|
function tryResolveBrowserMapping(id, importer, options, isFilePath, externalize) {
|
|
33723
33710
|
let res;
|
|
33724
33711
|
const pkg = importer && findNearestPackageData(path.dirname(importer), options.packageCache);
|
|
33725
|
-
if (pkg && isObject(pkg.data.browser)) {
|
|
33712
|
+
if (pkg && isObject$1(pkg.data.browser)) {
|
|
33726
33713
|
const browserMappedPath = mapWithBrowserField(isFilePath ? "./" + slash(path.relative(pkg.dir, id)) : id, pkg.data.browser);
|
|
33727
33714
|
if (browserMappedPath) {
|
|
33728
33715
|
if (res = bareImportRE.test(browserMappedPath) ? tryNodeResolve(browserMappedPath, importer, options, void 0, void 0)?.id : tryFsResolve(path.join(pkg.dir, browserMappedPath), options)) {
|
|
33729
|
-
debug$1?.(`[browser mapped] ${import_picocolors
|
|
33716
|
+
debug$1?.(`[browser mapped] ${import_picocolors.default.cyan(id)} -> ${import_picocolors.default.dim(res)}`);
|
|
33730
33717
|
let result = { id: res };
|
|
33731
33718
|
if (options.idOnly) return result;
|
|
33732
33719
|
if (!options.scan && options.isBuild) {
|
|
@@ -33746,7 +33733,7 @@ function tryResolveBrowserMapping(id, importer, options, isFilePath, externalize
|
|
|
33746
33733
|
}
|
|
33747
33734
|
}
|
|
33748
33735
|
function tryResolveBrowserEntry(dir, data, options) {
|
|
33749
|
-
const browserEntry = typeof data.browser === "string" ? data.browser : isObject(data.browser) && data.browser["."];
|
|
33736
|
+
const browserEntry = typeof data.browser === "string" ? data.browser : isObject$1(data.browser) && data.browser["."];
|
|
33750
33737
|
if (browserEntry) if (!options.isRequire && options.mainFields.includes("module") && typeof data.module === "string" && data.module !== browserEntry) {
|
|
33751
33738
|
const resolvedBrowserEntry = tryFsResolve(path.join(dir, browserEntry), options);
|
|
33752
33739
|
if (resolvedBrowserEntry) if (hasESMSyntax(fs.readFileSync(resolvedBrowserEntry, "utf-8"))) return browserEntry;
|
|
@@ -33933,7 +33920,7 @@ function ssrManifestPlugin() {
|
|
|
33933
33920
|
const code = chunk.code;
|
|
33934
33921
|
let imports = [];
|
|
33935
33922
|
try {
|
|
33936
|
-
imports = parse$
|
|
33923
|
+
imports = parse$3(code)[0].filter((i) => i.n && i.d > -1);
|
|
33937
33924
|
} catch (_e) {
|
|
33938
33925
|
const e$1 = _e;
|
|
33939
33926
|
const loc = numberToPos(code, e$1.idx);
|
|
@@ -34003,7 +33990,7 @@ function licensePlugin() {
|
|
|
34003
33990
|
const chunk = bundle[file];
|
|
34004
33991
|
if (chunk.type === "asset") continue;
|
|
34005
33992
|
for (const moduleId of chunk.moduleIds) {
|
|
34006
|
-
if (moduleId.startsWith("\0") || !isInNodeModules(moduleId)) continue;
|
|
33993
|
+
if (moduleId.startsWith("\0") || !isInNodeModules$1(moduleId)) continue;
|
|
34007
33994
|
const pkgData = findNearestMainPackageData(path.dirname(moduleId), packageCache);
|
|
34008
33995
|
if (!pkgData) continue;
|
|
34009
33996
|
const { name, version = "0.0.0", license } = pkgData.data;
|
|
@@ -34064,7 +34051,6 @@ function findLicenseFile(pkgDir) {
|
|
|
34064
34051
|
|
|
34065
34052
|
//#endregion
|
|
34066
34053
|
//#region src/node/plugins/prepareOutDir.ts
|
|
34067
|
-
var import_picocolors$2 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
34068
34054
|
function prepareOutDirPlugin() {
|
|
34069
34055
|
const rendered = /* @__PURE__ */ new Set();
|
|
34070
34056
|
return {
|
|
@@ -34097,7 +34083,7 @@ function prepareOutDir(outDirs, emptyOutDir, environment) {
|
|
|
34097
34083
|
return "";
|
|
34098
34084
|
}).filter(Boolean), ".git"]);
|
|
34099
34085
|
if (environment.config.build.copyPublicDir && publicDir && fs.existsSync(publicDir)) {
|
|
34100
|
-
if (!areSeparateFolders(outDir, publicDir)) environment.logger.warn(import_picocolors
|
|
34086
|
+
if (!areSeparateFolders(outDir, publicDir)) environment.logger.warn(import_picocolors.default.yellow(`\n${import_picocolors.default.bold(`(!)`)} The public directory feature may not work correctly. outDir ${import_picocolors.default.white(import_picocolors.default.dim(outDir))} and publicDir ${import_picocolors.default.white(import_picocolors.default.dim(publicDir))} are not separate folders.\n`));
|
|
34101
34087
|
copyDir(publicDir, outDir);
|
|
34102
34088
|
}
|
|
34103
34089
|
}
|
|
@@ -34110,7 +34096,6 @@ function areSeparateFolders(a, b) {
|
|
|
34110
34096
|
|
|
34111
34097
|
//#endregion
|
|
34112
34098
|
//#region src/node/build.ts
|
|
34113
|
-
var import_picocolors$1 = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
34114
34099
|
const _buildEnvironmentOptionsDefaults = Object.freeze({
|
|
34115
34100
|
target: "baseline-widely-available",
|
|
34116
34101
|
polyfillModulePreload: true,
|
|
@@ -34265,7 +34250,7 @@ function resolveRolldownOptions(environment, chunkMetadataMap) {
|
|
|
34265
34250
|
const buildOutputOptions = (output = {}) => {
|
|
34266
34251
|
if (output.output) logger.warn("You've set \"rollupOptions.output.output\" in your config. This is deprecated and will override all Vite.js default output options. Please use \"rollupOptions.output\" instead.");
|
|
34267
34252
|
if (output.file) throw new Error("Vite does not support \"rollupOptions.output.file\". Please use \"rollupOptions.output.dir\" and \"rollupOptions.output.entryFileNames\" instead.");
|
|
34268
|
-
if (output.sourcemap) logger.warnOnce(import_picocolors
|
|
34253
|
+
if (output.sourcemap) logger.warnOnce(import_picocolors.default.yellow("Vite does not support \"rollupOptions.output.sourcemap\". Please use \"build.sourcemap\" instead."));
|
|
34269
34254
|
const format$1 = output.format || "es";
|
|
34270
34255
|
const jsExt = ssr && !isSsrTargetWebworkerEnvironment || libOptions ? resolveOutputJsExtension(format$1, findNearestPackageData(root, packageCache)?.data.type) : "js";
|
|
34271
34256
|
return {
|
|
@@ -34300,14 +34285,14 @@ function resolveRolldownOptions(environment, chunkMetadataMap) {
|
|
|
34300
34285
|
async function buildEnvironment(environment) {
|
|
34301
34286
|
const { logger, config } = environment;
|
|
34302
34287
|
const { root, build: options } = config;
|
|
34303
|
-
logger.info(import_picocolors
|
|
34288
|
+
logger.info(import_picocolors.default.cyan(`vite v${VERSION} ${import_picocolors.default.green(`building ${environment.name} environment for ${environment.config.mode}...`)}`));
|
|
34304
34289
|
let bundle;
|
|
34305
34290
|
let startTime;
|
|
34306
34291
|
try {
|
|
34307
34292
|
const chunkMetadataMap = new ChunkMetadataMap();
|
|
34308
34293
|
const rollupOptions = resolveRolldownOptions(environment, chunkMetadataMap);
|
|
34309
34294
|
if (options.watch) {
|
|
34310
|
-
logger.info(import_picocolors
|
|
34295
|
+
logger.info(import_picocolors.default.cyan(`\nwatching for file changes...`));
|
|
34311
34296
|
const resolvedOutDirs = getResolvedOutDirs(root, options.outDir, options.rollupOptions.output);
|
|
34312
34297
|
const emptyOutDir = resolveEmptyOutDir(options.emptyOutDir, root, resolvedOutDirs, logger);
|
|
34313
34298
|
const resolvedChokidarOptions = resolveChokidarOptions({
|
|
@@ -34325,11 +34310,11 @@ async function buildEnvironment(environment) {
|
|
|
34325
34310
|
});
|
|
34326
34311
|
watcher.on("event", (event) => {
|
|
34327
34312
|
if (event.code === "BUNDLE_START") {
|
|
34328
|
-
logger.info(import_picocolors
|
|
34313
|
+
logger.info(import_picocolors.default.cyan(`\nbuild started...`));
|
|
34329
34314
|
chunkMetadataMap.clearResetChunks();
|
|
34330
34315
|
} else if (event.code === "BUNDLE_END") {
|
|
34331
34316
|
event.result.close();
|
|
34332
|
-
logger.info(import_picocolors
|
|
34317
|
+
logger.info(import_picocolors.default.cyan(`built in ${event.duration}ms.`));
|
|
34333
34318
|
} else if (event.code === "ERROR") {
|
|
34334
34319
|
const e$1 = event.error;
|
|
34335
34320
|
enhanceRollupError(e$1);
|
|
@@ -34345,13 +34330,13 @@ async function buildEnvironment(environment) {
|
|
|
34345
34330
|
const res = [];
|
|
34346
34331
|
for (const output of arraify(rollupOptions.output)) res.push(await bundle[options.write ? "write" : "generate"](output));
|
|
34347
34332
|
for (const output of res) for (const chunk of output.output) if (chunk.type === "chunk") injectChunkMetadata(chunkMetadataMap, chunk);
|
|
34348
|
-
logger.info(`${import_picocolors
|
|
34333
|
+
logger.info(`${import_picocolors.default.green(`✓ built in ${displayTime(Date.now() - startTime)}`)}`);
|
|
34349
34334
|
return Array.isArray(rollupOptions.output) ? res : res[0];
|
|
34350
34335
|
} catch (e$1) {
|
|
34351
34336
|
enhanceRollupError(e$1);
|
|
34352
34337
|
clearLine();
|
|
34353
34338
|
if (startTime) {
|
|
34354
|
-
logger.error(`${import_picocolors
|
|
34339
|
+
logger.error(`${import_picocolors.default.red("✗")} Build failed in ${displayTime(Date.now() - startTime)}`);
|
|
34355
34340
|
startTime = void 0;
|
|
34356
34341
|
}
|
|
34357
34342
|
throw e$1;
|
|
@@ -34361,10 +34346,10 @@ async function buildEnvironment(environment) {
|
|
|
34361
34346
|
}
|
|
34362
34347
|
function enhanceRollupError(e$1) {
|
|
34363
34348
|
const stackOnly = extractStack(e$1);
|
|
34364
|
-
let msg = import_picocolors
|
|
34365
|
-
if (e$1.loc && e$1.loc.file && e$1.loc.file !== e$1.id) msg += `\nfile: ${import_picocolors
|
|
34366
|
-
else if (e$1.id) msg += `\nfile: ${import_picocolors
|
|
34367
|
-
if (e$1.frame) msg += `\n` + import_picocolors
|
|
34349
|
+
let msg = import_picocolors.default.red((e$1.plugin ? `[${e$1.plugin}] ` : "") + e$1.message);
|
|
34350
|
+
if (e$1.loc && e$1.loc.file && e$1.loc.file !== e$1.id) msg += `\nfile: ${import_picocolors.default.cyan(`${e$1.loc.file}:${e$1.loc.line}:${e$1.loc.column}` + (e$1.id ? ` (${e$1.id})` : ""))}`;
|
|
34351
|
+
else if (e$1.id) msg += `\nfile: ${import_picocolors.default.cyan(e$1.id + (e$1.loc ? `:${e$1.loc.line}:${e$1.loc.column}` : ""))}`;
|
|
34352
|
+
if (e$1.frame) msg += `\n` + import_picocolors.default.yellow(normalizeCodeFrame(e$1.frame));
|
|
34368
34353
|
e$1.message = msg;
|
|
34369
34354
|
if (stackOnly !== void 0) e$1.stack = `${e$1.message}\n${stackOnly}`;
|
|
34370
34355
|
}
|
|
@@ -34414,7 +34399,7 @@ function resolveBuildOutputs(outputs, libOptions, logger) {
|
|
|
34414
34399
|
format: format$1
|
|
34415
34400
|
}));
|
|
34416
34401
|
}
|
|
34417
|
-
if (libOptions.formats) logger.warn(import_picocolors
|
|
34402
|
+
if (libOptions.formats) logger.warn(import_picocolors.default.yellow("\"build.lib.formats\" will be ignored because \"build.rollupOptions.output\" is already an array format."));
|
|
34418
34403
|
outputs.forEach((output) => {
|
|
34419
34404
|
if ((output.format === "umd" || output.format === "iife") && !output.name) throw new Error("Entries in \"build.rollupOptions.output\" must specify \"name\" when the format is \"umd\" or \"iife\".");
|
|
34420
34405
|
});
|
|
@@ -34449,10 +34434,10 @@ function onRollupLog(level, log$1, environment) {
|
|
|
34449
34434
|
environment.logger.info(message);
|
|
34450
34435
|
return;
|
|
34451
34436
|
case "warn":
|
|
34452
|
-
environment.logger.warn(import_picocolors
|
|
34437
|
+
environment.logger.warn(import_picocolors.default.yellow(message));
|
|
34453
34438
|
return;
|
|
34454
34439
|
case "error":
|
|
34455
|
-
environment.logger.error(import_picocolors
|
|
34440
|
+
environment.logger.error(import_picocolors.default.red(message));
|
|
34456
34441
|
return;
|
|
34457
34442
|
case "debug":
|
|
34458
34443
|
debugLogger?.(message);
|
|
@@ -34833,7 +34818,7 @@ function getChunkSize(chunk, enc) {
|
|
|
34833
34818
|
* @param {import('./index.d.mts').Options} [options]
|
|
34834
34819
|
* @returns {import('./index.d.mts').Middleware}
|
|
34835
34820
|
*/
|
|
34836
|
-
function build_default
|
|
34821
|
+
function build_default({ threshold = 1024, level = -1, brotli = false, gzip: gzip$1 = true, mimes: mimes$1 = MIMES } = {}) {
|
|
34837
34822
|
const brotliOpts = typeof brotli === "object" && brotli || {};
|
|
34838
34823
|
const gzipOpts = typeof gzip$1 === "object" && gzip$1 || {};
|
|
34839
34824
|
if (!zlib.createBrotliCompress) brotli = false;
|
|
@@ -34903,8 +34888,6 @@ function build_default$1({ threshold = 1024, level = -1, brotli = false, gzip: g
|
|
|
34903
34888
|
|
|
34904
34889
|
//#endregion
|
|
34905
34890
|
//#region src/node/preview.ts
|
|
34906
|
-
var import_connect = /* @__PURE__ */ __toESM(require_connect(), 1);
|
|
34907
|
-
var import_lib = /* @__PURE__ */ __toESM(require_lib$1(), 1);
|
|
34908
34891
|
function resolvePreviewOptions(preview$1, server) {
|
|
34909
34892
|
return {
|
|
34910
34893
|
port: preview$1?.port ?? DEFAULT_PREVIEW_PORT,
|
|
@@ -34977,10 +34960,10 @@ async function preview(inlineConfig = {}) {
|
|
|
34977
34960
|
for (const hook of config.getSortedPluginHooks("configurePreviewServer")) postHooks.push(await hook.call(configurePreviewServerContext, server));
|
|
34978
34961
|
const { proxy } = config.preview;
|
|
34979
34962
|
if (proxy) app.use(proxyMiddleware(httpServer, proxy, config));
|
|
34980
|
-
app.use(build_default
|
|
34963
|
+
app.use(build_default());
|
|
34981
34964
|
if (config.base !== "/") app.use(baseMiddleware(config.rawBase, false));
|
|
34982
34965
|
const headers = config.preview.headers;
|
|
34983
|
-
const viteAssetMiddleware = (...args) => build_default(distDir, {
|
|
34966
|
+
const viteAssetMiddleware = (...args) => build_default$1(distDir, {
|
|
34984
34967
|
etag: true,
|
|
34985
34968
|
dev: true,
|
|
34986
34969
|
extensions: [],
|
|
@@ -35220,7 +35203,6 @@ function idToPathAndNamespace(id) {
|
|
|
35220
35203
|
|
|
35221
35204
|
//#endregion
|
|
35222
35205
|
//#region src/node/config.ts
|
|
35223
|
-
var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
|
|
35224
35206
|
const debug = createDebugger("vite:config", { depth: 10 });
|
|
35225
35207
|
const promisifiedRealpath = promisify(fs.realpath);
|
|
35226
35208
|
const SYMBOL_RESOLVED_CONFIG = Symbol("vite:resolved-config");
|
|
@@ -35275,7 +35257,7 @@ const configDefaults = Object.freeze({
|
|
|
35275
35257
|
importGlobRestoreExtension: false,
|
|
35276
35258
|
renderBuiltUrl: void 0,
|
|
35277
35259
|
hmrPartialAccept: false,
|
|
35278
|
-
enableNativePlugin: process.env._VITE_TEST_JS_PLUGIN ? false : "
|
|
35260
|
+
enableNativePlugin: process.env._VITE_TEST_JS_PLUGIN ? false : "v2",
|
|
35279
35261
|
bundledDev: false
|
|
35280
35262
|
},
|
|
35281
35263
|
future: {
|
|
@@ -35314,7 +35296,7 @@ const configDefaults = Object.freeze({
|
|
|
35314
35296
|
function resolveDevEnvironmentOptions(dev$1, environmentName, consumer, preTransformRequest$1) {
|
|
35315
35297
|
const resolved = mergeWithDefaults({
|
|
35316
35298
|
...configDefaults.dev,
|
|
35317
|
-
sourcemapIgnoreList: isInNodeModules,
|
|
35299
|
+
sourcemapIgnoreList: isInNodeModules$1,
|
|
35318
35300
|
preTransformRequests: preTransformRequest$1 ?? consumer === "client",
|
|
35319
35301
|
createEnvironment: environmentName === "client" ? defaultCreateClientDevEnvironment : defaultCreateDevEnvironment,
|
|
35320
35302
|
recoverable: consumer === "client",
|
|
@@ -35606,7 +35588,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
|
35606
35588
|
const resolvedBase = config.base === "" || config.base === "./" ? !isBuild || config.build?.ssr ? "/" : "./" : resolveBaseUrl(config.base, isBuild, logger);
|
|
35607
35589
|
const pkgDir = findNearestPackageData(resolvedRoot, packageCache)?.dir;
|
|
35608
35590
|
const cacheDir = normalizePath(config.cacheDir ? path.resolve(resolvedRoot, config.cacheDir) : pkgDir ? path.join(pkgDir, `node_modules/.vite`) : path.join(resolvedRoot, `.vite`));
|
|
35609
|
-
const assetsFilter = config.assetsInclude && (!Array.isArray(config.assetsInclude) || config.assetsInclude.length) ? createFilter(config.assetsInclude) : () => false;
|
|
35591
|
+
const assetsFilter = config.assetsInclude && (!Array.isArray(config.assetsInclude) || config.assetsInclude.length) ? createFilter$1(config.assetsInclude) : () => false;
|
|
35610
35592
|
const { publicDir } = config;
|
|
35611
35593
|
const resolvedPublicDir = publicDir !== false && publicDir !== "" ? normalizePath(path.resolve(resolvedRoot, typeof publicDir === "string" ? publicDir : configDefaults.publicDir)) : "";
|
|
35612
35594
|
const server = resolveServerOptions(resolvedRoot, config.server, logger);
|
|
@@ -35809,8 +35791,9 @@ assetFileNames isn't equal for every build.rollupOptions.output. A single patter
|
|
|
35809
35791
|
function resolveNativePluginEnabledLevel(enableNativePlugin) {
|
|
35810
35792
|
switch (enableNativePlugin) {
|
|
35811
35793
|
case "resolver": return 0;
|
|
35812
|
-
case "v1":
|
|
35813
|
-
case
|
|
35794
|
+
case "v1": return 1;
|
|
35795
|
+
case "v2":
|
|
35796
|
+
case true: return 2;
|
|
35814
35797
|
case false: return -1;
|
|
35815
35798
|
default: return -1;
|
|
35816
35799
|
}
|
|
@@ -35874,7 +35857,7 @@ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cw
|
|
|
35874
35857
|
const { configExport, dependencies } = await (configLoader === "bundle" ? bundleAndLoadConfigFile : configLoader === "runner" ? runnerImportConfigFile : nativeImportConfigFile)(resolvedPath);
|
|
35875
35858
|
debug?.(`config file loaded in ${getTime()}`);
|
|
35876
35859
|
const config = await (typeof configExport === "function" ? configExport(configEnv) : configExport);
|
|
35877
|
-
if (!isObject(config)) throw new Error(`config must export or return an object.`);
|
|
35860
|
+
if (!isObject$1(config)) throw new Error(`config must export or return an object.`);
|
|
35878
35861
|
return {
|
|
35879
35862
|
path: normalizePath(resolvedPath),
|
|
35880
35863
|
config,
|
|
@@ -35915,6 +35898,7 @@ async function bundleConfigFile(fileName, isESM) {
|
|
|
35915
35898
|
const filenameVarName = "__vite_injected_original_filename";
|
|
35916
35899
|
const importMetaUrlVarName = "__vite_injected_original_import_meta_url";
|
|
35917
35900
|
const importMetaResolveVarName = "__vite_injected_original_import_meta_resolve";
|
|
35901
|
+
const importMetaResolveRegex = /import\.meta\s*\.\s*resolve/;
|
|
35918
35902
|
const bundle = await rolldown({
|
|
35919
35903
|
input: fileName,
|
|
35920
35904
|
platform: "node",
|
|
@@ -35971,7 +35955,7 @@ async function bundleConfigFile(fileName, isESM) {
|
|
|
35971
35955
|
filter: { id: /\.[cm]?[jt]s$/ },
|
|
35972
35956
|
async handler(code, id) {
|
|
35973
35957
|
let injectValues = `const ${dirnameVarName} = ${JSON.stringify(path.dirname(id))};const ${filenameVarName} = ${JSON.stringify(id)};const ${importMetaUrlVarName} = ${JSON.stringify(pathToFileURL(id).href)};`;
|
|
35974
|
-
if (
|
|
35958
|
+
if (importMetaResolveRegex.test(code)) if (isESM) {
|
|
35975
35959
|
if (!importMetaResolverRegistered) {
|
|
35976
35960
|
importMetaResolverRegistered = true;
|
|
35977
35961
|
await createImportMetaResolver();
|
|
@@ -36147,4 +36131,4 @@ const parseAstAsync$1 = parseAstAsync;
|
|
|
36147
36131
|
const esbuildVersion = "0.25.0";
|
|
36148
36132
|
|
|
36149
36133
|
//#endregion
|
|
36150
|
-
export { discoverProjectDependencies as $, createBuilder as A, createServerModuleRunner as At, resolveRolldownOptions as B, isCSSRequest as Bt, isRunnableDevEnvironment as C, isFileServingAllowed as Ct, buildEnvironmentOptionsDefaults as D, searchForWorkspaceRoot as Dt, build as E, preprocessCSS as Et, resolveBuildEnvironmentOptions as F, transformWithOxc as Ft, toOutputFilePathWithoutRuntime as G, rollupVersion as Gt, toOutputFilePathInCss as H, mergeConfig as Ht, resolveBuildOutputs as I, transformWithEsbuild as It, cleanupDepsCacheStaleDirs as J, addManuallyIncludedOptimizeDeps as K, withFilter as Kt, resolveBuildPlugins as L, perEnvironmentState as Lt, enhanceRollupError as M, buildErrorMessage as Mt, injectEnvironmentToHooks as N, loadEnv as Nt, builderOptionsDefaults as O, createIdResolver as Ot, onRollupLog as P, resolveEnvPrefix as Pt, depsLogString as Q, resolveBuilderOptions as R, perEnvironmentPlugin as Rt, createRunnableDevEnvironment as S, isFileLoadingAllowed as St, ChunkMetadataMap as T, formatPostcssSourceMap as Tt, toOutputFilePathInHtml as U, normalizePath as Ut, resolveUserExternal as V, mergeAlias as Vt, toOutputFilePathInJS as W, rolldownVersion as Wt, createIsOptimizedDepUrl as X, createIsOptimizedDepFile as Y, depsFromOptimizedDepInfo as Z, resolveDevEnvironmentOptions as _, resolveServerOptions as _t, parse as a, loadCachedDepOptimizationMetadata as at, preview as b, send as bt, parseSync as c, optimizedDepInfoFromFile as ct, defineConfig as d, runOptimizeDeps as dt, extractExportsData as et, getDefaultEnvironmentOptions as f, toDiscoveredDependencies as ft, resolveConfig as g, createServerCloseFn as gt, resolveBaseUrl as h, createServer$2 as ht, minifySync as i, isDepOptimizationDisabled as it, createToImportMetaURLBasedRelativeRuntime as j, createServerModuleRunnerTransport as jt, clearLine as k, ssrTransform as kt, createFetchableDevEnvironment as l, optimizedDepInfoFromId as lt, loadConfigFromFile as m, _createServer as mt, esmExternalRequirePlugin as n, getOptimizedDepPath as nt, parseAst$1 as o, optimizeDeps as ot, isResolvedConfig as p, createServerHotChannel as pt, addOptimizedDepInfo as q, minify as r, initDepsOptimizerMetadata as rt, parseAstAsync$1 as s, optimizeExplicitEnvironmentDeps as st, esbuildVersion as t, getDepsCacheDir as tt, isFetchableDevEnvironment as u, optimizedDepNeedsInterop as ut, sortUserPlugins as v, restartServerWithUrls as vt, BuildEnvironment as w, fetchModule as wt, resolvePreviewOptions as x, DevEnvironment as xt, runnerImport as y, serverConfigDefaults as yt, resolveLibFilename as z, createFilter as zt };
|
|
36134
|
+
export { discoverProjectDependencies as $, createBuilder as A, createServerModuleRunner as At, resolveRolldownOptions as B, isCSSRequest as Bt, isRunnableDevEnvironment as C, isFileServingAllowed as Ct, buildEnvironmentOptionsDefaults as D, searchForWorkspaceRoot as Dt, build as E, preprocessCSS as Et, resolveBuildEnvironmentOptions as F, transformWithOxc as Ft, toOutputFilePathWithoutRuntime as G, rollupVersion as Gt, toOutputFilePathInCss as H, mergeConfig as Ht, resolveBuildOutputs as I, transformWithEsbuild as It, cleanupDepsCacheStaleDirs as J, addManuallyIncludedOptimizeDeps as K, withFilter as Kt, resolveBuildPlugins as L, perEnvironmentState as Lt, enhanceRollupError as M, buildErrorMessage as Mt, injectEnvironmentToHooks as N, loadEnv as Nt, builderOptionsDefaults as O, createIdResolver as Ot, onRollupLog as P, resolveEnvPrefix as Pt, depsLogString as Q, resolveBuilderOptions as R, perEnvironmentPlugin as Rt, createRunnableDevEnvironment as S, isFileLoadingAllowed as St, ChunkMetadataMap as T, formatPostcssSourceMap as Tt, toOutputFilePathInHtml as U, normalizePath as Ut, resolveUserExternal as V, mergeAlias as Vt, toOutputFilePathInJS as W, rolldownVersion as Wt, createIsOptimizedDepUrl as X, createIsOptimizedDepFile as Y, depsFromOptimizedDepInfo as Z, resolveDevEnvironmentOptions as _, resolveServerOptions as _t, parse as a, loadCachedDepOptimizationMetadata as at, preview as b, send as bt, parseSync as c, optimizedDepInfoFromFile as ct, defineConfig as d, runOptimizeDeps as dt, extractExportsData as et, getDefaultEnvironmentOptions as f, toDiscoveredDependencies as ft, resolveConfig as g, createServerCloseFn as gt, resolveBaseUrl as h, createServer$2 as ht, minifySync as i, isDepOptimizationDisabled as it, createToImportMetaURLBasedRelativeRuntime as j, createServerModuleRunnerTransport as jt, clearLine as k, ssrTransform as kt, createFetchableDevEnvironment as l, optimizedDepInfoFromId as lt, loadConfigFromFile as m, _createServer as mt, esmExternalRequirePlugin as n, getOptimizedDepPath as nt, parseAst$1 as o, optimizeDeps as ot, isResolvedConfig as p, createServerHotChannel as pt, addOptimizedDepInfo as q, minify as r, initDepsOptimizerMetadata as rt, parseAstAsync$1 as s, optimizeExplicitEnvironmentDeps as st, esbuildVersion as t, getDepsCacheDir as tt, isFetchableDevEnvironment as u, optimizedDepNeedsInterop as ut, sortUserPlugins as v, restartServerWithUrls as vt, BuildEnvironment as w, fetchModule as wt, resolvePreviewOptions as x, DevEnvironment as xt, runnerImport as y, serverConfigDefaults as yt, resolveLibFilename as z, createFilter$1 as zt };
|