vite 6.0.0-beta.7 → 6.0.0-beta.8
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/node/chunks/{dep-C35rJP-t.js → dep-DUn1iy3F.js} +1 -1
- package/dist/node/chunks/{dep-Vd7gFLqj.js → dep-Ddvoc4zx.js} +404 -612
- package/dist/node/chunks/{dep-BLM335V-.js → dep-qU9-vqRp.js} +1 -1
- package/dist/node/cli.js +5 -5
- package/dist/node/constants.js +9 -1
- package/dist/node/index.d.ts +8 -31
- package/dist/node/index.js +2 -2
- package/dist/node-cjs/publicUtils.cjs +1 -3
- package/package.json +1 -1
@@ -7,7 +7,7 @@ import { promisify, format, inspect } from 'node:util';
|
|
7
7
|
import { performance } from 'node:perf_hooks';
|
8
8
|
import require$$0$3, { createRequire, builtinModules } from 'node:module';
|
9
9
|
import esbuild, { transform, formatMessages, build as build$3 } from 'esbuild';
|
10
|
-
import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, wildcardHosts, loopbackHosts, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, DEFAULT_ASSETS_INLINE_LIMIT, ENV_ENTRY, SPECIAL_QUERY_RE, DEP_VERSION_RE, JS_TYPES_RE, KNOWN_ASSET_TYPES, CSS_LANGS_RE, METADATA_FILENAME, ESBUILD_MODULES_TARGET, ERR_OPTIMIZE_DEPS_PROCESSING_ERROR, ERR_OUTDATED_OPTIMIZED_DEP, ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR, VITE_PACKAGE_DIR, CLIENT_DIR, DEFAULT_DEV_PORT, VERSION, ROLLUP_HOOKS, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS } from '../constants.js';
|
10
|
+
import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, wildcardHosts, loopbackHosts, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, DEFAULT_ASSETS_INLINE_LIMIT, ENV_ENTRY, SPECIAL_QUERY_RE, DEP_VERSION_RE, DEV_PROD_CONDITION, JS_TYPES_RE, KNOWN_ASSET_TYPES, CSS_LANGS_RE, METADATA_FILENAME, ESBUILD_MODULES_TARGET, ERR_OPTIMIZE_DEPS_PROCESSING_ERROR, ERR_OUTDATED_OPTIMIZED_DEP, ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR, VITE_PACKAGE_DIR, CLIENT_DIR, DEFAULT_DEV_PORT, VERSION, ROLLUP_HOOKS, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_CONDITIONS, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEFAULT_EXTERNAL_CONDITIONS } from '../constants.js';
|
11
11
|
import * as sysPath from 'path';
|
12
12
|
import sysPath__default, { posix, win32, isAbsolute, resolve as resolve$2, relative as relative$1, basename as basename$1, extname, dirname as dirname$1, join, sep } from 'path';
|
13
13
|
import require$$0$1, { existsSync, readFileSync, statSync, lstatSync, unwatchFile, watchFile, watch as watch$1, stat as stat$1, readdirSync } from 'fs';
|
@@ -9651,14 +9651,24 @@ function loadPackageData(pkgPath) {
|
|
9651
9651
|
function getResolveCacheKey(key, options) {
|
9652
9652
|
return [
|
9653
9653
|
key,
|
9654
|
-
options.webCompatible ? "1" : "0",
|
9655
9654
|
options.isRequire ? "1" : "0",
|
9656
9655
|
options.conditions.join("_"),
|
9657
|
-
options.overrideConditions?.join("_") || "",
|
9658
9656
|
options.extensions.join("_"),
|
9659
9657
|
options.mainFields.join("_")
|
9660
9658
|
].join("|");
|
9661
9659
|
}
|
9660
|
+
function findNearestNodeModules(basedir) {
|
9661
|
+
while (basedir) {
|
9662
|
+
const pkgPath = path.join(basedir, "node_modules");
|
9663
|
+
if (tryStatSync(pkgPath)?.isDirectory()) {
|
9664
|
+
return pkgPath;
|
9665
|
+
}
|
9666
|
+
const nextBasedir = path.dirname(basedir);
|
9667
|
+
if (nextBasedir === basedir) break;
|
9668
|
+
basedir = nextBasedir;
|
9669
|
+
}
|
9670
|
+
return null;
|
9671
|
+
}
|
9662
9672
|
function watchPackageDataPlugin(packageCache) {
|
9663
9673
|
const watchQueue = /* @__PURE__ */ new Set();
|
9664
9674
|
const watchedDirs = /* @__PURE__ */ new Set();
|
@@ -9791,7 +9801,7 @@ const DEBUG = process.env.DEBUG;
|
|
9791
9801
|
function createDebugger(namespace, options = {}) {
|
9792
9802
|
const log = debug$e(namespace);
|
9793
9803
|
const { onlyWhenFocused, depth } = options;
|
9794
|
-
if (depth && log.inspectOpts.depth == null) {
|
9804
|
+
if (depth && log.inspectOpts && log.inspectOpts.depth == null) {
|
9795
9805
|
log.inspectOpts.depth = options.depth;
|
9796
9806
|
}
|
9797
9807
|
let enabled = log.enabled;
|
@@ -15820,283 +15830,6 @@ function hasESMSyntax(code, opts = {}) {
|
|
15820
15830
|
return ESM_RE.test(code);
|
15821
15831
|
}
|
15822
15832
|
|
15823
|
-
const commonFsUtils = {
|
15824
|
-
existsSync: fs__default.existsSync,
|
15825
|
-
isDirectory,
|
15826
|
-
tryResolveRealFile,
|
15827
|
-
tryResolveRealFileWithExtensions,
|
15828
|
-
tryResolveRealFileOrType
|
15829
|
-
};
|
15830
|
-
const cachedFsUtilsMap = /* @__PURE__ */ new WeakMap();
|
15831
|
-
function getFsUtils(config) {
|
15832
|
-
let fsUtils = cachedFsUtilsMap.get(config);
|
15833
|
-
if (!fsUtils) {
|
15834
|
-
if (config.command !== "serve" || config.server.fs.cachedChecks !== true || config.server.watch?.ignored || process.versions.pnp) {
|
15835
|
-
fsUtils = commonFsUtils;
|
15836
|
-
} else if (!config.resolve.preserveSymlinks && config.root !== getRealPath(config.root)) {
|
15837
|
-
fsUtils = commonFsUtils;
|
15838
|
-
} else {
|
15839
|
-
fsUtils = createCachedFsUtils(config);
|
15840
|
-
}
|
15841
|
-
cachedFsUtilsMap.set(config, fsUtils);
|
15842
|
-
}
|
15843
|
-
return fsUtils;
|
15844
|
-
}
|
15845
|
-
function readDirCacheSync(file) {
|
15846
|
-
let dirents;
|
15847
|
-
try {
|
15848
|
-
dirents = fs__default.readdirSync(file, { withFileTypes: true });
|
15849
|
-
} catch {
|
15850
|
-
return;
|
15851
|
-
}
|
15852
|
-
return direntsToDirentMap(dirents);
|
15853
|
-
}
|
15854
|
-
function direntsToDirentMap(fsDirents) {
|
15855
|
-
const dirents = /* @__PURE__ */ new Map();
|
15856
|
-
for (const dirent of fsDirents) {
|
15857
|
-
const type = dirent.isDirectory() ? "directory" : dirent.isSymbolicLink() ? "symlink" : dirent.isFile() ? "file" : void 0;
|
15858
|
-
if (type) {
|
15859
|
-
dirents.set(dirent.name, { type });
|
15860
|
-
}
|
15861
|
-
}
|
15862
|
-
return dirents;
|
15863
|
-
}
|
15864
|
-
function ensureFileMaybeSymlinkIsResolved(direntCache, filePath) {
|
15865
|
-
if (direntCache.type !== "file_maybe_symlink") return;
|
15866
|
-
const isSymlink = fs__default.lstatSync(filePath, { throwIfNoEntry: false })?.isSymbolicLink();
|
15867
|
-
direntCache.type = isSymlink === void 0 ? "error" : isSymlink ? "symlink" : "file";
|
15868
|
-
}
|
15869
|
-
function pathUntilPart(root, parts, i) {
|
15870
|
-
let p = root;
|
15871
|
-
for (let k = 0; k < i; k++) p += "/" + parts[k];
|
15872
|
-
return p;
|
15873
|
-
}
|
15874
|
-
function createCachedFsUtils(config) {
|
15875
|
-
const root = config.root;
|
15876
|
-
const rootDirPath = `${root}/`;
|
15877
|
-
const rootCache = { type: "directory" };
|
15878
|
-
const getDirentCacheSync = (parts) => {
|
15879
|
-
let direntCache = rootCache;
|
15880
|
-
for (let i = 0; i < parts.length; i++) {
|
15881
|
-
if (direntCache.type === "directory") {
|
15882
|
-
let dirPath;
|
15883
|
-
if (!direntCache.dirents) {
|
15884
|
-
dirPath = pathUntilPart(root, parts, i);
|
15885
|
-
const dirents = readDirCacheSync(dirPath);
|
15886
|
-
if (!dirents) {
|
15887
|
-
direntCache.type = "error";
|
15888
|
-
return;
|
15889
|
-
}
|
15890
|
-
direntCache.dirents = dirents;
|
15891
|
-
}
|
15892
|
-
const nextDirentCache = direntCache.dirents.get(parts[i]);
|
15893
|
-
if (!nextDirentCache) {
|
15894
|
-
return;
|
15895
|
-
}
|
15896
|
-
if (nextDirentCache.type === "directory_maybe_symlink") {
|
15897
|
-
dirPath ??= pathUntilPart(root, parts, i + 1);
|
15898
|
-
const isSymlink = fs__default.lstatSync(dirPath, { throwIfNoEntry: false })?.isSymbolicLink();
|
15899
|
-
nextDirentCache.type = isSymlink ? "symlink" : "directory";
|
15900
|
-
}
|
15901
|
-
direntCache = nextDirentCache;
|
15902
|
-
} else if (direntCache.type === "symlink") {
|
15903
|
-
return direntCache;
|
15904
|
-
} else if (direntCache.type === "error") {
|
15905
|
-
return direntCache;
|
15906
|
-
} else {
|
15907
|
-
if (i !== parts.length - 1) {
|
15908
|
-
return;
|
15909
|
-
}
|
15910
|
-
if (direntCache.type === "file_maybe_symlink") {
|
15911
|
-
ensureFileMaybeSymlinkIsResolved(
|
15912
|
-
direntCache,
|
15913
|
-
pathUntilPart(root, parts, i)
|
15914
|
-
);
|
15915
|
-
return direntCache;
|
15916
|
-
} else if (direntCache.type === "file") {
|
15917
|
-
return direntCache;
|
15918
|
-
} else {
|
15919
|
-
return;
|
15920
|
-
}
|
15921
|
-
}
|
15922
|
-
}
|
15923
|
-
return direntCache;
|
15924
|
-
};
|
15925
|
-
function getDirentCacheFromPath(normalizedFile) {
|
15926
|
-
if (normalizedFile[normalizedFile.length - 1] === "/") {
|
15927
|
-
normalizedFile = normalizedFile.slice(0, -1);
|
15928
|
-
}
|
15929
|
-
if (normalizedFile === root) {
|
15930
|
-
return rootCache;
|
15931
|
-
}
|
15932
|
-
if (!normalizedFile.startsWith(rootDirPath)) {
|
15933
|
-
return void 0;
|
15934
|
-
}
|
15935
|
-
const pathFromRoot = normalizedFile.slice(rootDirPath.length);
|
15936
|
-
const parts = pathFromRoot.split("/");
|
15937
|
-
const direntCache = getDirentCacheSync(parts);
|
15938
|
-
if (!direntCache || direntCache.type === "error") {
|
15939
|
-
return false;
|
15940
|
-
}
|
15941
|
-
return direntCache;
|
15942
|
-
}
|
15943
|
-
function onPathAdd(file, type) {
|
15944
|
-
const direntCache = getDirentCacheFromPath(
|
15945
|
-
normalizePath$1(path.dirname(file))
|
15946
|
-
);
|
15947
|
-
if (direntCache && direntCache.type === "directory" && direntCache.dirents) {
|
15948
|
-
direntCache.dirents.set(path.basename(file), { type });
|
15949
|
-
}
|
15950
|
-
}
|
15951
|
-
function onPathUnlink(file) {
|
15952
|
-
const direntCache = getDirentCacheFromPath(
|
15953
|
-
normalizePath$1(path.dirname(file))
|
15954
|
-
);
|
15955
|
-
if (direntCache && direntCache.type === "directory" && direntCache.dirents) {
|
15956
|
-
direntCache.dirents.delete(path.basename(file));
|
15957
|
-
}
|
15958
|
-
}
|
15959
|
-
return {
|
15960
|
-
existsSync(file) {
|
15961
|
-
if (isInNodeModules$1(file)) {
|
15962
|
-
return fs__default.existsSync(file);
|
15963
|
-
}
|
15964
|
-
const normalizedFile = normalizePath$1(file);
|
15965
|
-
const direntCache = getDirentCacheFromPath(normalizedFile);
|
15966
|
-
if (direntCache === void 0 || direntCache && direntCache.type === "symlink") {
|
15967
|
-
return fs__default.existsSync(file);
|
15968
|
-
}
|
15969
|
-
return !!direntCache;
|
15970
|
-
},
|
15971
|
-
tryResolveRealFile(file, preserveSymlinks) {
|
15972
|
-
if (isInNodeModules$1(file)) {
|
15973
|
-
return tryResolveRealFile(file, preserveSymlinks);
|
15974
|
-
}
|
15975
|
-
const normalizedFile = normalizePath$1(file);
|
15976
|
-
const direntCache = getDirentCacheFromPath(normalizedFile);
|
15977
|
-
if (direntCache === void 0 || direntCache && direntCache.type === "symlink") {
|
15978
|
-
return tryResolveRealFile(file, preserveSymlinks);
|
15979
|
-
}
|
15980
|
-
if (!direntCache || direntCache.type === "directory") {
|
15981
|
-
return;
|
15982
|
-
}
|
15983
|
-
return normalizedFile;
|
15984
|
-
},
|
15985
|
-
tryResolveRealFileWithExtensions(file, extensions, preserveSymlinks) {
|
15986
|
-
if (isInNodeModules$1(file)) {
|
15987
|
-
return tryResolveRealFileWithExtensions(
|
15988
|
-
file,
|
15989
|
-
extensions,
|
15990
|
-
preserveSymlinks
|
15991
|
-
);
|
15992
|
-
}
|
15993
|
-
const normalizedFile = normalizePath$1(file);
|
15994
|
-
const dirPath = path.posix.dirname(normalizedFile);
|
15995
|
-
const direntCache = getDirentCacheFromPath(dirPath);
|
15996
|
-
if (direntCache === void 0 || direntCache && direntCache.type === "symlink") {
|
15997
|
-
return tryResolveRealFileWithExtensions(
|
15998
|
-
file,
|
15999
|
-
extensions,
|
16000
|
-
preserveSymlinks
|
16001
|
-
);
|
16002
|
-
}
|
16003
|
-
if (!direntCache || direntCache.type !== "directory") {
|
16004
|
-
return;
|
16005
|
-
}
|
16006
|
-
if (!direntCache.dirents) {
|
16007
|
-
const dirents = readDirCacheSync(dirPath);
|
16008
|
-
if (!dirents) {
|
16009
|
-
direntCache.type = "error";
|
16010
|
-
return;
|
16011
|
-
}
|
16012
|
-
direntCache.dirents = dirents;
|
16013
|
-
}
|
16014
|
-
const base = path.posix.basename(normalizedFile);
|
16015
|
-
for (const ext of extensions) {
|
16016
|
-
const fileName = base + ext;
|
16017
|
-
const fileDirentCache = direntCache.dirents.get(fileName);
|
16018
|
-
if (fileDirentCache) {
|
16019
|
-
const filePath = dirPath + "/" + fileName;
|
16020
|
-
ensureFileMaybeSymlinkIsResolved(fileDirentCache, filePath);
|
16021
|
-
if (fileDirentCache.type === "symlink") {
|
16022
|
-
return tryResolveRealFile(filePath, preserveSymlinks);
|
16023
|
-
}
|
16024
|
-
if (fileDirentCache.type === "file") {
|
16025
|
-
return filePath;
|
16026
|
-
}
|
16027
|
-
}
|
16028
|
-
}
|
16029
|
-
},
|
16030
|
-
tryResolveRealFileOrType(file, preserveSymlinks) {
|
16031
|
-
if (isInNodeModules$1(file)) {
|
16032
|
-
return tryResolveRealFileOrType(file, preserveSymlinks);
|
16033
|
-
}
|
16034
|
-
const normalizedFile = normalizePath$1(file);
|
16035
|
-
const direntCache = getDirentCacheFromPath(normalizedFile);
|
16036
|
-
if (direntCache === void 0 || direntCache && direntCache.type === "symlink") {
|
16037
|
-
return tryResolveRealFileOrType(file, preserveSymlinks);
|
16038
|
-
}
|
16039
|
-
if (!direntCache) {
|
16040
|
-
return;
|
16041
|
-
}
|
16042
|
-
if (direntCache.type === "directory") {
|
16043
|
-
return { type: "directory" };
|
16044
|
-
}
|
16045
|
-
return { path: normalizedFile, type: "file" };
|
16046
|
-
},
|
16047
|
-
isDirectory(dirPath) {
|
16048
|
-
if (isInNodeModules$1(dirPath)) {
|
16049
|
-
return isDirectory(dirPath);
|
16050
|
-
}
|
16051
|
-
const direntCache = getDirentCacheFromPath(normalizePath$1(dirPath));
|
16052
|
-
if (direntCache === void 0 || direntCache && direntCache.type === "symlink") {
|
16053
|
-
return isDirectory(dirPath);
|
16054
|
-
}
|
16055
|
-
return direntCache && direntCache.type === "directory";
|
16056
|
-
},
|
16057
|
-
initWatcher(watcher) {
|
16058
|
-
watcher.on("add", (file) => {
|
16059
|
-
onPathAdd(file, "file_maybe_symlink");
|
16060
|
-
});
|
16061
|
-
watcher.on("addDir", (dir) => {
|
16062
|
-
onPathAdd(dir, "directory_maybe_symlink");
|
16063
|
-
});
|
16064
|
-
watcher.on("unlink", onPathUnlink);
|
16065
|
-
watcher.on("unlinkDir", onPathUnlink);
|
16066
|
-
}
|
16067
|
-
};
|
16068
|
-
}
|
16069
|
-
function tryResolveRealFile(file, preserveSymlinks) {
|
16070
|
-
const stat = tryStatSync(file);
|
16071
|
-
if (stat?.isFile()) return getRealPath(file, preserveSymlinks);
|
16072
|
-
}
|
16073
|
-
function tryResolveRealFileWithExtensions(filePath, extensions, preserveSymlinks) {
|
16074
|
-
for (const ext of extensions) {
|
16075
|
-
const res = tryResolveRealFile(filePath + ext, preserveSymlinks);
|
16076
|
-
if (res) return res;
|
16077
|
-
}
|
16078
|
-
}
|
16079
|
-
function tryResolveRealFileOrType(file, preserveSymlinks) {
|
16080
|
-
const fileStat = tryStatSync(file);
|
16081
|
-
if (fileStat?.isFile()) {
|
16082
|
-
return { path: getRealPath(file, preserveSymlinks), type: "file" };
|
16083
|
-
}
|
16084
|
-
if (fileStat?.isDirectory()) {
|
16085
|
-
return { type: "directory" };
|
16086
|
-
}
|
16087
|
-
return;
|
16088
|
-
}
|
16089
|
-
function getRealPath(resolved, preserveSymlinks) {
|
16090
|
-
if (!preserveSymlinks) {
|
16091
|
-
resolved = safeRealpathSync(resolved);
|
16092
|
-
}
|
16093
|
-
return normalizePath$1(resolved);
|
16094
|
-
}
|
16095
|
-
function isDirectory(path2) {
|
16096
|
-
const stat = tryStatSync(path2);
|
16097
|
-
return stat?.isDirectory() ?? false;
|
16098
|
-
}
|
16099
|
-
|
16100
15833
|
const debug$b = createDebugger("vite:external");
|
16101
15834
|
const isExternalCache = /* @__PURE__ */ new WeakMap();
|
16102
15835
|
function shouldExternalize(environment, id, importer) {
|
@@ -16118,7 +15851,7 @@ function isConfiguredAsExternal(environment, id, importer) {
|
|
16118
15851
|
}
|
16119
15852
|
function createIsConfiguredAsExternal(environment) {
|
16120
15853
|
const { config } = environment;
|
16121
|
-
const { root, resolve
|
15854
|
+
const { root, resolve } = config;
|
16122
15855
|
const { external, noExternal } = resolve;
|
16123
15856
|
const noExternalFilter = typeof noExternal !== "boolean" && !(Array.isArray(noExternal) && noExternal.length === 0) && createFilter(void 0, noExternal, { resolve: false });
|
16124
15857
|
const targetConditions = resolve.externalConditions || [];
|
@@ -16127,8 +15860,7 @@ function createIsConfiguredAsExternal(environment) {
|
|
16127
15860
|
root,
|
16128
15861
|
isProduction: false,
|
16129
15862
|
isBuild: true,
|
16130
|
-
conditions: targetConditions
|
16131
|
-
webCompatible
|
15863
|
+
conditions: targetConditions
|
16132
15864
|
};
|
16133
15865
|
const isExternalizable = (id, importer, configuredAsExternal) => {
|
16134
15866
|
if (!bareImportRE.test(id) || id.includes("\0")) {
|
@@ -16237,12 +15969,10 @@ function resolvePlugin(resolveOptions, environmentsOptions) {
|
|
16237
15969
|
const options = {
|
16238
15970
|
isRequire,
|
16239
15971
|
...environmentResolveOptions,
|
16240
|
-
webCompatible: currentEnvironmentOptions.webCompatible,
|
16241
15972
|
...resolveOptions,
|
16242
15973
|
// plugin options + resolve options overrides
|
16243
15974
|
scan: resolveOpts?.scan ?? resolveOptions.scan
|
16244
15975
|
};
|
16245
|
-
const depsOptimizerOptions = this.environment.config.optimizeDeps;
|
16246
15976
|
const resolvedImports = resolveSubpathImports(id, importer, options);
|
16247
15977
|
if (resolvedImports) {
|
16248
15978
|
id = resolvedImports;
|
@@ -16291,14 +16021,7 @@ function resolvePlugin(resolveOptions, environmentsOptions) {
|
|
16291
16021
|
}
|
16292
16022
|
return normalizedFsPath;
|
16293
16023
|
}
|
16294
|
-
if (options.
|
16295
|
-
fsPath,
|
16296
|
-
importer,
|
16297
|
-
options,
|
16298
|
-
true,
|
16299
|
-
void 0,
|
16300
|
-
depsOptimizerOptions
|
16301
|
-
))) {
|
16024
|
+
if (options.mainFields.includes("browser") && (res = tryResolveBrowserMapping(fsPath, importer, options, true))) {
|
16302
16025
|
return res;
|
16303
16026
|
}
|
16304
16027
|
if (res = tryFsResolve(fsPath, options)) {
|
@@ -16351,13 +16074,12 @@ function resolvePlugin(resolveOptions, environmentsOptions) {
|
|
16351
16074
|
))) {
|
16352
16075
|
return res;
|
16353
16076
|
}
|
16354
|
-
if (options.
|
16077
|
+
if (options.mainFields.includes("browser") && (res = tryResolveBrowserMapping(
|
16355
16078
|
id,
|
16356
16079
|
importer,
|
16357
16080
|
options,
|
16358
16081
|
false,
|
16359
|
-
external
|
16360
|
-
depsOptimizerOptions
|
16082
|
+
external
|
16361
16083
|
))) {
|
16362
16084
|
return res;
|
16363
16085
|
}
|
@@ -16367,14 +16089,13 @@ function resolvePlugin(resolveOptions, environmentsOptions) {
|
|
16367
16089
|
options,
|
16368
16090
|
depsOptimizer,
|
16369
16091
|
external,
|
16370
|
-
void 0
|
16371
|
-
depsOptimizerOptions
|
16092
|
+
void 0
|
16372
16093
|
)) {
|
16373
16094
|
return res;
|
16374
16095
|
}
|
16375
16096
|
if (isBuiltin(id)) {
|
16376
16097
|
if (currentEnvironmentOptions.consumer === "server") {
|
16377
|
-
if (options.
|
16098
|
+
if (options.noExternal === true && // if both noExternal and external are true, noExternal will take the higher priority and bundle it.
|
16378
16099
|
// only if the id is explicitly listed in external, we will externalize it and skip this error.
|
16379
16100
|
(options.external === true || !options.external.includes(id))) {
|
16380
16101
|
let message = `Cannot bundle Node.js built-in "${id}"`;
|
@@ -16479,32 +16200,25 @@ const knownTsOutputRE = /\.(?:js|mjs|cjs|jsx)$/;
|
|
16479
16200
|
const isPossibleTsOutput = (url) => knownTsOutputRE.test(url);
|
16480
16201
|
function tryCleanFsResolve(file, options, tryIndex = true, skipPackageJson = false) {
|
16481
16202
|
const { tryPrefix, extensions, preserveSymlinks } = options;
|
16482
|
-
const
|
16483
|
-
const fileResult = fsUtils.tryResolveRealFileOrType(
|
16484
|
-
file,
|
16485
|
-
options.preserveSymlinks
|
16486
|
-
);
|
16203
|
+
const fileResult = tryResolveRealFileOrType(file, options.preserveSymlinks);
|
16487
16204
|
if (fileResult?.path) return fileResult.path;
|
16488
16205
|
let res;
|
16489
16206
|
const possibleJsToTs = options.isFromTsImporter && isPossibleTsOutput(file);
|
16490
16207
|
if (possibleJsToTs || options.extensions.length || tryPrefix) {
|
16491
16208
|
const dirPath = path.dirname(file);
|
16492
|
-
if (
|
16209
|
+
if (isDirectory(dirPath)) {
|
16493
16210
|
if (possibleJsToTs) {
|
16494
16211
|
const fileExt = path.extname(file);
|
16495
16212
|
const fileName = file.slice(0, -fileExt.length);
|
16496
|
-
if (res =
|
16213
|
+
if (res = tryResolveRealFile(
|
16497
16214
|
fileName + fileExt.replace("js", "ts"),
|
16498
16215
|
preserveSymlinks
|
16499
16216
|
))
|
16500
16217
|
return res;
|
16501
|
-
if (fileExt === ".js" && (res =
|
16502
|
-
fileName + ".tsx",
|
16503
|
-
preserveSymlinks
|
16504
|
-
)))
|
16218
|
+
if (fileExt === ".js" && (res = tryResolveRealFile(fileName + ".tsx", preserveSymlinks)))
|
16505
16219
|
return res;
|
16506
16220
|
}
|
16507
|
-
if (res =
|
16221
|
+
if (res = tryResolveRealFileWithExtensions(
|
16508
16222
|
file,
|
16509
16223
|
extensions,
|
16510
16224
|
preserveSymlinks
|
@@ -16512,9 +16226,8 @@ function tryCleanFsResolve(file, options, tryIndex = true, skipPackageJson = fal
|
|
16512
16226
|
return res;
|
16513
16227
|
if (tryPrefix) {
|
16514
16228
|
const prefixed = `${dirPath}/${options.tryPrefix}${path.basename(file)}`;
|
16515
|
-
if (res =
|
16516
|
-
|
16517
|
-
if (res = fsUtils.tryResolveRealFileWithExtensions(
|
16229
|
+
if (res = tryResolveRealFile(prefixed, preserveSymlinks)) return res;
|
16230
|
+
if (res = tryResolveRealFileWithExtensions(
|
16518
16231
|
prefixed,
|
16519
16232
|
extensions,
|
16520
16233
|
preserveSymlinks
|
@@ -16528,7 +16241,7 @@ function tryCleanFsResolve(file, options, tryIndex = true, skipPackageJson = fal
|
|
16528
16241
|
if (!skipPackageJson) {
|
16529
16242
|
let pkgPath = `${dirPath}/package.json`;
|
16530
16243
|
try {
|
16531
|
-
if (
|
16244
|
+
if (fs__default.existsSync(pkgPath)) {
|
16532
16245
|
if (!options.preserveSymlinks) {
|
16533
16246
|
pkgPath = safeRealpathSync(pkgPath);
|
16534
16247
|
}
|
@@ -16540,14 +16253,14 @@ function tryCleanFsResolve(file, options, tryIndex = true, skipPackageJson = fal
|
|
16540
16253
|
throw e;
|
16541
16254
|
}
|
16542
16255
|
}
|
16543
|
-
if (res =
|
16256
|
+
if (res = tryResolveRealFileWithExtensions(
|
16544
16257
|
`${dirPath}/index`,
|
16545
16258
|
extensions,
|
16546
16259
|
preserveSymlinks
|
16547
16260
|
))
|
16548
16261
|
return res;
|
16549
16262
|
if (tryPrefix) {
|
16550
|
-
if (res =
|
16263
|
+
if (res = tryResolveRealFileWithExtensions(
|
16551
16264
|
`${dirPath}/${options.tryPrefix}index`,
|
16552
16265
|
extensions,
|
16553
16266
|
preserveSymlinks
|
@@ -16556,7 +16269,7 @@ function tryCleanFsResolve(file, options, tryIndex = true, skipPackageJson = fal
|
|
16556
16269
|
}
|
16557
16270
|
}
|
16558
16271
|
}
|
16559
|
-
function tryNodeResolve(id, importer, options, depsOptimizer, externalize, allowLinkedExternal = true
|
16272
|
+
function tryNodeResolve(id, importer, options, depsOptimizer, externalize, allowLinkedExternal = true) {
|
16560
16273
|
const { root, dedupe, isBuild, preserveSymlinks, packageCache } = options;
|
16561
16274
|
const deepMatch = deepImportRE.exec(id);
|
16562
16275
|
const pkgId = deepMatch ? deepMatch[1] || deepMatch[2] : cleanUrl(id);
|
@@ -16619,47 +16332,30 @@ function tryNodeResolve(id, importer, options, depsOptimizer, externalize, allow
|
|
16619
16332
|
}
|
16620
16333
|
return { ...resolved2, id: resolvedId, external: true };
|
16621
16334
|
};
|
16622
|
-
if (!options.idOnly && (!options.scan && isBuild
|
16335
|
+
if (!options.idOnly && (!options.scan && isBuild || externalize)) {
|
16623
16336
|
return processResult({
|
16624
16337
|
id: resolved,
|
16625
16338
|
moduleSideEffects: pkg.hasSideEffects(resolved)
|
16626
16339
|
});
|
16627
16340
|
}
|
16628
|
-
if (!
|
16341
|
+
if (!isInNodeModules$1(resolved) || // linked
|
16629
16342
|
!depsOptimizer || // resolving before listening to the server
|
16630
|
-
options.scan)
|
16343
|
+
options.scan) {
|
16631
16344
|
return { id: resolved };
|
16632
16345
|
}
|
16633
|
-
const isJsType =
|
16634
|
-
|
16635
|
-
|
16636
|
-
exclude = depsOptimizerOptions?.exclude;
|
16637
|
-
}
|
16638
|
-
const skipOptimization = !options.ssrOptimizeCheck && depsOptimizer?.options.noDiscovery || !isJsType || importer && isInNodeModules$1(importer) || exclude?.includes(pkgId) || exclude?.includes(id) || SPECIAL_QUERY_RE.test(resolved);
|
16639
|
-
if (options.ssrOptimizeCheck) {
|
16640
|
-
return {
|
16641
|
-
id: skipOptimization ? injectQuery(resolved, `__vite_skip_optimization`) : resolved
|
16642
|
-
};
|
16643
|
-
}
|
16346
|
+
const isJsType = isOptimizable(resolved, depsOptimizer.options);
|
16347
|
+
const exclude = depsOptimizer.options.exclude;
|
16348
|
+
const skipOptimization = depsOptimizer.options.noDiscovery || !isJsType || importer && isInNodeModules$1(importer) || exclude?.includes(pkgId) || exclude?.includes(id) || SPECIAL_QUERY_RE.test(resolved);
|
16644
16349
|
if (skipOptimization) {
|
16645
|
-
|
16646
|
-
|
16647
|
-
|
16648
|
-
resolved = injectQuery(resolved, `v=${versionHash}`);
|
16649
|
-
}
|
16350
|
+
const versionHash = depsOptimizer.metadata.browserHash;
|
16351
|
+
if (versionHash && isJsType) {
|
16352
|
+
resolved = injectQuery(resolved, `v=${versionHash}`);
|
16650
16353
|
}
|
16651
16354
|
} else {
|
16652
16355
|
const optimizedInfo = depsOptimizer.registerMissingImport(id, resolved);
|
16653
16356
|
resolved = depsOptimizer.getOptimizedDepId(optimizedInfo);
|
16654
16357
|
}
|
16655
|
-
|
16656
|
-
return {
|
16657
|
-
id: resolved,
|
16658
|
-
moduleSideEffects: pkg.hasSideEffects(resolved)
|
16659
|
-
};
|
16660
|
-
} else {
|
16661
|
-
return { id: resolved };
|
16662
|
-
}
|
16358
|
+
return { id: resolved };
|
16663
16359
|
}
|
16664
16360
|
async function tryOptimizedResolve(depsOptimizer, id, importer, preserveSymlinks, packageCache) {
|
16665
16361
|
await depsOptimizer.scanProcessing;
|
@@ -16705,11 +16401,9 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
|
|
16705
16401
|
if (!entryPoint) {
|
16706
16402
|
for (const field of options.mainFields) {
|
16707
16403
|
if (field === "browser") {
|
16708
|
-
|
16709
|
-
|
16710
|
-
|
16711
|
-
break;
|
16712
|
-
}
|
16404
|
+
entryPoint = tryResolveBrowserEntry(dir, data, options);
|
16405
|
+
if (entryPoint) {
|
16406
|
+
break;
|
16713
16407
|
}
|
16714
16408
|
} else if (typeof data[field] === "string") {
|
16715
16409
|
entryPoint = data[field];
|
@@ -16726,7 +16420,7 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
|
|
16726
16420
|
skipPackageJson = true;
|
16727
16421
|
} else {
|
16728
16422
|
const { browser: browserField } = data;
|
16729
|
-
if (options.
|
16423
|
+
if (options.mainFields.includes("browser") && isObject(browserField)) {
|
16730
16424
|
entry = mapWithBrowserField(entry, browserField) || entry;
|
16731
16425
|
}
|
16732
16426
|
}
|
@@ -16760,29 +16454,19 @@ function packageEntryFailure(id, details) {
|
|
16760
16454
|
throw err;
|
16761
16455
|
}
|
16762
16456
|
function resolveExportsOrImports(pkg, key, options, type) {
|
16763
|
-
const
|
16764
|
-
|
16765
|
-
"production"
|
16766
|
-
"development",
|
16767
|
-
"module",
|
16768
|
-
...options.conditions
|
16769
|
-
]
|
16770
|
-
);
|
16771
|
-
const conditions = [...additionalConditions].filter((condition) => {
|
16772
|
-
switch (condition) {
|
16773
|
-
case "production":
|
16774
|
-
return options.isProduction;
|
16775
|
-
case "development":
|
16776
|
-
return !options.isProduction;
|
16457
|
+
const conditions = options.conditions.map((condition) => {
|
16458
|
+
if (condition === DEV_PROD_CONDITION) {
|
16459
|
+
return options.isProduction ? "production" : "development";
|
16777
16460
|
}
|
16778
|
-
return
|
16461
|
+
return condition;
|
16779
16462
|
});
|
16463
|
+
if (options.isRequire) {
|
16464
|
+
conditions.push("require");
|
16465
|
+
} else {
|
16466
|
+
conditions.push("import");
|
16467
|
+
}
|
16780
16468
|
const fn = type === "imports" ? f : o;
|
16781
|
-
const result = fn(pkg, key, {
|
16782
|
-
browser: options.webCompatible && !additionalConditions.has("node"),
|
16783
|
-
require: options.isRequire && !additionalConditions.has("import"),
|
16784
|
-
conditions
|
16785
|
-
});
|
16469
|
+
const result = fn(pkg, key, { conditions, unsafe: true });
|
16786
16470
|
return result ? result[0] : void 0;
|
16787
16471
|
}
|
16788
16472
|
function resolveDeepImport(id, { setResolvedCache, getResolvedCache, dir, data }, options) {
|
@@ -16809,7 +16493,7 @@ function resolveDeepImport(id, { setResolvedCache, getResolvedCache, dir, data }
|
|
16809
16493
|
`Package subpath '${relativeId}' is not defined by "exports" in ${path.join(dir, "package.json")}.`
|
16810
16494
|
);
|
16811
16495
|
}
|
16812
|
-
} else if (options.
|
16496
|
+
} else if (options.mainFields.includes("browser") && isObject(browserField)) {
|
16813
16497
|
const { file, postfix } = splitFileAndPostfix(relativeId);
|
16814
16498
|
const mapped = mapWithBrowserField(file, browserField);
|
16815
16499
|
if (mapped) {
|
@@ -16835,7 +16519,7 @@ function resolveDeepImport(id, { setResolvedCache, getResolvedCache, dir, data }
|
|
16835
16519
|
}
|
16836
16520
|
}
|
16837
16521
|
}
|
16838
|
-
function tryResolveBrowserMapping(id, importer, options, isFilePath, externalize
|
16522
|
+
function tryResolveBrowserMapping(id, importer, options, isFilePath, externalize) {
|
16839
16523
|
let res;
|
16840
16524
|
const pkg = importer && findNearestPackageData(path.dirname(importer), options.packageCache);
|
16841
16525
|
if (pkg && isObject(pkg.data.browser)) {
|
@@ -16848,8 +16532,7 @@ function tryResolveBrowserMapping(id, importer, options, isFilePath, externalize
|
|
16848
16532
|
options,
|
16849
16533
|
void 0,
|
16850
16534
|
void 0,
|
16851
|
-
void 0
|
16852
|
-
depsOptimizerOptions
|
16535
|
+
void 0
|
16853
16536
|
)?.id : tryFsResolve(path.join(pkg.dir, browserMappedPath), options)) {
|
16854
16537
|
debug$a?.(`[browser mapped] ${colors.cyan(id)} -> ${colors.dim(res)}`);
|
16855
16538
|
let result = { id: res };
|
@@ -16908,6 +16591,36 @@ function mapWithBrowserField(relativePathInPkgDir, map) {
|
|
16908
16591
|
function equalWithoutSuffix(path2, key, suffix) {
|
16909
16592
|
return key.endsWith(suffix) && key.slice(0, -suffix.length) === path2;
|
16910
16593
|
}
|
16594
|
+
function tryResolveRealFile(file, preserveSymlinks) {
|
16595
|
+
const stat = tryStatSync(file);
|
16596
|
+
if (stat?.isFile()) return getRealPath(file, preserveSymlinks);
|
16597
|
+
}
|
16598
|
+
function tryResolveRealFileWithExtensions(filePath, extensions, preserveSymlinks) {
|
16599
|
+
for (const ext of extensions) {
|
16600
|
+
const res = tryResolveRealFile(filePath + ext, preserveSymlinks);
|
16601
|
+
if (res) return res;
|
16602
|
+
}
|
16603
|
+
}
|
16604
|
+
function tryResolveRealFileOrType(file, preserveSymlinks) {
|
16605
|
+
const fileStat = tryStatSync(file);
|
16606
|
+
if (fileStat?.isFile()) {
|
16607
|
+
return { path: getRealPath(file, preserveSymlinks), type: "file" };
|
16608
|
+
}
|
16609
|
+
if (fileStat?.isDirectory()) {
|
16610
|
+
return { type: "directory" };
|
16611
|
+
}
|
16612
|
+
return;
|
16613
|
+
}
|
16614
|
+
function getRealPath(resolved, preserveSymlinks) {
|
16615
|
+
if (!preserveSymlinks) {
|
16616
|
+
resolved = safeRealpathSync(resolved);
|
16617
|
+
}
|
16618
|
+
return normalizePath$1(resolved);
|
16619
|
+
}
|
16620
|
+
function isDirectory(path2) {
|
16621
|
+
const stat = tryStatSync(path2);
|
16622
|
+
return stat?.isDirectory() ?? false;
|
16623
|
+
}
|
16911
16624
|
|
16912
16625
|
const externalWithConversionNamespace = "vite:dep-pre-bundle:external-conversion";
|
16913
16626
|
const convertedExternalPrefix = "vite-dep-pre-bundle-external:";
|
@@ -17179,7 +16892,6 @@ function getDefaultResolvedEnvironmentOptions(config) {
|
|
17179
16892
|
define: config.define,
|
17180
16893
|
resolve: config.resolve,
|
17181
16894
|
consumer: "server",
|
17182
|
-
webCompatible: false,
|
17183
16895
|
optimizeDeps: config.optimizeDeps,
|
17184
16896
|
dev: config.dev,
|
17185
16897
|
build: config.build
|
@@ -18727,7 +18439,6 @@ function createOptimizeDepsIncludeResolver(environment) {
|
|
18727
18439
|
const resolve = createBackCompatIdResolver(topLevelConfig, {
|
18728
18440
|
asSrc: false,
|
18729
18441
|
scan: true,
|
18730
|
-
ssrOptimizeCheck: environment.config.consumer === "server",
|
18731
18442
|
packageCache: /* @__PURE__ */ new Map()
|
18732
18443
|
});
|
18733
18444
|
return async (id) => {
|
@@ -19195,7 +18906,7 @@ async function prepareEsbuildOptimizerRun(environment, depsInfo, processingCache
|
|
19195
18906
|
process.env.NODE_ENV || environment.config.mode
|
19196
18907
|
)
|
19197
18908
|
};
|
19198
|
-
const platform = environment.config.
|
18909
|
+
const platform = environment.config.consumer === "client" ? "browser" : "node";
|
19199
18910
|
const external = [...optimizeDeps2?.exclude ?? []];
|
19200
18911
|
const plugins = [...pluginsFromConfig];
|
19201
18912
|
if (external.length) {
|
@@ -19262,9 +18973,7 @@ async function addManuallyIncludedOptimizeDeps(environment, deps) {
|
|
19262
18973
|
const entry = await resolve(id);
|
19263
18974
|
if (entry) {
|
19264
18975
|
if (isOptimizable(entry, optimizeDeps2)) {
|
19265
|
-
|
19266
|
-
deps[normalizedId] = entry;
|
19267
|
-
}
|
18976
|
+
deps[normalizedId] = entry;
|
19268
18977
|
} else {
|
19269
18978
|
unableToOptimize(id, "Cannot optimize dependency");
|
19270
18979
|
}
|
@@ -19505,8 +19214,7 @@ function getConfigHash(environment) {
|
|
19505
19214
|
...optimizeDeps2?.esbuildOptions,
|
19506
19215
|
plugins: optimizeDeps2?.esbuildOptions?.plugins?.map((p) => p.name)
|
19507
19216
|
}
|
19508
|
-
}
|
19509
|
-
webCompatible: config.webCompatible
|
19217
|
+
}
|
19510
19218
|
},
|
19511
19219
|
(_, value) => {
|
19512
19220
|
if (typeof value === "function" || value instanceof RegExp) {
|
@@ -19640,6 +19348,7 @@ var index$1 = {
|
|
19640
19348
|
};
|
19641
19349
|
|
19642
19350
|
const jsonExtRE = /\.json(?:$|\?)(?!commonjs-(?:proxy|external))/;
|
19351
|
+
const jsonObjRE = /^\s*\{/;
|
19643
19352
|
const jsonLangs = `\\.(?:json|json5)(?:$|\\?)`;
|
19644
19353
|
const jsonLangRE = new RegExp(jsonLangs);
|
19645
19354
|
const isJSONRequest = (request) => jsonLangRE.test(request);
|
@@ -19652,31 +19361,29 @@ function jsonPlugin(options = {}, isBuild) {
|
|
19652
19361
|
json = stripBomTag(json);
|
19653
19362
|
try {
|
19654
19363
|
if (options.stringify !== false) {
|
19655
|
-
if (options.namedExports) {
|
19364
|
+
if (options.namedExports && jsonObjRE.test(json)) {
|
19656
19365
|
const parsed = JSON.parse(json);
|
19657
|
-
|
19658
|
-
|
19659
|
-
|
19660
|
-
|
19661
|
-
|
19662
|
-
|
19663
|
-
code += `export const ${key} = ${serializeValue(parsed[key])};
|
19366
|
+
const keys = Object.keys(parsed);
|
19367
|
+
let code = "";
|
19368
|
+
let defaultObjectCode = "{\n";
|
19369
|
+
for (const key of keys) {
|
19370
|
+
if (key === makeLegalIdentifier(key)) {
|
19371
|
+
code += `export const ${key} = ${serializeValue(parsed[key])};
|
19664
19372
|
`;
|
19665
|
-
|
19373
|
+
defaultObjectCode += ` ${key},
|
19666
19374
|
`;
|
19667
|
-
|
19668
|
-
|
19375
|
+
} else {
|
19376
|
+
defaultObjectCode += ` ${JSON.stringify(key)}: ${serializeValue(parsed[key])},
|
19669
19377
|
`;
|
19670
|
-
}
|
19671
19378
|
}
|
19672
|
-
defaultObjectCode += "}";
|
19673
|
-
code += `export default ${defaultObjectCode};
|
19674
|
-
`;
|
19675
|
-
return {
|
19676
|
-
code,
|
19677
|
-
map: { mappings: "" }
|
19678
|
-
};
|
19679
19379
|
}
|
19380
|
+
defaultObjectCode += "}";
|
19381
|
+
code += `export default ${defaultObjectCode};
|
19382
|
+
`;
|
19383
|
+
return {
|
19384
|
+
code,
|
19385
|
+
map: { mappings: "" }
|
19386
|
+
};
|
19680
19387
|
}
|
19681
19388
|
if (options.stringify === true || // use 10kB as a threshold
|
19682
19389
|
// https://v8.dev/blog/cost-of-javascript-2019#:~:text=A%20good%20rule%20of%20thumb%20is%20to%20apply%20this%20technique%20for%20objects%20of%2010%20kB%20or%20larger
|
@@ -35791,7 +35498,7 @@ function doesProxyContextMatchUrl(context, url) {
|
|
35791
35498
|
}
|
35792
35499
|
|
35793
35500
|
const debug$4 = createDebugger("vite:html-fallback");
|
35794
|
-
function htmlFallbackMiddleware(root, spaFallback
|
35501
|
+
function htmlFallbackMiddleware(root, spaFallback) {
|
35795
35502
|
return function viteHtmlFallbackMiddleware(req, _res, next) {
|
35796
35503
|
if (
|
35797
35504
|
// Only accept GET or HEAD
|
@@ -35807,14 +35514,14 @@ function htmlFallbackMiddleware(root, spaFallback, fsUtils = commonFsUtils) {
|
|
35807
35514
|
const pathname = decodeURIComponent(url);
|
35808
35515
|
if (pathname.endsWith(".html")) {
|
35809
35516
|
const filePath = path.join(root, pathname);
|
35810
|
-
if (
|
35517
|
+
if (fs__default.existsSync(filePath)) {
|
35811
35518
|
debug$4?.(`Rewriting ${req.method} ${req.url} to ${url}`);
|
35812
35519
|
req.url = url;
|
35813
35520
|
return next();
|
35814
35521
|
}
|
35815
35522
|
} else if (pathname[pathname.length - 1] === "/") {
|
35816
35523
|
const filePath = path.join(root, pathname, "index.html");
|
35817
|
-
if (
|
35524
|
+
if (fs__default.existsSync(filePath)) {
|
35818
35525
|
const newUrl = url + "index.html";
|
35819
35526
|
debug$4?.(`Rewriting ${req.method} ${req.url} to ${newUrl}`);
|
35820
35527
|
req.url = newUrl;
|
@@ -35822,7 +35529,7 @@ function htmlFallbackMiddleware(root, spaFallback, fsUtils = commonFsUtils) {
|
|
35822
35529
|
}
|
35823
35530
|
} else {
|
35824
35531
|
const filePath = path.join(root, pathname + ".html");
|
35825
|
-
if (
|
35532
|
+
if (fs__default.existsSync(filePath)) {
|
35826
35533
|
const newUrl = url + ".html";
|
35827
35534
|
debug$4?.(`Rewriting ${req.method} ${req.url} to ${newUrl}`);
|
35828
35535
|
req.url = newUrl;
|
@@ -36743,6 +36450,108 @@ async function handleModuleSoftInvalidation(environment, mod, timestamp) {
|
|
36743
36450
|
return result;
|
36744
36451
|
}
|
36745
36452
|
|
36453
|
+
const ALLOWED_META_NAME = [
|
36454
|
+
"msapplication-tileimage",
|
36455
|
+
"msapplication-square70x70logo",
|
36456
|
+
"msapplication-square150x150logo",
|
36457
|
+
"msapplication-wide310x150logo",
|
36458
|
+
"msapplication-square310x310logo",
|
36459
|
+
"msapplication-config",
|
36460
|
+
"twitter:image"
|
36461
|
+
];
|
36462
|
+
const ALLOWED_META_PROPERTY = [
|
36463
|
+
"og:image",
|
36464
|
+
"og:image:url",
|
36465
|
+
"og:image:secure_url",
|
36466
|
+
"og:audio",
|
36467
|
+
"og:audio:secure_url",
|
36468
|
+
"og:video",
|
36469
|
+
"og:video:secure_url"
|
36470
|
+
];
|
36471
|
+
const DEFAULT_HTML_ASSET_SOURCES = {
|
36472
|
+
audio: {
|
36473
|
+
srcAttributes: ["src"]
|
36474
|
+
},
|
36475
|
+
embed: {
|
36476
|
+
srcAttributes: ["src"]
|
36477
|
+
},
|
36478
|
+
img: {
|
36479
|
+
srcAttributes: ["src"],
|
36480
|
+
srcsetAttributes: ["srcset"]
|
36481
|
+
},
|
36482
|
+
image: {
|
36483
|
+
srcAttributes: ["href", "xlink:href"]
|
36484
|
+
},
|
36485
|
+
input: {
|
36486
|
+
srcAttributes: ["src"]
|
36487
|
+
},
|
36488
|
+
link: {
|
36489
|
+
srcAttributes: ["href"],
|
36490
|
+
srcsetAttributes: ["imagesrcset"]
|
36491
|
+
},
|
36492
|
+
object: {
|
36493
|
+
srcAttributes: ["data"]
|
36494
|
+
},
|
36495
|
+
source: {
|
36496
|
+
srcAttributes: ["src"],
|
36497
|
+
srcsetAttributes: ["srcset"]
|
36498
|
+
},
|
36499
|
+
track: {
|
36500
|
+
srcAttributes: ["src"]
|
36501
|
+
},
|
36502
|
+
use: {
|
36503
|
+
srcAttributes: ["href", "xlink:href"]
|
36504
|
+
},
|
36505
|
+
video: {
|
36506
|
+
srcAttributes: ["src", "poster"]
|
36507
|
+
},
|
36508
|
+
meta: {
|
36509
|
+
srcAttributes: ["content"],
|
36510
|
+
filter({ attributes }) {
|
36511
|
+
if (attributes.name && ALLOWED_META_NAME.includes(attributes.name.trim().toLowerCase())) {
|
36512
|
+
return true;
|
36513
|
+
}
|
36514
|
+
if (attributes.property && ALLOWED_META_PROPERTY.includes(attributes.property.trim().toLowerCase())) {
|
36515
|
+
return true;
|
36516
|
+
}
|
36517
|
+
return false;
|
36518
|
+
}
|
36519
|
+
}
|
36520
|
+
};
|
36521
|
+
function getNodeAssetAttributes(node) {
|
36522
|
+
const matched = DEFAULT_HTML_ASSET_SOURCES[node.nodeName];
|
36523
|
+
if (!matched) return [];
|
36524
|
+
const attributes = {};
|
36525
|
+
for (const attr of node.attrs) {
|
36526
|
+
attributes[getAttrKey(attr)] = attr.value;
|
36527
|
+
}
|
36528
|
+
if ("vite-ignore" in attributes) {
|
36529
|
+
return [
|
36530
|
+
{
|
36531
|
+
type: "remove",
|
36532
|
+
key: "vite-ignore",
|
36533
|
+
value: "",
|
36534
|
+
attributes,
|
36535
|
+
location: node.sourceCodeLocation.attrs["vite-ignore"]
|
36536
|
+
}
|
36537
|
+
];
|
36538
|
+
}
|
36539
|
+
const actions = [];
|
36540
|
+
function handleAttributeKey(key, type) {
|
36541
|
+
const value = attributes[key];
|
36542
|
+
if (!value) return;
|
36543
|
+
if (matched.filter && !matched.filter({ key, value, attributes })) return;
|
36544
|
+
const location = node.sourceCodeLocation.attrs[key];
|
36545
|
+
actions.push({ type, key, value, attributes, location });
|
36546
|
+
}
|
36547
|
+
matched.srcAttributes?.forEach((key) => handleAttributeKey(key, "src"));
|
36548
|
+
matched.srcsetAttributes?.forEach((key) => handleAttributeKey(key, "srcset"));
|
36549
|
+
return actions;
|
36550
|
+
}
|
36551
|
+
function getAttrKey(attr) {
|
36552
|
+
return attr.prefix === void 0 ? attr.name : `${attr.prefix}:${attr.name}`;
|
36553
|
+
}
|
36554
|
+
|
36746
36555
|
const modulePreloadPolyfillId = "vite/modulepreload-polyfill";
|
36747
36556
|
const resolvedModulePreloadPolyfillId = "\0" + modulePreloadPolyfillId + ".js";
|
36748
36557
|
function modulePreloadPolyfillPlugin(config) {
|
@@ -36859,14 +36668,6 @@ function addToHTMLProxyCache(config, filePath, index, result) {
|
|
36859
36668
|
function addToHTMLProxyTransformResult(hash, code) {
|
36860
36669
|
htmlProxyResult.set(hash, code);
|
36861
36670
|
}
|
36862
|
-
const assetAttrsConfig = {
|
36863
|
-
link: ["href"],
|
36864
|
-
video: ["src", "poster"],
|
36865
|
-
source: ["src", "srcset"],
|
36866
|
-
img: ["src", "srcset"],
|
36867
|
-
image: ["xlink:href", "href"],
|
36868
|
-
use: ["xlink:href", "href"]
|
36869
|
-
};
|
36870
36671
|
const noInlineLinkRels = /* @__PURE__ */ new Set([
|
36871
36672
|
"icon",
|
36872
36673
|
"apple-touch-icon",
|
@@ -37120,84 +36921,69 @@ import "${id}?html-proxy&index=${inlineModuleIndex}.js"`;
|
|
37120
36921
|
}
|
37121
36922
|
}
|
37122
36923
|
}
|
37123
|
-
const
|
37124
|
-
|
37125
|
-
|
37126
|
-
|
37127
|
-
|
37128
|
-
}
|
37129
|
-
|
37130
|
-
|
37131
|
-
|
37132
|
-
|
37133
|
-
|
37134
|
-
|
37135
|
-
|
37136
|
-
|
37137
|
-
|
37138
|
-
(async () => {
|
37139
|
-
const processedEncodedUrl = await processSrcSet(
|
37140
|
-
attrValue,
|
37141
|
-
async ({ url }) => {
|
37142
|
-
const decodedUrl = decodeURI(url);
|
37143
|
-
if (!isExcludedUrl(decodedUrl)) {
|
37144
|
-
const result = await processAssetUrl(url);
|
37145
|
-
return result !== decodedUrl ? encodeURIPath(result) : url;
|
37146
|
-
}
|
37147
|
-
return url;
|
37148
|
-
}
|
37149
|
-
);
|
37150
|
-
if (processedEncodedUrl !== attrValue) {
|
37151
|
-
overwriteAttrValue(
|
37152
|
-
s,
|
37153
|
-
getAttrSourceCodeLocation(node, attrKey),
|
37154
|
-
processedEncodedUrl
|
37155
|
-
);
|
37156
|
-
}
|
37157
|
-
})()
|
37158
|
-
);
|
37159
|
-
} else {
|
37160
|
-
const url = decodeURI(attrValue);
|
37161
|
-
if (checkPublicFile(url, config)) {
|
37162
|
-
overwriteAttrValue(
|
37163
|
-
s,
|
37164
|
-
getAttrSourceCodeLocation(node, attrKey),
|
37165
|
-
partialEncodeURIPath(toOutputPublicFilePath(url))
|
37166
|
-
);
|
37167
|
-
} else if (!isExcludedUrl(url)) {
|
37168
|
-
if (node.nodeName === "link" && isCSSRequest(url) && // should not be converted if following attributes are present (#6748)
|
37169
|
-
!("media" in nodeAttrs || "disabled" in nodeAttrs)) {
|
37170
|
-
const importExpression = `
|
37171
|
-
import ${JSON.stringify(url)}`;
|
37172
|
-
styleUrls.push({
|
37173
|
-
url,
|
37174
|
-
start: nodeStartWithLeadingWhitespace(node),
|
37175
|
-
end: node.sourceCodeLocation.endOffset
|
37176
|
-
});
|
37177
|
-
js += importExpression;
|
37178
|
-
} else {
|
37179
|
-
const isNoInlineLink = node.nodeName === "link" && nodeAttrs.rel && parseRelAttr(nodeAttrs.rel).some(
|
37180
|
-
(v) => noInlineLinkRels.has(v)
|
37181
|
-
);
|
37182
|
-
const shouldInline = isNoInlineLink ? false : void 0;
|
37183
|
-
assetUrlsPromises.push(
|
37184
|
-
(async () => {
|
37185
|
-
const processedUrl = await processAssetUrl(
|
37186
|
-
url,
|
37187
|
-
shouldInline
|
37188
|
-
);
|
37189
|
-
if (processedUrl !== url) {
|
37190
|
-
overwriteAttrValue(
|
37191
|
-
s,
|
37192
|
-
getAttrSourceCodeLocation(node, attrKey),
|
37193
|
-
partialEncodeURIPath(processedUrl)
|
37194
|
-
);
|
37195
|
-
}
|
37196
|
-
})()
|
37197
|
-
);
|
36924
|
+
const assetAttributes = getNodeAssetAttributes(node);
|
36925
|
+
for (const attr of assetAttributes) {
|
36926
|
+
if (attr.type === "remove") {
|
36927
|
+
s.remove(attr.location.startOffset, attr.location.endOffset);
|
36928
|
+
continue;
|
36929
|
+
} else if (attr.type === "srcset") {
|
36930
|
+
assetUrlsPromises.push(
|
36931
|
+
(async () => {
|
36932
|
+
const processedEncodedUrl = await processSrcSet(
|
36933
|
+
attr.value,
|
36934
|
+
async ({ url }) => {
|
36935
|
+
const decodedUrl = decodeURI(url);
|
36936
|
+
if (!isExcludedUrl(decodedUrl)) {
|
36937
|
+
const result = await processAssetUrl(url);
|
36938
|
+
return result !== decodedUrl ? encodeURIPath(result) : url;
|
37198
36939
|
}
|
36940
|
+
return url;
|
37199
36941
|
}
|
36942
|
+
);
|
36943
|
+
if (processedEncodedUrl !== attr.value) {
|
36944
|
+
overwriteAttrValue(s, attr.location, processedEncodedUrl);
|
37200
36945
|
}
|
36946
|
+
})()
|
36947
|
+
);
|
36948
|
+
} else if (attr.type === "src") {
|
36949
|
+
const url = decodeURI(attr.value);
|
36950
|
+
if (checkPublicFile(url, config)) {
|
36951
|
+
overwriteAttrValue(
|
36952
|
+
s,
|
36953
|
+
attr.location,
|
36954
|
+
partialEncodeURIPath(toOutputPublicFilePath(url))
|
36955
|
+
);
|
36956
|
+
} else if (!isExcludedUrl(url)) {
|
36957
|
+
if (node.nodeName === "link" && isCSSRequest(url) && // should not be converted if following attributes are present (#6748)
|
36958
|
+
!("media" in attr.attributes || "disabled" in attr.attributes)) {
|
36959
|
+
const importExpression = `
|
36960
|
+
import ${JSON.stringify(url)}`;
|
36961
|
+
styleUrls.push({
|
36962
|
+
url,
|
36963
|
+
start: nodeStartWithLeadingWhitespace(node),
|
36964
|
+
end: node.sourceCodeLocation.endOffset
|
36965
|
+
});
|
36966
|
+
js += importExpression;
|
36967
|
+
} else {
|
36968
|
+
const isNoInlineLink = node.nodeName === "link" && attr.attributes.rel && parseRelAttr(attr.attributes.rel).some(
|
36969
|
+
(v) => noInlineLinkRels.has(v)
|
36970
|
+
);
|
36971
|
+
const shouldInline = isNoInlineLink ? false : void 0;
|
36972
|
+
assetUrlsPromises.push(
|
36973
|
+
(async () => {
|
36974
|
+
const processedUrl = await processAssetUrl(
|
36975
|
+
url,
|
36976
|
+
shouldInline
|
36977
|
+
);
|
36978
|
+
if (processedUrl !== url) {
|
36979
|
+
overwriteAttrValue(
|
36980
|
+
s,
|
36981
|
+
attr.location,
|
36982
|
+
partialEncodeURIPath(processedUrl)
|
36983
|
+
);
|
36984
|
+
}
|
36985
|
+
})()
|
36986
|
+
);
|
37201
36987
|
}
|
37202
36988
|
}
|
37203
36989
|
}
|
@@ -37868,12 +37654,6 @@ function serializeAttrs(attrs) {
|
|
37868
37654
|
function incrementIndent(indent = "") {
|
37869
37655
|
return `${indent}${indent[0] === " " ? " " : " "}`;
|
37870
37656
|
}
|
37871
|
-
function getAttrKey(attr) {
|
37872
|
-
return attr.prefix === void 0 ? attr.name : `${attr.prefix}:${attr.name}`;
|
37873
|
-
}
|
37874
|
-
function getAttrSourceCodeLocation(node, attrKey) {
|
37875
|
-
return node.sourceCodeLocation.attrs[attrKey];
|
37876
|
-
}
|
37877
37657
|
|
37878
37658
|
const debugCache = createDebugger("vite:cache");
|
37879
37659
|
const knownIgnoreList = /* @__PURE__ */ new Set(["/", "/favicon.ico"]);
|
@@ -38156,7 +37936,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
|
|
38156
37936
|
let proxyModulePath;
|
38157
37937
|
let proxyModuleUrl;
|
38158
37938
|
const trailingSlash = htmlPath.endsWith("/");
|
38159
|
-
if (!trailingSlash &&
|
37939
|
+
if (!trailingSlash && fs__default.existsSync(filename)) {
|
38160
37940
|
proxyModulePath = htmlPath;
|
38161
37941
|
proxyModuleUrl = proxyModulePath;
|
38162
37942
|
} else {
|
@@ -38210,7 +37990,8 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
|
|
38210
37990
|
} else if (src) {
|
38211
37991
|
const processedUrl = processNodeUrl(
|
38212
37992
|
src.value,
|
38213
|
-
|
37993
|
+
/* useSrcSetReplacer */
|
37994
|
+
false,
|
38214
37995
|
config,
|
38215
37996
|
htmlPath,
|
38216
37997
|
originalUrl,
|
@@ -38259,34 +38040,20 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
|
|
38259
38040
|
code: children.value
|
38260
38041
|
});
|
38261
38042
|
}
|
38262
|
-
const
|
38263
|
-
|
38264
|
-
|
38265
|
-
|
38266
|
-
nodeAttrs[getAttrKey(attr)] = attr.value;
|
38267
|
-
}
|
38268
|
-
const shouldIgnore = node.nodeName === "link" && "vite-ignore" in nodeAttrs;
|
38269
|
-
if (shouldIgnore) {
|
38270
|
-
removeViteIgnoreAttr(s, node.sourceCodeLocation);
|
38043
|
+
const assetAttributes = getNodeAssetAttributes(node);
|
38044
|
+
for (const attr of assetAttributes) {
|
38045
|
+
if (attr.type === "remove") {
|
38046
|
+
s.remove(attr.location.startOffset, attr.location.endOffset);
|
38271
38047
|
} else {
|
38272
|
-
|
38273
|
-
|
38274
|
-
|
38275
|
-
|
38276
|
-
|
38277
|
-
|
38278
|
-
|
38279
|
-
|
38280
|
-
|
38281
|
-
);
|
38282
|
-
if (processedUrl !== attrValue) {
|
38283
|
-
overwriteAttrValue(
|
38284
|
-
s,
|
38285
|
-
node.sourceCodeLocation.attrs[attrKey],
|
38286
|
-
processedUrl
|
38287
|
-
);
|
38288
|
-
}
|
38289
|
-
}
|
38048
|
+
const processedUrl = processNodeUrl(
|
38049
|
+
attr.value,
|
38050
|
+
attr.type === "srcset",
|
38051
|
+
config,
|
38052
|
+
htmlPath,
|
38053
|
+
originalUrl
|
38054
|
+
);
|
38055
|
+
if (processedUrl !== attr.value) {
|
38056
|
+
overwriteAttrValue(s, attr.location, processedUrl);
|
38290
38057
|
}
|
38291
38058
|
}
|
38292
38059
|
}
|
@@ -38351,7 +38118,6 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
|
|
38351
38118
|
};
|
38352
38119
|
function indexHtmlMiddleware(root, server) {
|
38353
38120
|
const isDev = isDevServer(server);
|
38354
|
-
const fsUtils = getFsUtils(server.config);
|
38355
38121
|
return async function viteIndexHtmlMiddleware(req, res, next) {
|
38356
38122
|
if (res.writableEnded) {
|
38357
38123
|
return next();
|
@@ -38364,7 +38130,7 @@ function indexHtmlMiddleware(root, server) {
|
|
38364
38130
|
} else {
|
38365
38131
|
filePath = path.join(root, decodeURIComponent(url));
|
38366
38132
|
}
|
38367
|
-
if (
|
38133
|
+
if (fs__default.existsSync(filePath)) {
|
38368
38134
|
const headers = isDev ? server.config.server.headers : server.config.preview.headers;
|
38369
38135
|
try {
|
38370
38136
|
let html = await fsp.readFile(filePath, "utf-8");
|
@@ -39044,7 +38810,8 @@ async function _createServer(inlineConfig = {}, options) {
|
|
39044
38810
|
}
|
39045
38811
|
const watcher = chokidar.watch(
|
39046
38812
|
// config file dependencies and env file might be outside of root
|
39047
|
-
|
38813
|
+
// eslint-disable-next-line eqeqeq -- null means disabled
|
38814
|
+
serverConfig.watch === null ? [] : [
|
39048
38815
|
root,
|
39049
38816
|
...config.configFileDependencies,
|
39050
38817
|
...getEnvFilesForMode(config.mode, config.envDir),
|
@@ -39058,6 +38825,7 @@ async function _createServer(inlineConfig = {}, options) {
|
|
39058
38825
|
watcher.add = function() {
|
39059
38826
|
return this;
|
39060
38827
|
};
|
38828
|
+
await watcher.close();
|
39061
38829
|
}
|
39062
38830
|
const environments = {};
|
39063
38831
|
for (const [name, environmentOptions] of Object.entries(
|
@@ -39315,7 +39083,6 @@ async function _createServer(inlineConfig = {}, options) {
|
|
39315
39083
|
}
|
39316
39084
|
await onHMRUpdate("update", file);
|
39317
39085
|
});
|
39318
|
-
getFsUtils(config).initWatcher?.(watcher);
|
39319
39086
|
watcher.on("add", (file) => {
|
39320
39087
|
onFileAddUnlink(file, false);
|
39321
39088
|
});
|
@@ -39362,13 +39129,7 @@ async function _createServer(inlineConfig = {}, options) {
|
|
39362
39129
|
middlewares.use(serveRawFsMiddleware(server));
|
39363
39130
|
middlewares.use(serveStaticMiddleware(server));
|
39364
39131
|
if (config.appType === "spa" || config.appType === "mpa") {
|
39365
|
-
middlewares.use(
|
39366
|
-
htmlFallbackMiddleware(
|
39367
|
-
root,
|
39368
|
-
config.appType === "spa",
|
39369
|
-
getFsUtils(config)
|
39370
|
-
)
|
39371
|
-
);
|
39132
|
+
middlewares.use(htmlFallbackMiddleware(root, config.appType === "spa"));
|
39372
39133
|
}
|
39373
39134
|
postHooks.forEach((fn) => fn && fn());
|
39374
39135
|
if (config.appType === "spa" || config.appType === "mpa") {
|
@@ -39501,8 +39262,7 @@ function resolveServerOptions(root, raw, logger) {
|
|
39501
39262
|
server.fs = {
|
39502
39263
|
strict: server.fs?.strict ?? true,
|
39503
39264
|
allow: allowDirs,
|
39504
|
-
deny
|
39505
|
-
cachedChecks: server.fs?.cachedChecks
|
39265
|
+
deny
|
39506
39266
|
};
|
39507
39267
|
if (server.origin?.endsWith("/")) {
|
39508
39268
|
server.origin = server.origin.slice(0, -1);
|
@@ -40236,6 +39996,7 @@ function definePlugin(config) {
|
|
40236
39996
|
importMetaFallbackKeys["import.meta.env"] = `undefined`;
|
40237
39997
|
}
|
40238
39998
|
function generatePattern(environment) {
|
39999
|
+
const keepProcessEnv = environment.config.keepProcessEnv;
|
40239
40000
|
const userDefine = {};
|
40240
40001
|
const userDefineEnv = {};
|
40241
40002
|
for (const key in environment.config.define) {
|
@@ -40244,9 +40005,8 @@ function definePlugin(config) {
|
|
40244
40005
|
userDefineEnv[key.slice(16)] = environment.config.define[key];
|
40245
40006
|
}
|
40246
40007
|
}
|
40247
|
-
const replaceProcessEnv = environment.config.webCompatible;
|
40248
40008
|
const define = {
|
40249
|
-
...
|
40009
|
+
...keepProcessEnv ? {} : processEnv,
|
40250
40010
|
...importMetaKeys,
|
40251
40011
|
...userDefine,
|
40252
40012
|
...importMetaFallbackKeys
|
@@ -40264,7 +40024,7 @@ function definePlugin(config) {
|
|
40264
40024
|
...userDefineEnv
|
40265
40025
|
});
|
40266
40026
|
const patternKeys = Object.keys(userDefine);
|
40267
|
-
if (
|
40027
|
+
if (!keepProcessEnv && Object.keys(processEnv).length) {
|
40268
40028
|
patternKeys.push("process.env");
|
40269
40029
|
}
|
40270
40030
|
if (Object.keys(importMetaKeys).length) {
|
@@ -40743,7 +40503,6 @@ function isSameContent(a, b) {
|
|
40743
40503
|
function preAliasPlugin(config) {
|
40744
40504
|
const findPatterns = getAliasPatterns(config.resolve.alias);
|
40745
40505
|
const isBuild = config.command === "build";
|
40746
|
-
const fsUtils = getFsUtils(config);
|
40747
40506
|
return {
|
40748
40507
|
name: "vite:pre-alias",
|
40749
40508
|
async resolveId(id, importer, options) {
|
@@ -40770,7 +40529,7 @@ function preAliasPlugin(config) {
|
|
40770
40529
|
const optimizeDeps = depsOptimizer.options;
|
40771
40530
|
const resolvedId = cleanUrl(resolved.id);
|
40772
40531
|
const isVirtual = resolvedId === id || resolvedId.includes("\0");
|
40773
|
-
if (!isVirtual &&
|
40532
|
+
if (!isVirtual && fs__default.existsSync(resolvedId) && !moduleListContains(optimizeDeps.exclude, id) && path.isAbsolute(resolvedId) && (isInNodeModules$1(resolvedId) || optimizeDeps.include?.includes(id)) && isOptimizable(resolvedId, optimizeDeps) && !(isBuild && ssr && isConfiguredAsExternal(environment, id, importer)) && (!ssr || optimizeAliasReplacementForSSR(resolvedId, optimizeDeps))) {
|
40774
40533
|
const optimizedInfo = depsOptimizer.registerMissingImport(
|
40775
40534
|
id,
|
40776
40535
|
resolvedId
|
@@ -40831,13 +40590,12 @@ function isExplicitImportRequired(url) {
|
|
40831
40590
|
function normalizeResolvedIdToUrl(environment, url, resolved) {
|
40832
40591
|
const root = environment.config.root;
|
40833
40592
|
const depsOptimizer = environment.depsOptimizer;
|
40834
|
-
const fsUtils = getFsUtils(environment.getTopLevelConfig());
|
40835
40593
|
if (resolved.id.startsWith(withTrailingSlash(root))) {
|
40836
40594
|
url = resolved.id.slice(root.length);
|
40837
40595
|
} else if (depsOptimizer?.isOptimizedDepFile(resolved.id) || // vite-plugin-react isn't following the leading \0 virtual module convention.
|
40838
40596
|
// This is a temporary hack to avoid expensive fs checks for React apps.
|
40839
40597
|
// We'll remove this as soon we're able to fix the react plugins.
|
40840
|
-
resolved.id !== "/@react-refresh" && path.isAbsolute(resolved.id) &&
|
40598
|
+
resolved.id !== "/@react-refresh" && path.isAbsolute(resolved.id) && fs__default.existsSync(cleanUrl(resolved.id))) {
|
40841
40599
|
url = path.posix.join(FS_PREFIX, resolved.id);
|
40842
40600
|
} else {
|
40843
40601
|
url = resolved.id;
|
@@ -41768,7 +41526,7 @@ function assetImportMetaUrlPlugin(config) {
|
|
41768
41526
|
const templateLiteral = ast.body[0].expression;
|
41769
41527
|
if (templateLiteral.expressions.length) {
|
41770
41528
|
const pattern = buildGlobPattern(templateLiteral);
|
41771
|
-
if (pattern.startsWith("
|
41529
|
+
if (pattern.startsWith("*")) {
|
41772
41530
|
continue;
|
41773
41531
|
}
|
41774
41532
|
const globOptions = {
|
@@ -41843,19 +41601,17 @@ ${rawExp} doesn't exist at build time, it will remain unchanged to be resolved a
|
|
41843
41601
|
}
|
41844
41602
|
function buildGlobPattern(ast) {
|
41845
41603
|
let pattern = "";
|
41846
|
-
let
|
41847
|
-
for (
|
41848
|
-
|
41849
|
-
|
41850
|
-
|
41851
|
-
|
41852
|
-
|
41853
|
-
|
41604
|
+
let lastIsGlob = false;
|
41605
|
+
for (let i = 0; i < ast.quasis.length; i++) {
|
41606
|
+
const str = ast.quasis[i].value.raw;
|
41607
|
+
if (str) {
|
41608
|
+
pattern += str;
|
41609
|
+
lastIsGlob = false;
|
41610
|
+
}
|
41611
|
+
if (ast.expressions[i] && !lastIsGlob) {
|
41612
|
+
pattern += "*";
|
41613
|
+
lastIsGlob = true;
|
41854
41614
|
}
|
41855
|
-
pattern += "**";
|
41856
|
-
}
|
41857
|
-
for (let i = lastElementIndex + 1; i < ast.quasis.length; i++) {
|
41858
|
-
pattern += ast.quasis[i].value.raw;
|
41859
41615
|
}
|
41860
41616
|
return pattern;
|
41861
41617
|
}
|
@@ -42213,7 +41969,6 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
|
|
42213
41969
|
isBuild,
|
42214
41970
|
packageCache: config.packageCache,
|
42215
41971
|
asSrc: true,
|
42216
|
-
fsUtils: getFsUtils(config),
|
42217
41972
|
optimizeDeps: true,
|
42218
41973
|
externalize: true
|
42219
41974
|
},
|
@@ -43010,7 +42765,6 @@ function createIdResolver(config, options) {
|
|
43010
42765
|
preferRelative: false,
|
43011
42766
|
tryIndex: true,
|
43012
42767
|
...options,
|
43013
|
-
fsUtils: getFsUtils(config),
|
43014
42768
|
// Ignore sideEffects and other computations as we only need the id
|
43015
42769
|
idOnly: true
|
43016
42770
|
})
|
@@ -43195,7 +42949,6 @@ function cssPostPlugin(config) {
|
|
43195
42949
|
let pureCssChunks;
|
43196
42950
|
let hasEmitted = false;
|
43197
42951
|
let chunkCSSMap;
|
43198
|
-
let cssBundleName;
|
43199
42952
|
const rollupOptionsOutput = config.build.rollupOptions.output;
|
43200
42953
|
const assetFileNames = (Array.isArray(rollupOptionsOutput) ? rollupOptionsOutput[0] : rollupOptionsOutput)?.assetFileNames;
|
43201
42954
|
const getCssAssetDirname = (cssAssetName) => {
|
@@ -43217,6 +42970,17 @@ function cssPostPlugin(config) {
|
|
43217
42970
|
);
|
43218
42971
|
}
|
43219
42972
|
};
|
42973
|
+
function getCssBundleName() {
|
42974
|
+
const cached = cssBundleNameCache.get(config);
|
42975
|
+
if (cached) return cached;
|
42976
|
+
const cssBundleName = config.build.lib ? resolveLibCssFilename(
|
42977
|
+
config.build.lib,
|
42978
|
+
config.root,
|
42979
|
+
config.packageCache
|
42980
|
+
) : defaultCssBundleName;
|
42981
|
+
cssBundleNameCache.set(config, cssBundleName);
|
42982
|
+
return cssBundleName;
|
42983
|
+
}
|
43220
42984
|
return {
|
43221
42985
|
name: "vite:css-post",
|
43222
42986
|
renderStart() {
|
@@ -43224,12 +42988,6 @@ function cssPostPlugin(config) {
|
|
43224
42988
|
hasEmitted = false;
|
43225
42989
|
chunkCSSMap = /* @__PURE__ */ new Map();
|
43226
42990
|
codeSplitEmitQueue = createSerialPromiseQueue();
|
43227
|
-
cssBundleName = config.build.lib ? resolveLibCssFilename(
|
43228
|
-
config.build.lib,
|
43229
|
-
config.root,
|
43230
|
-
config.packageCache
|
43231
|
-
) : defaultCssBundleName;
|
43232
|
-
cssBundleNameCache.set(config, cssBundleName);
|
43233
42991
|
},
|
43234
42992
|
async transform(css, id) {
|
43235
42993
|
if (!isCSSRequest(id) || commonjsProxyRE.test(id) || SPECIAL_QUERY_RE.test(id)) {
|
@@ -43495,7 +43253,7 @@ function cssPostPlugin(config) {
|
|
43495
43253
|
s.appendRight(injectionPoint, injectCode);
|
43496
43254
|
}
|
43497
43255
|
} else {
|
43498
|
-
chunkCSS = resolveAssetUrlsInCss(chunkCSS,
|
43256
|
+
chunkCSS = resolveAssetUrlsInCss(chunkCSS, getCssBundleName());
|
43499
43257
|
chunkCSSMap.set(chunk.fileName, chunkCSS);
|
43500
43258
|
}
|
43501
43259
|
}
|
@@ -43524,7 +43282,7 @@ function cssPostPlugin(config) {
|
|
43524
43282
|
if (opts.__vite_skip_asset_emit__) {
|
43525
43283
|
return;
|
43526
43284
|
}
|
43527
|
-
if (!config.build.cssCodeSplit && !hasEmitted) {
|
43285
|
+
if (!this.environment.config.build.cssCodeSplit && !hasEmitted) {
|
43528
43286
|
let collect2 = function(chunk) {
|
43529
43287
|
if (!chunk || chunk.type !== "chunk" || collected.has(chunk)) return;
|
43530
43288
|
collected.add(chunk);
|
@@ -43549,7 +43307,7 @@ function cssPostPlugin(config) {
|
|
43549
43307
|
hasEmitted = true;
|
43550
43308
|
extractedCss = await finalizeCss(extractedCss, true, config);
|
43551
43309
|
this.emitFile({
|
43552
|
-
name:
|
43310
|
+
name: getCssBundleName(),
|
43553
43311
|
type: "asset",
|
43554
43312
|
source: extractedCss
|
43555
43313
|
});
|
@@ -43669,7 +43427,7 @@ function createCSSResolvers(config) {
|
|
43669
43427
|
return cssResolve ??= createBackCompatIdResolver(config, {
|
43670
43428
|
extensions: [".css"],
|
43671
43429
|
mainFields: ["style"],
|
43672
|
-
conditions: ["style"],
|
43430
|
+
conditions: ["style", DEV_PROD_CONDITION],
|
43673
43431
|
tryIndex: false,
|
43674
43432
|
preferRelative: true
|
43675
43433
|
});
|
@@ -43679,7 +43437,7 @@ function createCSSResolvers(config) {
|
|
43679
43437
|
const resolver = createBackCompatIdResolver(config, {
|
43680
43438
|
extensions: [".scss", ".sass", ".css"],
|
43681
43439
|
mainFields: ["sass", "style"],
|
43682
|
-
conditions: ["sass", "style"],
|
43440
|
+
conditions: ["sass", "style", DEV_PROD_CONDITION],
|
43683
43441
|
tryIndex: true,
|
43684
43442
|
tryPrefix: "_",
|
43685
43443
|
preferRelative: true
|
@@ -43697,7 +43455,7 @@ function createCSSResolvers(config) {
|
|
43697
43455
|
return lessResolve ??= createBackCompatIdResolver(config, {
|
43698
43456
|
extensions: [".less", ".css"],
|
43699
43457
|
mainFields: ["less", "style"],
|
43700
|
-
conditions: ["less", "style"],
|
43458
|
+
conditions: ["less", "style", DEV_PROD_CONDITION],
|
43701
43459
|
tryIndex: false,
|
43702
43460
|
preferRelative: true
|
43703
43461
|
});
|
@@ -43989,8 +43747,8 @@ function createCachedImport(imp) {
|
|
43989
43747
|
return cached;
|
43990
43748
|
};
|
43991
43749
|
}
|
43992
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
43993
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
43750
|
+
const importPostcssImport = createCachedImport(() => import('./dep-DUn1iy3F.js').then(function (n) { return n.i; }));
|
43751
|
+
const importPostcssModules = createCachedImport(() => import('./dep-qU9-vqRp.js').then(function (n) { return n.i; }));
|
43994
43752
|
const importPostcss = createCachedImport(() => import('postcss'));
|
43995
43753
|
const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
|
43996
43754
|
let alwaysFakeWorkerWorkerControllerCache;
|
@@ -44082,9 +43840,9 @@ ${stack}`;
|
|
44082
43840
|
postcssConfigCache.set(config, result);
|
44083
43841
|
return result;
|
44084
43842
|
}
|
44085
|
-
const cssUrlRE = /(?<=^|[^\w\-\u0080-\uffff])url\((\s*('[^']+'|"[^"]+")\s*|[^'")]+)\)/;
|
43843
|
+
const cssUrlRE = /(?<!@import\s+)(?<=^|[^\w\-\u0080-\uffff])url\((\s*('[^']+'|"[^"]+")\s*|[^'")]+)\)/;
|
44086
43844
|
const cssDataUriRE = /(?<=^|[^\w\-\u0080-\uffff])data-uri\((\s*('[^']+'|"[^"]+")\s*|[^'")]+)\)/;
|
44087
|
-
const importCssRE = /@import
|
43845
|
+
const importCssRE = /@import\s+(?:url\()?('[^']+\.css'|"[^"]+\.css"|[^'"\s)]+\.css)/;
|
44088
43846
|
const cssImageSetRE = /(?<=image-set\()((?:[\w-]{1,256}\([^)]*\)|[^)])*)(?=\))/;
|
44089
43847
|
const UrlRewritePostcssPlugin = (opts) => {
|
44090
43848
|
if (!opts) {
|
@@ -44193,7 +43951,8 @@ async function doImportCSSReplace(rawUrl, matched, replacer) {
|
|
44193
43951
|
if (isExternalUrl(rawUrl) || isDataUrl(rawUrl) || rawUrl[0] === "#") {
|
44194
43952
|
return matched;
|
44195
43953
|
}
|
44196
|
-
|
43954
|
+
const prefix = matched.includes("url(") ? "url(" : "";
|
43955
|
+
return `@import ${prefix}${wrap}${await replacer(rawUrl)}${wrap}`;
|
44197
43956
|
}
|
44198
43957
|
async function minifyCSS(css, config, inlined) {
|
44199
43958
|
if (config.build.cssMinify === "lightningcss") {
|
@@ -44631,6 +44390,11 @@ const scssProcessor = (maxWorkers) => {
|
|
44631
44390
|
e.message = `[sass] ${e.message}`;
|
44632
44391
|
e.id = e.file;
|
44633
44392
|
e.frame = e.formatted;
|
44393
|
+
if (e.span?.start) {
|
44394
|
+
e.line = e.span.start.line + 1;
|
44395
|
+
e.column = e.span.start.column + 1;
|
44396
|
+
e.frame = e.message;
|
44397
|
+
}
|
44634
44398
|
return { code: "", error: e, deps: [] };
|
44635
44399
|
}
|
44636
44400
|
}
|
@@ -45780,7 +45544,7 @@ function completeSystemWrapPlugin() {
|
|
45780
45544
|
};
|
45781
45545
|
}
|
45782
45546
|
|
45783
|
-
function resolveBuildEnvironmentOptions(raw, logger, consumer) {
|
45547
|
+
function resolveBuildEnvironmentOptions(raw, logger, consumer, isSsrTargetWebworkerEnvironment) {
|
45784
45548
|
const deprecatedPolyfillModulePreload = raw?.polyfillModulePreload;
|
45785
45549
|
const { polyfillModulePreload, ...rest } = raw;
|
45786
45550
|
raw = rest;
|
@@ -45854,6 +45618,17 @@ function resolveBuildEnvironmentOptions(raw, logger, consumer) {
|
|
45854
45618
|
if (resolved.cssMinify == null) {
|
45855
45619
|
resolved.cssMinify = consumer === "server" ? "esbuild" : !!resolved.minify;
|
45856
45620
|
}
|
45621
|
+
if (isSsrTargetWebworkerEnvironment) {
|
45622
|
+
resolved.rollupOptions ??= {};
|
45623
|
+
resolved.rollupOptions.output ??= {};
|
45624
|
+
const output = resolved.rollupOptions.output;
|
45625
|
+
for (const out of arraify(output)) {
|
45626
|
+
out.entryFileNames ??= `[name].js`;
|
45627
|
+
out.chunkFileNames ??= `[name]-[hash].js`;
|
45628
|
+
const input = resolved.rollupOptions.input;
|
45629
|
+
out.inlineDynamicImports ??= !input || typeof input === "string" || Object.keys(input).length === 1;
|
45630
|
+
}
|
45631
|
+
}
|
45857
45632
|
return resolved;
|
45858
45633
|
}
|
45859
45634
|
async function resolveBuildPlugins(config) {
|
@@ -46022,7 +45797,7 @@ ${stackOnly}`;
|
|
46022
45797
|
);
|
46023
45798
|
}
|
46024
45799
|
const format = output.format || "es";
|
46025
|
-
const jsExt =
|
45800
|
+
const jsExt = environment.config.consumer === "server" || libOptions ? resolveOutputJsExtension(
|
46026
45801
|
format,
|
46027
45802
|
findNearestPackageData(root, packageCache)?.data.type
|
46028
45803
|
) : "js";
|
@@ -46048,7 +45823,7 @@ ${stackOnly}`;
|
|
46048
45823
|
) : path.posix.join(options.assetsDir, `[name]-[hash].${jsExt}`),
|
46049
45824
|
chunkFileNames: libOptions ? `[name]-[hash].${jsExt}` : path.posix.join(options.assetsDir, `[name]-[hash].${jsExt}`),
|
46050
45825
|
assetFileNames: libOptions ? `[name].[ext]` : path.posix.join(options.assetsDir, `[name]-[hash].[ext]`),
|
46051
|
-
inlineDynamicImports: output.format === "umd" || output.format === "iife"
|
45826
|
+
inlineDynamicImports: output.format === "umd" || output.format === "iife",
|
46052
45827
|
...output
|
46053
45828
|
};
|
46054
45829
|
};
|
@@ -46659,19 +46434,17 @@ async function fetchModule(environment, url, importer, options = {}) {
|
|
46659
46434
|
const { externalConditions, dedupe, preserveSymlinks } = environment.config.resolve;
|
46660
46435
|
const resolved = tryNodeResolve(url, importer, {
|
46661
46436
|
mainFields: ["main"],
|
46662
|
-
conditions:
|
46437
|
+
conditions: externalConditions,
|
46663
46438
|
externalConditions,
|
46664
46439
|
external: [],
|
46665
46440
|
noExternal: [],
|
46666
|
-
overrideConditions: [...externalConditions, "production", "development"],
|
46667
46441
|
extensions: [".js", ".cjs", ".json"],
|
46668
46442
|
dedupe,
|
46669
46443
|
preserveSymlinks,
|
46670
46444
|
isBuild: false,
|
46671
46445
|
isProduction,
|
46672
46446
|
root,
|
46673
|
-
packageCache: environment.config.packageCache
|
46674
|
-
webCompatible: environment.config.webCompatible
|
46447
|
+
packageCache: environment.config.packageCache
|
46675
46448
|
});
|
46676
46449
|
if (!resolved) {
|
46677
46450
|
const err = new Error(
|
@@ -48324,20 +48097,23 @@ function resolveDevEnvironmentOptions(dev, environmentName, consumer, skipSsrTra
|
|
48324
48097
|
moduleRunnerTransform: dev?.moduleRunnerTransform ?? (skipSsrTransform !== void 0 && consumer === "server" ? skipSsrTransform : consumer === "server")
|
48325
48098
|
};
|
48326
48099
|
}
|
48327
|
-
function resolveEnvironmentOptions(options, alias, preserveSymlinks, logger, environmentName, skipSsrTransform) {
|
48100
|
+
function resolveEnvironmentOptions(options, alias, preserveSymlinks, logger, environmentName, skipSsrTransform, ssrTargetWebworker) {
|
48101
|
+
const isClientEnvironment = environmentName === "client";
|
48102
|
+
const consumer = options.consumer ?? (isClientEnvironment ? "client" : "server");
|
48103
|
+
const isSsrTargetWebworkerEnvironment = ssrTargetWebworker && environmentName === "ssr";
|
48328
48104
|
const resolve = resolveEnvironmentResolveOptions(
|
48329
48105
|
options.resolve,
|
48330
48106
|
alias,
|
48331
48107
|
preserveSymlinks,
|
48332
|
-
logger
|
48108
|
+
logger,
|
48109
|
+
consumer,
|
48110
|
+
isSsrTargetWebworkerEnvironment
|
48333
48111
|
);
|
48334
|
-
const isClientEnvironment = environmentName === "client";
|
48335
|
-
const consumer = options.consumer ?? (isClientEnvironment ? "client" : "server");
|
48336
48112
|
return {
|
48337
48113
|
define: options.define,
|
48338
48114
|
resolve,
|
48115
|
+
keepProcessEnv: options.keepProcessEnv ?? (isSsrTargetWebworkerEnvironment ? false : consumer === "server"),
|
48339
48116
|
consumer,
|
48340
|
-
webCompatible: options.webCompatible ?? consumer === "client",
|
48341
48117
|
optimizeDeps: resolveDepOptimizationOptions(
|
48342
48118
|
options.optimizeDeps,
|
48343
48119
|
resolve.preserveSymlinks,
|
@@ -48352,14 +48128,20 @@ function resolveEnvironmentOptions(options, alias, preserveSymlinks, logger, env
|
|
48352
48128
|
build: resolveBuildEnvironmentOptions(
|
48353
48129
|
options.build ?? {},
|
48354
48130
|
logger,
|
48355
|
-
consumer
|
48131
|
+
consumer,
|
48132
|
+
isSsrTargetWebworkerEnvironment
|
48356
48133
|
)
|
48357
48134
|
};
|
48358
48135
|
}
|
48359
48136
|
function getDefaultEnvironmentOptions(config) {
|
48360
48137
|
return {
|
48361
48138
|
define: config.define,
|
48362
|
-
resolve:
|
48139
|
+
resolve: {
|
48140
|
+
...config.resolve,
|
48141
|
+
// mainFields and conditions are not inherited
|
48142
|
+
mainFields: void 0,
|
48143
|
+
conditions: void 0
|
48144
|
+
},
|
48363
48145
|
dev: config.dev,
|
48364
48146
|
build: config.build
|
48365
48147
|
};
|
@@ -48394,12 +48176,14 @@ const clientAlias = [
|
|
48394
48176
|
replacement: path.posix.join(FS_PREFIX, normalizePath$1(CLIENT_ENTRY))
|
48395
48177
|
}
|
48396
48178
|
];
|
48397
|
-
function resolveEnvironmentResolveOptions(resolve, alias, preserveSymlinks, logger) {
|
48179
|
+
function resolveEnvironmentResolveOptions(resolve, alias, preserveSymlinks, logger, consumer, isSsrTargetWebworkerEnvironment) {
|
48180
|
+
let conditions = resolve?.conditions;
|
48181
|
+
conditions ??= consumer === "client" || isSsrTargetWebworkerEnvironment ? DEFAULT_CONDITIONS.filter((c) => c !== "node") : DEFAULT_CONDITIONS.filter((c) => c !== "browser");
|
48398
48182
|
const resolvedResolve = {
|
48399
48183
|
mainFields: resolve?.mainFields ?? DEFAULT_MAIN_FIELDS,
|
48400
|
-
conditions
|
48401
|
-
externalConditions: resolve?.externalConditions ??
|
48402
|
-
external: resolve?.external ?? [],
|
48184
|
+
conditions,
|
48185
|
+
externalConditions: resolve?.externalConditions ?? DEFAULT_EXTERNAL_CONDITIONS,
|
48186
|
+
external: resolve?.external ?? (consumer === "server" && !isSsrTargetWebworkerEnvironment ? builtinModules : []),
|
48403
48187
|
noExternal: resolve?.noExternal ?? [],
|
48404
48188
|
extensions: resolve?.extensions ?? DEFAULT_EXTENSIONS,
|
48405
48189
|
dedupe: resolve?.dedupe ?? [],
|
@@ -48425,7 +48209,8 @@ function resolveResolveOptions(resolve, logger) {
|
|
48425
48209
|
resolve,
|
48426
48210
|
alias,
|
48427
48211
|
preserveSymlinks,
|
48428
|
-
logger
|
48212
|
+
logger,
|
48213
|
+
void 0
|
48429
48214
|
);
|
48430
48215
|
}
|
48431
48216
|
function resolveDepOptimizationOptions(optimizeDeps, preserveSymlinks, consumer) {
|
@@ -48532,9 +48317,6 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
48532
48317
|
configEnvironmentsSsr.resolve.externalConditions ??= config.ssr?.resolve?.externalConditions;
|
48533
48318
|
configEnvironmentsSsr.resolve.external ??= config.ssr?.external;
|
48534
48319
|
configEnvironmentsSsr.resolve.noExternal ??= config.ssr?.noExternal;
|
48535
|
-
if (config.ssr?.target === "webworker") {
|
48536
|
-
configEnvironmentsSsr.webCompatible = true;
|
48537
|
-
}
|
48538
48320
|
}
|
48539
48321
|
if (config.build?.ssrEmitAssets !== void 0) {
|
48540
48322
|
configEnvironmentsSsr ??= {};
|
@@ -48549,13 +48331,16 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
48549
48331
|
const defaultEnvironmentOptions = getDefaultEnvironmentOptions(config);
|
48550
48332
|
const defaultClientEnvironmentOptions = {
|
48551
48333
|
...defaultEnvironmentOptions,
|
48334
|
+
resolve: config.resolve,
|
48335
|
+
// inherit everything including mainFields and conditions
|
48552
48336
|
optimizeDeps: config.optimizeDeps
|
48553
48337
|
};
|
48554
48338
|
const defaultNonClientEnvironmentOptions = {
|
48555
48339
|
...defaultEnvironmentOptions,
|
48556
48340
|
dev: {
|
48557
48341
|
...defaultEnvironmentOptions.dev,
|
48558
|
-
createEnvironment: void 0
|
48342
|
+
createEnvironment: void 0,
|
48343
|
+
warmup: void 0
|
48559
48344
|
},
|
48560
48345
|
build: {
|
48561
48346
|
...defaultEnvironmentOptions.build,
|
@@ -48578,7 +48363,8 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
48578
48363
|
resolvedDefaultResolve.preserveSymlinks,
|
48579
48364
|
logger,
|
48580
48365
|
environmentName,
|
48581
|
-
config.experimental?.skipSsrTransform
|
48366
|
+
config.experimental?.skipSsrTransform,
|
48367
|
+
config.ssr?.target === "webworker"
|
48582
48368
|
);
|
48583
48369
|
}
|
48584
48370
|
const backwardCompatibleOptimizeDeps = resolvedEnvironments.client.optimizeDeps;
|
@@ -48980,17 +48766,15 @@ async function bundleConfigFile(fileName, isESM) {
|
|
48980
48766
|
preferRelative: false,
|
48981
48767
|
tryIndex: true,
|
48982
48768
|
mainFields: [],
|
48983
|
-
conditions: [],
|
48769
|
+
conditions: ["node"],
|
48984
48770
|
externalConditions: [],
|
48985
48771
|
external: [],
|
48986
48772
|
noExternal: [],
|
48987
|
-
overrideConditions: ["node"],
|
48988
48773
|
dedupe: [],
|
48989
48774
|
extensions: DEFAULT_EXTENSIONS,
|
48990
48775
|
preserveSymlinks: false,
|
48991
48776
|
packageCache,
|
48992
|
-
isRequire
|
48993
|
-
webCompatible: false
|
48777
|
+
isRequire
|
48994
48778
|
})?.id;
|
48995
48779
|
};
|
48996
48780
|
build2.onResolve(
|
@@ -49066,14 +48850,22 @@ async function bundleConfigFile(fileName, isESM) {
|
|
49066
48850
|
const _require = createRequire(import.meta.url);
|
49067
48851
|
async function loadConfigFromBundledFile(fileName, bundledCode, isESM) {
|
49068
48852
|
if (isESM) {
|
49069
|
-
const
|
49070
|
-
|
49071
|
-
|
49072
|
-
|
48853
|
+
const nodeModulesDir = findNearestNodeModules(path.dirname(fileName));
|
48854
|
+
if (nodeModulesDir) {
|
48855
|
+
await fsp.mkdir(path.resolve(nodeModulesDir, ".vite-temp/"), {
|
48856
|
+
recursive: true
|
48857
|
+
});
|
48858
|
+
}
|
48859
|
+
const hash = `timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
48860
|
+
const tempFileName = nodeModulesDir ? path.resolve(
|
48861
|
+
nodeModulesDir,
|
48862
|
+
`.vite-temp/${path.basename(fileName)}.${hash}.mjs`
|
48863
|
+
) : `${fileName}.${hash}.mjs`;
|
48864
|
+
await fsp.writeFile(tempFileName, bundledCode);
|
49073
48865
|
try {
|
49074
|
-
return (await import(
|
48866
|
+
return (await import(pathToFileURL(tempFileName).href)).default;
|
49075
48867
|
} finally {
|
49076
|
-
fs__default.unlink(
|
48868
|
+
fs__default.unlink(tempFileName, () => {
|
49077
48869
|
});
|
49078
48870
|
}
|
49079
48871
|
} else {
|