vite 6.0.2 → 6.0.3
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.
Potentially problematic release.
This version of vite might be problematic. Click here for more details.
- package/bin/vite.js +4 -0
- package/dist/client/client.mjs +19 -21
- package/dist/node/chunks/{dep-CoVxupJ6.js → dep-BiVmWRQp.js} +1 -1
- package/dist/node/chunks/{dep-DFNV1bxH.js → dep-CjE1AkI6.js} +1 -1
- package/dist/node/chunks/{dep-A4nAWF7x.js → dep-yUJfKD1i.js} +194 -169
- package/dist/node/cli.js +5 -5
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.js +4 -4
- package/dist/node/module-runner.d.ts +2 -2
- package/dist/node/module-runner.js +9 -9
- package/dist/node-cjs/publicUtils.cjs +2 -2
- package/package.json +4 -4
@@ -10172,7 +10172,7 @@ async function resolveServerUrls(server, options, config) {
|
|
10172
10172
|
}
|
10173
10173
|
} else {
|
10174
10174
|
Object.values(os$3.networkInterfaces()).flatMap((nInterface) => nInterface ?? []).filter(
|
10175
|
-
(detail) => detail
|
10175
|
+
(detail) => detail.address && (detail.family === "IPv4" || // @ts-expect-error Node 18.0 - 18.3 returns number
|
10176
10176
|
detail.family === 4)
|
10177
10177
|
).forEach((detail) => {
|
10178
10178
|
let host = detail.address.replace("127.0.0.1", hostname.name);
|
@@ -10442,7 +10442,7 @@ function getNpmPackageName(importPath) {
|
|
10442
10442
|
}
|
10443
10443
|
}
|
10444
10444
|
function getPkgName(name) {
|
10445
|
-
return name
|
10445
|
+
return name[0] === "@" ? name.split("/")[1] : name;
|
10446
10446
|
}
|
10447
10447
|
const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
|
10448
10448
|
function escapeRegex(str) {
|
@@ -13354,7 +13354,7 @@ async function fileToDevUrl(environment, id, skipBase = false) {
|
|
13354
13354
|
if (skipBase) {
|
13355
13355
|
return rtn;
|
13356
13356
|
}
|
13357
|
-
const base = joinUrlSegments(config.server
|
13357
|
+
const base = joinUrlSegments(config.server.origin ?? "", config.decodedBase);
|
13358
13358
|
return joinUrlSegments(base, removeLeadingSlash(rtn));
|
13359
13359
|
}
|
13360
13360
|
function getPublicAssetFilename(hash, config) {
|
@@ -13591,7 +13591,7 @@ function manifestPlugin() {
|
|
13591
13591
|
}
|
13592
13592
|
}
|
13593
13593
|
state.outputCount++;
|
13594
|
-
const output = buildOptions.rollupOptions
|
13594
|
+
const output = buildOptions.rollupOptions.output;
|
13595
13595
|
const outputLength = Array.isArray(output) ? output.length : 1;
|
13596
13596
|
if (state.outputCount >= outputLength) {
|
13597
13597
|
this.emitFile({
|
@@ -15704,7 +15704,7 @@ function createIsConfiguredAsExternal(environment) {
|
|
15704
15704
|
const { root, resolve } = config;
|
15705
15705
|
const { external, noExternal } = resolve;
|
15706
15706
|
const noExternalFilter = typeof noExternal !== "boolean" && !(Array.isArray(noExternal) && noExternal.length === 0) && createFilter(void 0, noExternal, { resolve: false });
|
15707
|
-
const targetConditions = resolve.externalConditions
|
15707
|
+
const targetConditions = resolve.externalConditions;
|
15708
15708
|
const resolveOptions = {
|
15709
15709
|
...resolve,
|
15710
15710
|
root,
|
@@ -15812,14 +15812,14 @@ function resolvePlugin(resolveOptions) {
|
|
15812
15812
|
if (id.startsWith(browserExternalId)) {
|
15813
15813
|
return id;
|
15814
15814
|
}
|
15815
|
-
const isRequire = resolveOpts
|
15815
|
+
const isRequire = resolveOpts.custom?.["node-resolve"]?.isRequire ?? false;
|
15816
15816
|
const currentEnvironmentOptions = this.environment.config;
|
15817
15817
|
const options = {
|
15818
15818
|
isRequire,
|
15819
15819
|
...currentEnvironmentOptions.resolve,
|
15820
15820
|
...resolveOptions,
|
15821
15821
|
// plugin options + resolve options overrides
|
15822
|
-
scan: resolveOpts
|
15822
|
+
scan: resolveOpts.scan ?? resolveOptions.scan
|
15823
15823
|
};
|
15824
15824
|
const resolvedImports = resolveSubpathImports(id, importer, options);
|
15825
15825
|
if (resolvedImports) {
|
@@ -15832,7 +15832,7 @@ function resolvePlugin(resolveOptions) {
|
|
15832
15832
|
if (isTsRequest(importer) || resolveOpts.custom?.depScan?.loader?.startsWith("ts")) {
|
15833
15833
|
options.isFromTsImporter = true;
|
15834
15834
|
} else {
|
15835
|
-
const moduleLang = this.getModuleInfo(importer)?.meta
|
15835
|
+
const moduleLang = this.getModuleInfo(importer)?.meta.vite?.lang;
|
15836
15836
|
options.isFromTsImporter = moduleLang && isTsRequest(`.${moduleLang}`);
|
15837
15837
|
}
|
15838
15838
|
}
|
@@ -16115,7 +16115,7 @@ function tryNodeResolve(id, importer, options, depsOptimizer, externalize) {
|
|
16115
16115
|
const deepMatch = deepImportRE.exec(id);
|
16116
16116
|
const pkgId = deepMatch ? deepMatch[1] || deepMatch[2] : cleanUrl(id);
|
16117
16117
|
let basedir;
|
16118
|
-
if (dedupe
|
16118
|
+
if (dedupe.includes(pkgId)) {
|
16119
16119
|
basedir = root;
|
16120
16120
|
} else if (importer && path$d.isAbsolute(importer) && // css processing appends `*` for importer
|
16121
16121
|
(importer[importer.length - 1] === "*" || fs__default.existsSync(cleanUrl(importer)))) {
|
@@ -16126,7 +16126,7 @@ function tryNodeResolve(id, importer, options, depsOptimizer, externalize) {
|
|
16126
16126
|
let selfPkg = null;
|
16127
16127
|
if (!isBuiltin(id) && !id.includes("\0") && bareImportRE.test(id)) {
|
16128
16128
|
const selfPackageData = findNearestPackageData(basedir, packageCache);
|
16129
|
-
selfPkg = selfPackageData?.data.exports && selfPackageData
|
16129
|
+
selfPkg = selfPackageData?.data.exports && selfPackageData.data.name === pkgId ? selfPackageData : null;
|
16130
16130
|
}
|
16131
16131
|
const pkg = selfPkg || resolvePackageData(pkgId, basedir, preserveSymlinks, packageCache);
|
16132
16132
|
if (!pkg) {
|
@@ -16158,7 +16158,7 @@ function tryNodeResolve(id, importer, options, depsOptimizer, externalize) {
|
|
16158
16158
|
return resolved2;
|
16159
16159
|
}
|
16160
16160
|
let resolvedId = id;
|
16161
|
-
if (deepMatch && !pkg
|
16161
|
+
if (deepMatch && !pkg.data.exports && path$d.extname(id) !== path$d.extname(resolved2.id)) {
|
16162
16162
|
const index = resolved2.id.indexOf(id);
|
16163
16163
|
if (index > -1) {
|
16164
16164
|
resolvedId = resolved2.id.slice(index);
|
@@ -16489,7 +16489,7 @@ const externalTypes = [
|
|
16489
16489
|
function esbuildDepPlugin(environment, qualified, external) {
|
16490
16490
|
const { isProduction } = environment.config;
|
16491
16491
|
const { extensions } = environment.config.optimizeDeps;
|
16492
|
-
const allExternalTypes = extensions ? externalTypes.filter((type) => !extensions
|
16492
|
+
const allExternalTypes = extensions ? externalTypes.filter((type) => !extensions.includes("." + type)) : externalTypes;
|
16493
16493
|
const esmPackageCache = /* @__PURE__ */ new Map();
|
16494
16494
|
const cjsPackageCache = /* @__PURE__ */ new Map();
|
16495
16495
|
const _resolve = createBackCompatIdResolver(environment.getTopLevelConfig(), {
|
@@ -17849,7 +17849,7 @@ function scanImports(environment) {
|
|
17849
17849
|
});
|
17850
17850
|
});
|
17851
17851
|
}
|
17852
|
-
if (!context || scanContext
|
17852
|
+
if (!context || scanContext.cancelled) {
|
17853
17853
|
disposeContext();
|
17854
17854
|
return { deps: {}, missing: {} };
|
17855
17855
|
}
|
@@ -17899,7 +17899,7 @@ function scanImports(environment) {
|
|
17899
17899
|
async function computeEntries(environment) {
|
17900
17900
|
let entries = [];
|
17901
17901
|
const explicitEntryPatterns = environment.config.optimizeDeps.entries;
|
17902
|
-
const buildInput = environment.config.build.rollupOptions
|
17902
|
+
const buildInput = environment.config.build.rollupOptions.input;
|
17903
17903
|
if (explicitEntryPatterns) {
|
17904
17904
|
entries = await globEntries(explicitEntryPatterns, environment);
|
17905
17905
|
} else if (buildInput) {
|
@@ -17932,7 +17932,7 @@ async function computeEntries(environment) {
|
|
17932
17932
|
return entries;
|
17933
17933
|
}
|
17934
17934
|
async function prepareEsbuildScanner(environment, entries, deps, missing, scanContext) {
|
17935
|
-
if (scanContext
|
17935
|
+
if (scanContext.cancelled) return;
|
17936
17936
|
const plugin = esbuildScanPlugin(environment, deps, missing, entries);
|
17937
17937
|
const { plugins = [], ...esbuildOptions } = environment.config.optimizeDeps.esbuildOptions ?? {};
|
17938
17938
|
let tsconfigRaw = esbuildOptions.tsconfigRaw;
|
@@ -18473,7 +18473,7 @@ function addOptimizedDepInfo(metadata, type, depInfo) {
|
|
18473
18473
|
return depInfo;
|
18474
18474
|
}
|
18475
18475
|
let firstLoadCachedDepOptimizationMetadata = true;
|
18476
|
-
async function loadCachedDepOptimizationMetadata(environment, force = environment.config.optimizeDeps
|
18476
|
+
async function loadCachedDepOptimizationMetadata(environment, force = environment.config.optimizeDeps.force ?? false, asCommand = false) {
|
18477
18477
|
const log = asCommand ? environment.logger.info : debug$c;
|
18478
18478
|
if (firstLoadCachedDepOptimizationMetadata) {
|
18479
18479
|
firstLoadCachedDepOptimizationMetadata = false;
|
@@ -18759,7 +18759,7 @@ async function prepareEsbuildOptimizerRun(environment, depsInfo, processingCache
|
|
18759
18759
|
const flatIdDeps = {};
|
18760
18760
|
const idToExports = {};
|
18761
18761
|
const { optimizeDeps: optimizeDeps2 } = environment.config;
|
18762
|
-
const { plugins: pluginsFromConfig = [], ...esbuildOptions } = optimizeDeps2
|
18762
|
+
const { plugins: pluginsFromConfig = [], ...esbuildOptions } = optimizeDeps2.esbuildOptions ?? {};
|
18763
18763
|
await Promise.all(
|
18764
18764
|
Object.keys(depsInfo).map(async (id) => {
|
18765
18765
|
const src = depsInfo[id].src;
|
@@ -18785,7 +18785,7 @@ async function prepareEsbuildOptimizerRun(environment, depsInfo, processingCache
|
|
18785
18785
|
// when the platform is 'node' or 'browser' that can't be emulated by using mainFields
|
18786
18786
|
// and conditions
|
18787
18787
|
(environment.config.consumer === "client" || environment.config.ssr.target === "webworker" ? "browser" : "node");
|
18788
|
-
const external = [...optimizeDeps2
|
18788
|
+
const external = [...optimizeDeps2.exclude ?? []];
|
18789
18789
|
const plugins = [...pluginsFromConfig];
|
18790
18790
|
if (external.length) {
|
18791
18791
|
plugins.push(esbuildCjsExternalPlugin(external, platform));
|
@@ -18823,7 +18823,7 @@ async function prepareEsbuildOptimizerRun(environment, depsInfo, processingCache
|
|
18823
18823
|
async function addManuallyIncludedOptimizeDeps(environment, deps) {
|
18824
18824
|
const { logger } = environment;
|
18825
18825
|
const { optimizeDeps: optimizeDeps2 } = environment.config;
|
18826
|
-
const optimizeDepsInclude = optimizeDeps2
|
18826
|
+
const optimizeDepsInclude = optimizeDeps2.include ?? [];
|
18827
18827
|
if (optimizeDepsInclude.length) {
|
18828
18828
|
const unableToOptimize = (id, msg) => {
|
18829
18829
|
if (optimizeDepsInclude.includes(id)) {
|
@@ -18999,7 +18999,7 @@ function esbuildOutputFromId(outputs, id, cacheDirOutputPath) {
|
|
18999
18999
|
async function extractExportsData(environment, filePath) {
|
19000
19000
|
await init;
|
19001
19001
|
const { optimizeDeps: optimizeDeps2 } = environment.config;
|
19002
|
-
const esbuildOptions = optimizeDeps2
|
19002
|
+
const esbuildOptions = optimizeDeps2.esbuildOptions ?? {};
|
19003
19003
|
if (optimizeDeps2.extensions?.some((ext) => filePath.endsWith(ext))) {
|
19004
19004
|
const result = await build$b({
|
19005
19005
|
...esbuildOptions,
|
@@ -19043,7 +19043,7 @@ async function extractExportsData(environment, filePath) {
|
|
19043
19043
|
return exportsData;
|
19044
19044
|
}
|
19045
19045
|
function needsInterop(environment, id, exportsData, output) {
|
19046
|
-
if (environment.config.optimizeDeps
|
19046
|
+
if (environment.config.optimizeDeps.needsInterop?.includes(id)) {
|
19047
19047
|
return true;
|
19048
19048
|
}
|
19049
19049
|
const { hasModuleSyntax, exports } = exportsData;
|
@@ -19052,7 +19052,7 @@ function needsInterop(environment, id, exportsData, output) {
|
|
19052
19052
|
}
|
19053
19053
|
if (output) {
|
19054
19054
|
const generatedExports = output.exports;
|
19055
|
-
if (
|
19055
|
+
if (isSingleDefaultExport(generatedExports) && !isSingleDefaultExport(exports)) {
|
19056
19056
|
return true;
|
19057
19057
|
}
|
19058
19058
|
}
|
@@ -19107,11 +19107,11 @@ function getConfigHash(environment) {
|
|
19107
19107
|
assetsInclude: config.assetsInclude,
|
19108
19108
|
plugins: config.plugins.map((p) => p.name),
|
19109
19109
|
optimizeDeps: {
|
19110
|
-
include: optimizeDeps2
|
19111
|
-
exclude: optimizeDeps2
|
19110
|
+
include: optimizeDeps2.include ? unique(optimizeDeps2.include).sort() : void 0,
|
19111
|
+
exclude: optimizeDeps2.exclude ? unique(optimizeDeps2.exclude).sort() : void 0,
|
19112
19112
|
esbuildOptions: {
|
19113
|
-
...optimizeDeps2
|
19114
|
-
plugins: optimizeDeps2
|
19113
|
+
...optimizeDeps2.esbuildOptions,
|
19114
|
+
plugins: optimizeDeps2.esbuildOptions?.plugins?.map((p) => p.name)
|
19115
19115
|
}
|
19116
19116
|
}
|
19117
19117
|
},
|
@@ -19218,7 +19218,7 @@ const safeRename = promisify$4(function gracefulRename(from, to, cb) {
|
|
19218
19218
|
if (backoff < 100) backoff += 10;
|
19219
19219
|
return;
|
19220
19220
|
}
|
19221
|
-
|
19221
|
+
cb(er);
|
19222
19222
|
});
|
19223
19223
|
});
|
19224
19224
|
|
@@ -19285,9 +19285,9 @@ function jsonPlugin(options, isBuild) {
|
|
19285
19285
|
map: { mappings: "" }
|
19286
19286
|
};
|
19287
19287
|
}
|
19288
|
-
if (options.stringify === true || // use 10kB as a threshold
|
19288
|
+
if (options.stringify === true || // use 10kB as a threshold for 'auto'
|
19289
19289
|
// 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
|
19290
|
-
|
19290
|
+
json.length > 10 * 1e3) {
|
19291
19291
|
if (isBuild) {
|
19292
19292
|
json = JSON.stringify(JSON.parse(json));
|
19293
19293
|
}
|
@@ -30425,7 +30425,7 @@ function ssrRewriteStacktrace(stack, moduleGraph) {
|
|
30425
30425
|
// stacktrace's column is 1-indexed, but sourcemap's one is 0-indexed
|
30426
30426
|
column: Number(column) - 1
|
30427
30427
|
});
|
30428
|
-
if (!pos.source
|
30428
|
+
if (!pos.source) {
|
30429
30429
|
return input;
|
30430
30430
|
}
|
30431
30431
|
const trimmedVarName = varName.trim();
|
@@ -31201,7 +31201,7 @@ function walk(root, { onIdentifier, onImportMeta, onDynamicImport, onStatements
|
|
31201
31201
|
scopeIds.add(name);
|
31202
31202
|
};
|
31203
31203
|
function isInScope(name, parents) {
|
31204
|
-
return parents.some((node) =>
|
31204
|
+
return parents.some((node) => scopeMap.get(node)?.has(name));
|
31205
31205
|
}
|
31206
31206
|
function handlePattern(p, parentScope) {
|
31207
31207
|
if (p.type === "Identifier") {
|
@@ -31270,12 +31270,12 @@ function walk(root, { onIdentifier, onImportMeta, onDynamicImport, onStatements
|
|
31270
31270
|
}
|
31271
31271
|
walk$1(p.type === "AssignmentPattern" ? p.left : p, {
|
31272
31272
|
enter(child, parent2) {
|
31273
|
-
if (parent2?.type === "AssignmentPattern" && parent2
|
31273
|
+
if (parent2?.type === "AssignmentPattern" && parent2.right === child) {
|
31274
31274
|
return this.skip();
|
31275
31275
|
}
|
31276
31276
|
if (child.type !== "Identifier") return;
|
31277
31277
|
if (isStaticPropertyKey(child, parent2)) return;
|
31278
|
-
if (parent2?.type === "TemplateLiteral" && parent2
|
31278
|
+
if (parent2?.type === "TemplateLiteral" && parent2.expressions.includes(child) || parent2?.type === "CallExpression" && parent2.callee === child) {
|
31279
31279
|
return;
|
31280
31280
|
}
|
31281
31281
|
setScope(node, child.name);
|
@@ -31351,8 +31351,8 @@ function isRefIdentifier(id, parent, parentStack) {
|
|
31351
31351
|
}
|
31352
31352
|
return true;
|
31353
31353
|
}
|
31354
|
-
const isStaticProperty = (node) => node
|
31355
|
-
const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
|
31354
|
+
const isStaticProperty = (node) => node.type === "Property" && !node.computed;
|
31355
|
+
const isStaticPropertyKey = (node, parent) => parent && isStaticProperty(parent) && parent.key === node;
|
31356
31356
|
const functionNodeTypeRE = /Function(?:Expression|Declaration)$|Method$/;
|
31357
31357
|
function isFunction$1(node) {
|
31358
31358
|
return functionNodeTypeRE.test(node.type);
|
@@ -31365,7 +31365,7 @@ function findParentScope(parentStack, isVar = false) {
|
|
31365
31365
|
return parentStack.find(isVar ? isFunction$1 : isBlock);
|
31366
31366
|
}
|
31367
31367
|
function isInDestructuringAssignment(parent, parentStack) {
|
31368
|
-
if (parent
|
31368
|
+
if (parent.type === "Property" || parent.type === "ArrayPattern") {
|
31369
31369
|
return parentStack.some((i) => i.type === "AssignmentExpression");
|
31370
31370
|
}
|
31371
31371
|
return false;
|
@@ -37488,7 +37488,7 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
37488
37488
|
off: noop$3,
|
37489
37489
|
setInvokeHandler: noop$3,
|
37490
37490
|
handleInvoke: async () => ({
|
37491
|
-
|
37491
|
+
error: {
|
37492
37492
|
name: "TransportError",
|
37493
37493
|
message: "handleInvoke not implemented",
|
37494
37494
|
stack: new Error().stack
|
@@ -40685,7 +40685,7 @@ const debugLoad = createDebugger("vite:load");
|
|
40685
40685
|
const debugTransform = createDebugger("vite:transform");
|
40686
40686
|
const debugCache$1 = createDebugger("vite:cache");
|
40687
40687
|
function transformRequest(environment, url, options = {}) {
|
40688
|
-
if (!options
|
40688
|
+
if (!options.ssr) {
|
40689
40689
|
options = { ...options, ssr: environment.config.consumer === "server" };
|
40690
40690
|
}
|
40691
40691
|
if (environment._closing && environment.config.dev.recoverable)
|
@@ -40761,12 +40761,16 @@ async function doTransform(environment, url, options, timestamp) {
|
|
40761
40761
|
}
|
40762
40762
|
async function getCachedTransformResult(environment, url, module, timestamp) {
|
40763
40763
|
const prettyUrl = debugCache$1 ? prettifyUrl(url, environment.config.root) : "";
|
40764
|
-
const softInvalidatedTransformResult =
|
40764
|
+
const softInvalidatedTransformResult = await handleModuleSoftInvalidation(
|
40765
|
+
environment,
|
40766
|
+
module,
|
40767
|
+
timestamp
|
40768
|
+
);
|
40765
40769
|
if (softInvalidatedTransformResult) {
|
40766
40770
|
debugCache$1?.(`[memory-hmr] ${prettyUrl}`);
|
40767
40771
|
return softInvalidatedTransformResult;
|
40768
40772
|
}
|
40769
|
-
const cached = module
|
40773
|
+
const cached = module.transformResult;
|
40770
40774
|
if (cached) {
|
40771
40775
|
debugCache$1?.(`[memory] ${prettyUrl}`);
|
40772
40776
|
return cached;
|
@@ -40849,7 +40853,7 @@ ${e}`, {
|
|
40849
40853
|
inMap: map
|
40850
40854
|
});
|
40851
40855
|
const originalCode = code;
|
40852
|
-
if (transformResult
|
40856
|
+
if (transformResult.code === originalCode) {
|
40853
40857
|
debugTransform?.(
|
40854
40858
|
timeFrom(transformStart) + colors$1.dim(` [skipped] ${prettyUrl}`)
|
40855
40859
|
);
|
@@ -40898,7 +40902,7 @@ ${e}`, {
|
|
40898
40902
|
const topLevelConfig = environment.getTopLevelConfig();
|
40899
40903
|
const result = environment.config.dev.moduleRunnerTransform ? await ssrTransform(code, normalizedMap, url, originalCode, {
|
40900
40904
|
json: {
|
40901
|
-
stringify: topLevelConfig.json
|
40905
|
+
stringify: topLevelConfig.json.stringify === true && topLevelConfig.json.namedExports !== true
|
40902
40906
|
}
|
40903
40907
|
}) : {
|
40904
40908
|
code,
|
@@ -41296,6 +41300,8 @@ function handleParseError(parserError, html, filePath) {
|
|
41296
41300
|
return;
|
41297
41301
|
case "non-void-html-element-start-tag-with-trailing-solidus":
|
41298
41302
|
return;
|
41303
|
+
case "unexpected-question-mark-instead-of-tag-name":
|
41304
|
+
return;
|
41299
41305
|
}
|
41300
41306
|
const parseError = formatParseError(parserError, filePath, html);
|
41301
41307
|
throw new Error(
|
@@ -41359,9 +41365,7 @@ function buildHtmlPlugin(config) {
|
|
41359
41365
|
let someScriptsAreAsync = false;
|
41360
41366
|
let someScriptsAreDefer = false;
|
41361
41367
|
const assetUrlsPromises = [];
|
41362
|
-
const namedOutput = Object.keys(
|
41363
|
-
config?.build?.rollupOptions?.input || {}
|
41364
|
-
);
|
41368
|
+
const namedOutput = Object.keys(config.build.rollupOptions.input || {});
|
41365
41369
|
const processAssetUrl = async (url, shouldInline) => {
|
41366
41370
|
if (url !== "" && // Empty attribute
|
41367
41371
|
!namedOutput.includes(url) && // Direct reference to named output
|
@@ -42193,7 +42197,7 @@ function cachedTransformMiddleware(server) {
|
|
42193
42197
|
const ifNoneMatch = req.headers["if-none-match"];
|
42194
42198
|
if (ifNoneMatch) {
|
42195
42199
|
const moduleByEtag = environment.moduleGraph.getModuleByEtag(ifNoneMatch);
|
42196
|
-
if (moduleByEtag?.transformResult?.etag === ifNoneMatch && moduleByEtag
|
42200
|
+
if (moduleByEtag?.transformResult?.etag === ifNoneMatch && moduleByEtag.url === req.url) {
|
42197
42201
|
const maybeMixedEtag = isCSSRequest(req.url);
|
42198
42202
|
if (!maybeMixedEtag) {
|
42199
42203
|
debugCache?.(`[304] ${prettifyUrl(req.url, server.config.root)}`);
|
@@ -42608,19 +42612,13 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
|
|
42608
42612
|
environment: server.environments.client
|
42609
42613
|
});
|
42610
42614
|
let content = "";
|
42611
|
-
if (result) {
|
42612
|
-
if (result.map
|
42613
|
-
|
42614
|
-
await injectSourcesContent(
|
42615
|
-
result.map,
|
42616
|
-
proxyModulePath,
|
42617
|
-
config.logger
|
42618
|
-
);
|
42619
|
-
}
|
42620
|
-
content = getCodeWithSourcemap("css", result.code, result.map);
|
42621
|
-
} else {
|
42622
|
-
content = result.code;
|
42615
|
+
if (result.map && "version" in result.map) {
|
42616
|
+
if (result.map.mappings) {
|
42617
|
+
await injectSourcesContent(result.map, proxyModulePath, config.logger);
|
42623
42618
|
}
|
42619
|
+
content = getCodeWithSourcemap("css", result.code, result.map);
|
42620
|
+
} else {
|
42621
|
+
content = result.code;
|
42624
42622
|
}
|
42625
42623
|
s.overwrite(start, end, content);
|
42626
42624
|
}),
|
@@ -43228,7 +43226,7 @@ function createBackwardCompatibleFileToModulesMap(moduleGraph) {
|
|
43228
43226
|
}
|
43229
43227
|
}
|
43230
43228
|
if (!found) {
|
43231
|
-
modules
|
43229
|
+
modules.add(ssrModule);
|
43232
43230
|
}
|
43233
43231
|
}
|
43234
43232
|
}
|
@@ -43325,7 +43323,7 @@ async function _createServer(inlineConfig = {}, options) {
|
|
43325
43323
|
const resolvedOutDirs = getResolvedOutDirs(
|
43326
43324
|
config.root,
|
43327
43325
|
config.build.outDir,
|
43328
|
-
config.build.rollupOptions
|
43326
|
+
config.build.rollupOptions.output
|
43329
43327
|
);
|
43330
43328
|
const emptyOutDir = resolveEmptyOutDir(
|
43331
43329
|
config.build.emptyOutDir,
|
@@ -43406,7 +43404,7 @@ async function _createServer(inlineConfig = {}, options) {
|
|
43406
43404
|
ssrTransform(code, inMap, url, originalCode = code) {
|
43407
43405
|
return ssrTransform(code, inMap, url, originalCode, {
|
43408
43406
|
json: {
|
43409
|
-
stringify: config.json
|
43407
|
+
stringify: config.json.stringify === true && config.json.namedExports !== true
|
43410
43408
|
}
|
43411
43409
|
});
|
43412
43410
|
},
|
@@ -44027,7 +44025,13 @@ const normalizeHotChannel = (channel, enableHmr, normalizeClient = true) => {
|
|
44027
44025
|
};
|
44028
44026
|
channel.on?.("vite:invoke", listenerForInvokeHandler);
|
44029
44027
|
},
|
44030
|
-
handleInvoke
|
44028
|
+
handleInvoke: async (payload) => {
|
44029
|
+
const data = await handleInvoke(payload);
|
44030
|
+
if (data.e) {
|
44031
|
+
return { error: data.e };
|
44032
|
+
}
|
44033
|
+
return { result: data.r };
|
44034
|
+
},
|
44031
44035
|
send: (...args) => {
|
44032
44036
|
let payload;
|
44033
44037
|
if (typeof args[0] === "string") {
|
@@ -44498,7 +44502,7 @@ function lexAcceptedHmrDeps(code, start, urls) {
|
|
44498
44502
|
} else {
|
44499
44503
|
return true;
|
44500
44504
|
}
|
44501
|
-
} else
|
44505
|
+
} else {
|
44502
44506
|
if (char === `]`) {
|
44503
44507
|
return false;
|
44504
44508
|
} else if (char === ",") {
|
@@ -44624,7 +44628,7 @@ function createDeprecatedHotBroadcaster(ws) {
|
|
44624
44628
|
send: ws.send,
|
44625
44629
|
setInvokeHandler: ws.setInvokeHandler,
|
44626
44630
|
handleInvoke: async () => ({
|
44627
|
-
|
44631
|
+
error: {
|
44628
44632
|
name: "TransportError",
|
44629
44633
|
message: "handleInvoke not implemented",
|
44630
44634
|
stack: new Error().stack
|
@@ -44637,9 +44641,7 @@ function createDeprecatedHotBroadcaster(ws) {
|
|
44637
44641
|
return broadcaster;
|
44638
44642
|
},
|
44639
44643
|
close() {
|
44640
|
-
return Promise.all(
|
44641
|
-
broadcaster.channels.map((channel) => channel.close?.())
|
44642
|
-
);
|
44644
|
+
return Promise.all(broadcaster.channels.map((channel) => channel.close()));
|
44643
44645
|
}
|
44644
44646
|
};
|
44645
44647
|
return broadcaster;
|
@@ -45189,7 +45191,7 @@ function preAliasPlugin(config) {
|
|
45189
45191
|
const { environment } = this;
|
45190
45192
|
const ssr = environment.config.consumer === "server";
|
45191
45193
|
const depsOptimizer = environment.mode === "dev" ? environment.depsOptimizer : void 0;
|
45192
|
-
if (importer && depsOptimizer && bareImportRE.test(id) && !options
|
45194
|
+
if (importer && depsOptimizer && bareImportRE.test(id) && !options.scan && id !== "@vite/client" && id !== "@vite/env") {
|
45193
45195
|
if (findPatterns.find((pattern) => matches(pattern, id))) {
|
45194
45196
|
const optimizedId = await tryOptimizedResolve(
|
45195
45197
|
depsOptimizer,
|
@@ -45242,9 +45244,6 @@ function matches(pattern, importee) {
|
|
45242
45244
|
return importee.startsWith(withTrailingSlash(pattern));
|
45243
45245
|
}
|
45244
45246
|
function getAliasPatterns(entries) {
|
45245
|
-
if (!entries) {
|
45246
|
-
return [];
|
45247
|
-
}
|
45248
45247
|
if (Array.isArray(entries)) {
|
45249
45248
|
return entries.map((entry) => entry.find);
|
45250
45249
|
}
|
@@ -45312,9 +45311,6 @@ function extractImportedBindings(id, source, importSpec, importedBindings) {
|
|
45312
45311
|
specifier: match.groups.specifier
|
45313
45312
|
};
|
45314
45313
|
const parsed = parseStaticImport(staticImport);
|
45315
|
-
if (!parsed) {
|
45316
|
-
return;
|
45317
|
-
}
|
45318
45314
|
if (parsed.namespacedImport) {
|
45319
45315
|
bindings.add("*");
|
45320
45316
|
}
|
@@ -45330,7 +45326,7 @@ function extractImportedBindings(id, source, importSpec, importedBindings) {
|
|
45330
45326
|
function importAnalysisPlugin(config) {
|
45331
45327
|
const { root, base } = config;
|
45332
45328
|
const clientPublicPath = path$d.posix.join(base, CLIENT_PUBLIC_PATH);
|
45333
|
-
const enablePartialAccept = config.experimental
|
45329
|
+
const enablePartialAccept = config.experimental.hmrPartialAccept;
|
45334
45330
|
const matchAlias = getAliasPatternMatcher(config.resolve.alias);
|
45335
45331
|
let _env;
|
45336
45332
|
let _ssrEnv;
|
@@ -46869,9 +46865,8 @@ class EnvironmentPluginContainer {
|
|
46869
46865
|
async hookParallel(hookName, context, args, condition) {
|
46870
46866
|
const parallelPromises = [];
|
46871
46867
|
for (const plugin of this.getSortedPlugins(hookName)) {
|
46872
|
-
const hook = plugin[hookName];
|
46873
|
-
if (!hook) continue;
|
46874
46868
|
if (condition && !condition(plugin)) continue;
|
46869
|
+
const hook = plugin[hookName];
|
46875
46870
|
const handler = getHookHandler(hook);
|
46876
46871
|
if (hook.sequential) {
|
46877
46872
|
await Promise.all(parallelPromises);
|
@@ -46921,7 +46916,6 @@ class EnvironmentPluginContainer {
|
|
46921
46916
|
for (const plugin of this.getSortedPlugins("resolveId")) {
|
46922
46917
|
if (this._closed && this.environment.config.dev.recoverable)
|
46923
46918
|
throwClosedServerError();
|
46924
|
-
if (!plugin.resolveId) continue;
|
46925
46919
|
if (skip?.has(plugin)) continue;
|
46926
46920
|
ctx._plugin = plugin;
|
46927
46921
|
const pluginResolveStart = debugPluginResolve ? performance.now() : 0;
|
@@ -46974,7 +46968,6 @@ class EnvironmentPluginContainer {
|
|
46974
46968
|
for (const plugin of this.getSortedPlugins("load")) {
|
46975
46969
|
if (this._closed && this.environment.config.dev.recoverable)
|
46976
46970
|
throwClosedServerError();
|
46977
|
-
if (!plugin.load) continue;
|
46978
46971
|
ctx._plugin = plugin;
|
46979
46972
|
const handler = getHookHandler(plugin.load);
|
46980
46973
|
const result = await this.handleHookPromise(
|
@@ -47000,7 +46993,6 @@ class EnvironmentPluginContainer {
|
|
47000
46993
|
for (const plugin of this.getSortedPlugins("transform")) {
|
47001
46994
|
if (this._closed && this.environment.config.dev.recoverable)
|
47002
46995
|
throwClosedServerError();
|
47003
|
-
if (!plugin.transform) continue;
|
47004
46996
|
ctx._updateActiveInfo(plugin, id, code);
|
47005
46997
|
const start = debugPluginTransform ? performance.now() : 0;
|
47006
46998
|
let result;
|
@@ -47082,7 +47074,7 @@ class PluginContext {
|
|
47082
47074
|
}
|
47083
47075
|
async resolve(id, importer, options) {
|
47084
47076
|
let skip;
|
47085
|
-
if (options?.skipSelf !== false
|
47077
|
+
if (options?.skipSelf !== false) {
|
47086
47078
|
skip = new Set(this._resolveSkips);
|
47087
47079
|
skip.add(this._plugin);
|
47088
47080
|
}
|
@@ -47167,7 +47159,7 @@ class PluginContext {
|
|
47167
47159
|
if (err.pluginCode) {
|
47168
47160
|
return err;
|
47169
47161
|
}
|
47170
|
-
|
47162
|
+
err.plugin = this._plugin.name;
|
47171
47163
|
if (this._activeId && !err.id) err.id = this._activeId;
|
47172
47164
|
if (this._activeCode) {
|
47173
47165
|
err.pluginCode = this._activeCode;
|
@@ -47213,7 +47205,7 @@ ${err2.stack || err2.message}
|
|
47213
47205
|
};
|
47214
47206
|
err.frame = err.frame || generateCodeFrame(this._activeCode, err.loc);
|
47215
47207
|
}
|
47216
|
-
if (this instanceof TransformPluginContext && typeof err.loc?.line === "number" && typeof err.loc
|
47208
|
+
if (this instanceof TransformPluginContext && typeof err.loc?.line === "number" && typeof err.loc.column === "number") {
|
47217
47209
|
const rawSourceMap = this._getCombinedSourcemap();
|
47218
47210
|
if (rawSourceMap && "version" in rawSourceMap) {
|
47219
47211
|
const traced = new TraceMap(rawSourceMap);
|
@@ -47221,7 +47213,7 @@ ${err2.stack || err2.message}
|
|
47221
47213
|
line: Number(err.loc.line),
|
47222
47214
|
column: Number(err.loc.column)
|
47223
47215
|
});
|
47224
|
-
if (source
|
47216
|
+
if (source) {
|
47225
47217
|
err.loc = { file: source, line, column };
|
47226
47218
|
}
|
47227
47219
|
}
|
@@ -47366,7 +47358,7 @@ class PluginContainer {
|
|
47366
47358
|
// Users should call pluginContainer.resolveId (and load/transform) passing the environment they want to work with
|
47367
47359
|
// But there is code that is going to call it without passing an environment, or with the ssr flag to get the ssr environment
|
47368
47360
|
_getEnvironment(options) {
|
47369
|
-
return options?.environment ? options.environment : this.environments
|
47361
|
+
return options?.environment ? options.environment : this.environments[options?.ssr ? "ssr" : "client"];
|
47370
47362
|
}
|
47371
47363
|
_getPluginContainer(options) {
|
47372
47364
|
return this._getEnvironment(options).pluginContainer;
|
@@ -47521,8 +47513,9 @@ function cssPlugin(config) {
|
|
47521
47513
|
extensions: []
|
47522
47514
|
});
|
47523
47515
|
let preprocessorWorkerController;
|
47524
|
-
if (config.css
|
47525
|
-
resolvePostcssConfig(config)
|
47516
|
+
if (config.css.transformer !== "lightningcss") {
|
47517
|
+
resolvePostcssConfig(config).catch(() => {
|
47518
|
+
});
|
47526
47519
|
}
|
47527
47520
|
return {
|
47528
47521
|
name: "vite:css",
|
@@ -47697,7 +47690,7 @@ function cssPostPlugin(config) {
|
|
47697
47690
|
const modulesCode = modules && !inlined && dataToEsm(modules, { namedExports: true, preferConst: true });
|
47698
47691
|
if (config.command === "serve") {
|
47699
47692
|
const getContentWithSourcemap = async (content) => {
|
47700
|
-
if (config.css
|
47693
|
+
if (config.css.devSourcemap) {
|
47701
47694
|
const sourcemap = this.getCombinedSourcemap();
|
47702
47695
|
if (sourcemap.mappings) {
|
47703
47696
|
await injectSourcesContent(sourcemap, cleanUrl(id), config.logger);
|
@@ -48100,7 +48093,15 @@ function getEmptyChunkReplacer(pureCssChunkNames, outputFormat) {
|
|
48100
48093
|
return (code) => code.replace(
|
48101
48094
|
emptyChunkRE,
|
48102
48095
|
// remove css import while preserving source map location
|
48103
|
-
(m
|
48096
|
+
(m, p1, p2) => {
|
48097
|
+
if (outputFormat === "es") {
|
48098
|
+
return `/* empty css ${"".padEnd(m.length - 15)}*/`;
|
48099
|
+
}
|
48100
|
+
if (p2 === ";") {
|
48101
|
+
return `${p2}/* empty css ${"".padEnd(m.length - 16)}*/`;
|
48102
|
+
}
|
48103
|
+
return `${p1}/* empty css ${"".padEnd(m.length - 15 - p1.length)}*/`;
|
48104
|
+
}
|
48104
48105
|
);
|
48105
48106
|
}
|
48106
48107
|
function createCSSResolvers(config) {
|
@@ -48152,7 +48153,7 @@ function getCssResolversKeys(resolvers) {
|
|
48152
48153
|
}
|
48153
48154
|
async function compileCSSPreprocessors(environment, id, lang, code, workerController) {
|
48154
48155
|
const { config } = environment;
|
48155
|
-
const { preprocessorOptions, devSourcemap } = config.css
|
48156
|
+
const { preprocessorOptions, devSourcemap } = config.css;
|
48156
48157
|
const atImportResolvers = getAtImportResolvers(
|
48157
48158
|
environment.getTopLevelConfig()
|
48158
48159
|
);
|
@@ -48175,7 +48176,7 @@ async function compileCSSPreprocessors(environment, id, lang, code, workerContro
|
|
48175
48176
|
throw preprocessResult.error;
|
48176
48177
|
}
|
48177
48178
|
let deps;
|
48178
|
-
if (preprocessResult.deps) {
|
48179
|
+
if (preprocessResult.deps.length > 0) {
|
48179
48180
|
const normalizedFilename = normalizePath$3(opts.filename);
|
48180
48181
|
deps = new Set(
|
48181
48182
|
[...preprocessResult.deps].filter(
|
@@ -48204,10 +48205,10 @@ function getAtImportResolvers(config) {
|
|
48204
48205
|
}
|
48205
48206
|
async function compileCSS(environment, id, code, workerController, urlReplacer) {
|
48206
48207
|
const { config } = environment;
|
48207
|
-
if (config.css
|
48208
|
+
if (config.css.transformer === "lightningcss") {
|
48208
48209
|
return compileLightningCSS(id, code, environment, urlReplacer);
|
48209
48210
|
}
|
48210
|
-
const { modules: modulesOptions, devSourcemap } = config.css
|
48211
|
+
const { modules: modulesOptions, devSourcemap } = config.css;
|
48211
48212
|
const isModule = modulesOptions !== false && cssModuleRE.test(id);
|
48212
48213
|
const needInlineImport = code.includes("@import");
|
48213
48214
|
const hasUrl = cssUrlRE.test(code) || cssImageSetRE.test(code);
|
@@ -48236,8 +48237,8 @@ async function compileCSS(environment, id, code, workerController, urlReplacer)
|
|
48236
48237
|
const atImportResolvers = getAtImportResolvers(
|
48237
48238
|
environment.getTopLevelConfig()
|
48238
48239
|
);
|
48239
|
-
const postcssOptions = postcssConfig
|
48240
|
-
const postcssPlugins = postcssConfig
|
48240
|
+
const postcssOptions = postcssConfig?.options ?? {};
|
48241
|
+
const postcssPlugins = postcssConfig?.plugins.slice() ?? [];
|
48241
48242
|
if (needInlineImport) {
|
48242
48243
|
postcssPlugins.unshift(
|
48243
48244
|
(await importPostcssImport()).default({
|
@@ -48432,8 +48433,8 @@ function createCachedImport(imp) {
|
|
48432
48433
|
return cached;
|
48433
48434
|
};
|
48434
48435
|
}
|
48435
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
48436
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
48436
|
+
const importPostcssImport = createCachedImport(() => import('./dep-CjE1AkI6.js').then(function (n) { return n.i; }));
|
48437
|
+
const importPostcssModules = createCachedImport(() => import('./dep-BiVmWRQp.js').then(function (n) { return n.i; }));
|
48437
48438
|
const importPostcss = createCachedImport(() => import('postcss'));
|
48438
48439
|
const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
|
48439
48440
|
let alwaysFakeWorkerWorkerControllerCache;
|
@@ -48492,7 +48493,7 @@ async function resolvePostcssConfig(config) {
|
|
48492
48493
|
if (result !== void 0) {
|
48493
48494
|
return await result;
|
48494
48495
|
}
|
48495
|
-
const inlineOptions = config.css
|
48496
|
+
const inlineOptions = config.css.postcss;
|
48496
48497
|
if (isObject$2(inlineOptions)) {
|
48497
48498
|
const options = { ...inlineOptions };
|
48498
48499
|
delete options.plugins;
|
@@ -48518,9 +48519,13 @@ ${stack}`;
|
|
48518
48519
|
}
|
48519
48520
|
return null;
|
48520
48521
|
});
|
48521
|
-
result.then(
|
48522
|
-
|
48523
|
-
|
48522
|
+
result.then(
|
48523
|
+
(resolved) => {
|
48524
|
+
postcssConfigCache.set(config, resolved);
|
48525
|
+
},
|
48526
|
+
() => {
|
48527
|
+
}
|
48528
|
+
);
|
48524
48529
|
}
|
48525
48530
|
postcssConfigCache.set(config, result);
|
48526
48531
|
return result;
|
@@ -48550,14 +48555,22 @@ const UrlRewritePostcssPlugin = (opts) => {
|
|
48550
48555
|
const replacerForDeclaration = (rawUrl) => {
|
48551
48556
|
return opts.replacer(rawUrl, importer);
|
48552
48557
|
};
|
48553
|
-
|
48554
|
-
|
48555
|
-
|
48556
|
-
(url) => {
|
48558
|
+
if (isCssUrl && isCssImageSet) {
|
48559
|
+
promises.push(
|
48560
|
+
rewriteCssUrls(declaration.value, replacerForDeclaration).then((url) => rewriteCssImageSet(url, replacerForDeclaration)).then((url) => {
|
48557
48561
|
declaration.value = url;
|
48558
|
-
}
|
48559
|
-
)
|
48560
|
-
|
48562
|
+
})
|
48563
|
+
);
|
48564
|
+
} else {
|
48565
|
+
const rewriterToUse = isCssImageSet ? rewriteCssImageSet : rewriteCssUrls;
|
48566
|
+
promises.push(
|
48567
|
+
rewriterToUse(declaration.value, replacerForDeclaration).then(
|
48568
|
+
(url) => {
|
48569
|
+
declaration.value = url;
|
48570
|
+
}
|
48571
|
+
)
|
48572
|
+
);
|
48573
|
+
}
|
48561
48574
|
}
|
48562
48575
|
});
|
48563
48576
|
if (promises.length) {
|
@@ -48642,7 +48655,7 @@ async function doImportCSSReplace(rawUrl, matched, replacer) {
|
|
48642
48655
|
async function minifyCSS(css, config, inlined) {
|
48643
48656
|
if (config.build.cssMinify === "lightningcss") {
|
48644
48657
|
const { code, warnings } = (await importLightningCSS()).transform({
|
48645
|
-
...config.css
|
48658
|
+
...config.css.lightningcss,
|
48646
48659
|
targets: convertTargets(config.build.cssTarget),
|
48647
48660
|
cssModules: void 0,
|
48648
48661
|
// TODO: Pass actual filename here, which can also be passed to esbuild's
|
@@ -48774,7 +48787,7 @@ function loadSss(root) {
|
|
48774
48787
|
function cleanScssBugUrl(url) {
|
48775
48788
|
if (
|
48776
48789
|
// check bug via `window` and `location` global
|
48777
|
-
typeof window !== "undefined" && typeof location !== "undefined" && typeof location
|
48790
|
+
typeof window !== "undefined" && typeof location !== "undefined" && typeof location.href === "string"
|
48778
48791
|
) {
|
48779
48792
|
const prefix = location.href.replace(/\/$/, "");
|
48780
48793
|
return url.replace(prefix, "");
|
@@ -48822,7 +48835,7 @@ const makeScssWorker = (environment, resolvers, alias, maxWorkers, packageName)
|
|
48822
48835
|
const path2 = require("node:path");
|
48823
48836
|
const _internalImporter = (url, importer2, done) => {
|
48824
48837
|
internalImporter(url, importer2, options.filename).then(
|
48825
|
-
(data2) => done
|
48838
|
+
(data2) => done(data2)
|
48826
48839
|
);
|
48827
48840
|
};
|
48828
48841
|
const importer = [_internalImporter];
|
@@ -49143,13 +49156,10 @@ const makeLessWorker = (environment, resolvers, alias, maxWorkers) => {
|
|
49143
49156
|
"@",
|
49144
49157
|
resolvers.less
|
49145
49158
|
);
|
49146
|
-
|
49147
|
-
|
49148
|
-
|
49149
|
-
|
49150
|
-
};
|
49151
|
-
}
|
49152
|
-
return result;
|
49159
|
+
return {
|
49160
|
+
resolved,
|
49161
|
+
contents: "contents" in result ? result.contents : void 0
|
49162
|
+
};
|
49153
49163
|
};
|
49154
49164
|
const worker = new WorkerWithFallback(
|
49155
49165
|
() => {
|
@@ -49455,11 +49465,11 @@ async function compileLightningCSS(id, src, environment, urlReplacer) {
|
|
49455
49465
|
res = styleAttrRE.test(id) ? (await importLightningCSS()).transformStyleAttribute({
|
49456
49466
|
filename,
|
49457
49467
|
code: Buffer.from(src),
|
49458
|
-
targets: config.css
|
49468
|
+
targets: config.css.lightningcss?.targets,
|
49459
49469
|
minify: config.isProduction && !!config.build.cssMinify,
|
49460
49470
|
analyzeDependencies: true
|
49461
49471
|
}) : await (await importLightningCSS()).bundleAsync({
|
49462
|
-
...config.css
|
49472
|
+
...config.css.lightningcss,
|
49463
49473
|
filename,
|
49464
49474
|
resolver: {
|
49465
49475
|
read(filePath) {
|
@@ -49490,9 +49500,9 @@ async function compileLightningCSS(id, src, environment, urlReplacer) {
|
|
49490
49500
|
}
|
49491
49501
|
},
|
49492
49502
|
minify: config.isProduction && !!config.build.cssMinify,
|
49493
|
-
sourceMap: config.command === "build" ? !!config.build.sourcemap : config.css
|
49503
|
+
sourceMap: config.command === "build" ? !!config.build.sourcemap : config.css.devSourcemap,
|
49494
49504
|
analyzeDependencies: true,
|
49495
|
-
cssModules: cssModuleRE.test(id) ? config.css
|
49505
|
+
cssModules: cssModuleRE.test(id) ? config.css.lightningcss?.cssModules ?? true : void 0
|
49496
49506
|
});
|
49497
49507
|
} catch (e) {
|
49498
49508
|
e.message = `[lightningcss] ${e.message}`;
|
@@ -50105,7 +50115,7 @@ function buildImportAnalysisPlugin(config) {
|
|
50105
50115
|
);
|
50106
50116
|
chunk.code += `
|
50107
50117
|
//# sourceMappingURL=${genSourceMapUrl(map)}`;
|
50108
|
-
} else
|
50118
|
+
} else {
|
50109
50119
|
const mapAsset = bundle[chunk.fileName + ".map"];
|
50110
50120
|
if (mapAsset && mapAsset.type === "asset") {
|
50111
50121
|
mapAsset.source = map.toString();
|
@@ -50278,7 +50288,7 @@ const buildEnvironmentOptionsDefaults = Object.freeze({
|
|
50278
50288
|
// createEnvironment
|
50279
50289
|
});
|
50280
50290
|
function resolveBuildEnvironmentOptions(raw, logger, consumer) {
|
50281
|
-
const deprecatedPolyfillModulePreload = raw
|
50291
|
+
const deprecatedPolyfillModulePreload = raw.polyfillModulePreload;
|
50282
50292
|
const { polyfillModulePreload, ...rest } = raw;
|
50283
50293
|
raw = rest;
|
50284
50294
|
if (deprecatedPolyfillModulePreload !== void 0) {
|
@@ -50381,12 +50391,12 @@ async function buildEnvironment(environment) {
|
|
50381
50391
|
)
|
50382
50392
|
);
|
50383
50393
|
const resolve = (p) => path$d.resolve(root, p);
|
50384
|
-
const input = libOptions ? options.rollupOptions
|
50394
|
+
const input = libOptions ? options.rollupOptions.input || (typeof libOptions.entry === "string" ? resolve(libOptions.entry) : Array.isArray(libOptions.entry) ? libOptions.entry.map(resolve) : Object.fromEntries(
|
50385
50395
|
Object.entries(libOptions.entry).map(([alias, file]) => [
|
50386
50396
|
alias,
|
50387
50397
|
resolve(file)
|
50388
50398
|
])
|
50389
|
-
)) : typeof options.ssr === "string" ? resolve(options.ssr) : options.rollupOptions
|
50399
|
+
)) : typeof options.ssr === "string" ? resolve(options.ssr) : options.rollupOptions.input || resolve("index.html");
|
50390
50400
|
if (ssr && typeof input === "string" && input.endsWith(".html")) {
|
50391
50401
|
throw new Error(
|
50392
50402
|
`rollupOptions.input should not be an html file when building for SSR. Please specify a dedicated SSR entry.`
|
@@ -50411,7 +50421,7 @@ async function buildEnvironment(environment) {
|
|
50411
50421
|
output: options.rollupOptions.output,
|
50412
50422
|
input,
|
50413
50423
|
plugins,
|
50414
|
-
external: options.rollupOptions
|
50424
|
+
external: options.rollupOptions.external,
|
50415
50425
|
onwarn(warning, warn) {
|
50416
50426
|
onRollupWarning(warning, warn, environment);
|
50417
50427
|
}
|
@@ -50512,7 +50522,7 @@ ${stackOnly}`;
|
|
50512
50522
|
};
|
50513
50523
|
};
|
50514
50524
|
const outputs = resolveBuildOutputs(
|
50515
|
-
options.rollupOptions
|
50525
|
+
options.rollupOptions.output,
|
50516
50526
|
libOptions,
|
50517
50527
|
logger
|
50518
50528
|
);
|
@@ -50527,7 +50537,7 @@ ${stackOnly}`;
|
|
50527
50537
|
const resolvedOutDirs = getResolvedOutDirs(
|
50528
50538
|
root,
|
50529
50539
|
options.outDir,
|
50530
|
-
options.rollupOptions
|
50540
|
+
options.rollupOptions.output
|
50531
50541
|
);
|
50532
50542
|
const emptyOutDir = resolveEmptyOutDir(
|
50533
50543
|
options.emptyOutDir,
|
@@ -50743,7 +50753,7 @@ If you do want to externalize this module explicitly add it to
|
|
50743
50753
|
warn(warnLog);
|
50744
50754
|
};
|
50745
50755
|
clearLine();
|
50746
|
-
const userOnWarn = environment.config.build.rollupOptions
|
50756
|
+
const userOnWarn = environment.config.build.rollupOptions.onwarn;
|
50747
50757
|
if (userOnWarn) {
|
50748
50758
|
userOnWarn(warning, viteWarn);
|
50749
50759
|
} else {
|
@@ -50993,7 +51003,7 @@ class BuildEnvironment extends BaseEnvironment {
|
|
50993
51003
|
if (setup?.options) {
|
50994
51004
|
options = mergeConfig(
|
50995
51005
|
options,
|
50996
|
-
setup
|
51006
|
+
setup.options
|
50997
51007
|
);
|
50998
51008
|
}
|
50999
51009
|
super(name, config, options);
|
@@ -52248,12 +52258,12 @@ class DevEnvironment extends BaseEnvironment {
|
|
52248
52258
|
}
|
52249
52259
|
async close() {
|
52250
52260
|
this._closing = true;
|
52251
|
-
this._crawlEndFinder
|
52261
|
+
this._crawlEndFinder.cancel();
|
52252
52262
|
await Promise.allSettled([
|
52253
52263
|
this.pluginContainer.close(),
|
52254
52264
|
this.depsOptimizer?.close(),
|
52255
52265
|
// WebSocketServer is independent of HotChannel and should not be closed on environment close
|
52256
|
-
isWebSocketServer in this.hot ? Promise.resolve() : this.hot.close
|
52266
|
+
isWebSocketServer in this.hot ? Promise.resolve() : this.hot.close(),
|
52257
52267
|
(async () => {
|
52258
52268
|
while (this._pendingRequests.size > 0) {
|
52259
52269
|
await Promise.allSettled(
|
@@ -52523,7 +52533,7 @@ async function preview(inlineConfig = {}) {
|
|
52523
52533
|
"production",
|
52524
52534
|
true
|
52525
52535
|
);
|
52526
|
-
const clientOutDir = config.environments.client.build.outDir
|
52536
|
+
const clientOutDir = config.environments.client.build.outDir;
|
52527
52537
|
const distDir = path$d.resolve(config.root, clientOutDir);
|
52528
52538
|
if (!fs__default.existsSync(distDir) && // error if no plugins implement `configurePreviewServer`
|
52529
52539
|
config.plugins.every((plugin) => !plugin.configurePreviewServer) && // error if called in CLI only. programmatic usage could access `httpServer`
|
@@ -52537,7 +52547,7 @@ async function preview(inlineConfig = {}) {
|
|
52537
52547
|
const httpServer = await resolveHttpServer(
|
52538
52548
|
config.preview,
|
52539
52549
|
app,
|
52540
|
-
await resolveHttpsConfig(config.preview
|
52550
|
+
await resolveHttpsConfig(config.preview.https)
|
52541
52551
|
);
|
52542
52552
|
setClientErrorHandler(httpServer, config.logger);
|
52543
52553
|
const options = config.preview;
|
@@ -52628,7 +52638,7 @@ async function preview(inlineConfig = {}) {
|
|
52628
52638
|
config
|
52629
52639
|
);
|
52630
52640
|
if (options.open) {
|
52631
|
-
const url = server.resolvedUrls
|
52641
|
+
const url = server.resolvedUrls.local[0] ?? server.resolvedUrls.network[0];
|
52632
52642
|
if (url) {
|
52633
52643
|
const path2 = typeof options.open === "string" ? new URL(options.open, url).href : url;
|
52634
52644
|
openBrowser(path2, true, logger);
|
@@ -52969,7 +52979,9 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
52969
52979
|
return p.apply === command;
|
52970
52980
|
}
|
52971
52981
|
};
|
52972
|
-
const rawPlugins = (await asyncFlatten(config.plugins || [])).filter(
|
52982
|
+
const rawPlugins = (await asyncFlatten(config.plugins || [])).filter(
|
52983
|
+
filterPlugin
|
52984
|
+
);
|
52973
52985
|
const [prePlugins, normalPlugins, postPlugins] = sortUserPlugins(rawPlugins);
|
52974
52986
|
const isBuild = command === "build";
|
52975
52987
|
const userPlugins = [...prePlugins, ...normalPlugins, ...postPlugins];
|
@@ -52995,31 +53007,35 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
52995
53007
|
let configEnvironmentsSsr = config.environments.ssr;
|
52996
53008
|
const warmupOptions = config.server?.warmup;
|
52997
53009
|
if (warmupOptions?.clientFiles) {
|
52998
|
-
configEnvironmentsClient.dev.warmup = warmupOptions
|
53010
|
+
configEnvironmentsClient.dev.warmup = warmupOptions.clientFiles;
|
52999
53011
|
}
|
53000
53012
|
if (warmupOptions?.ssrFiles) {
|
53001
53013
|
configEnvironmentsSsr ??= {};
|
53002
53014
|
configEnvironmentsSsr.dev ??= {};
|
53003
|
-
configEnvironmentsSsr.dev.warmup = warmupOptions
|
53015
|
+
configEnvironmentsSsr.dev.warmup = warmupOptions.ssrFiles;
|
53004
53016
|
}
|
53005
53017
|
if (configEnvironmentsSsr) {
|
53006
53018
|
configEnvironmentsSsr.optimizeDeps = mergeConfig(
|
53007
53019
|
deprecatedSsrOptimizeDepsConfig,
|
53008
53020
|
configEnvironmentsSsr.optimizeDeps ?? {}
|
53009
53021
|
);
|
53010
|
-
configEnvironmentsSsr.resolve
|
53011
|
-
|
53012
|
-
|
53013
|
-
|
53014
|
-
|
53015
|
-
|
53022
|
+
configEnvironmentsSsr.resolve = mergeConfig(
|
53023
|
+
{
|
53024
|
+
conditions: config.ssr?.resolve?.conditions,
|
53025
|
+
externalConditions: config.ssr?.resolve?.externalConditions,
|
53026
|
+
mainFields: config.ssr?.resolve?.mainFields,
|
53027
|
+
external: config.ssr?.external,
|
53028
|
+
noExternal: config.ssr?.noExternal
|
53029
|
+
},
|
53030
|
+
configEnvironmentsSsr.resolve ?? {}
|
53031
|
+
);
|
53016
53032
|
}
|
53017
53033
|
if (config.build?.ssrEmitAssets !== void 0) {
|
53018
53034
|
configEnvironmentsSsr ??= {};
|
53019
53035
|
configEnvironmentsSsr.build ??= {};
|
53020
53036
|
configEnvironmentsSsr.build.emitAssets = config.build.ssrEmitAssets;
|
53021
53037
|
}
|
53022
|
-
if (!config.environments
|
53038
|
+
if (!config.environments.client || !config.environments.ssr && !isBuild) {
|
53023
53039
|
throw new Error(
|
53024
53040
|
"Required environments configuration were stripped out in the config hook"
|
53025
53041
|
);
|
@@ -53055,6 +53071,9 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
53055
53071
|
configEnv,
|
53056
53072
|
config.ssr?.target === "webworker"
|
53057
53073
|
);
|
53074
|
+
config.resolve ??= {};
|
53075
|
+
config.resolve.conditions = config.environments.client.resolve?.conditions;
|
53076
|
+
config.resolve.mainFields = config.environments.client.resolve?.mainFields;
|
53058
53077
|
const resolvedDefaultResolve = resolveResolveOptions(config.resolve, logger);
|
53059
53078
|
const resolvedEnvironments = {};
|
53060
53079
|
for (const environmentName of Object.keys(config.environments)) {
|
@@ -53109,7 +53128,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
53109
53128
|
}
|
53110
53129
|
const isProduction = process.env.NODE_ENV === "production";
|
53111
53130
|
const relativeBaseShortcut = config.base === "" || config.base === "./";
|
53112
|
-
const resolvedBase = relativeBaseShortcut ? !isBuild || config.build?.ssr ? "/" : "./" : resolveBaseUrl(config.base, isBuild, logger)
|
53131
|
+
const resolvedBase = relativeBaseShortcut ? !isBuild || config.build?.ssr ? "/" : "./" : resolveBaseUrl(config.base, isBuild, logger);
|
53113
53132
|
const pkgDir = findNearestPackageData(resolvedRoot, packageCache)?.dir;
|
53114
53133
|
const cacheDir = normalizePath$3(
|
53115
53134
|
config.cacheDir ? path$d.resolve(resolvedRoot, config.cacheDir) : pkgDir ? path$d.join(pkgDir, `node_modules/.vite`) : path$d.join(resolvedRoot, `.vite`)
|
@@ -53350,7 +53369,7 @@ assetFileNames isn't equal for every build.rollupOptions.output. A single patter
|
|
53350
53369
|
}
|
53351
53370
|
return resolved;
|
53352
53371
|
}
|
53353
|
-
function resolveBaseUrl(base =
|
53372
|
+
function resolveBaseUrl(base = configDefaults.base, isBuild, logger) {
|
53354
53373
|
if (base[0] === ".") {
|
53355
53374
|
logger.warn(
|
53356
53375
|
colors$1.yellow(
|
@@ -53451,6 +53470,8 @@ async function bundleConfigFile(fileName, isESM) {
|
|
53451
53470
|
format: isESM ? "esm" : "cjs",
|
53452
53471
|
mainFields: ["main"],
|
53453
53472
|
sourcemap: "inline",
|
53473
|
+
// the last slash is needed to make the path correct
|
53474
|
+
sourceRoot: path$d.dirname(fileName) + path$d.sep,
|
53454
53475
|
metafile: true,
|
53455
53476
|
define: {
|
53456
53477
|
__dirname: dirnameVarName,
|
@@ -53487,7 +53508,7 @@ async function bundleConfigFile(fileName, isESM) {
|
|
53487
53508
|
})?.id;
|
53488
53509
|
};
|
53489
53510
|
build2.onResolve(
|
53490
|
-
{ filter: /^[
|
53511
|
+
{ filter: /^[^.#].*/ },
|
53491
53512
|
async ({ path: id, importer, kind }) => {
|
53492
53513
|
if (kind === "entry-point" || path$d.isAbsolute(id) || isNodeBuiltin(id)) {
|
53493
53514
|
return;
|
@@ -53553,17 +53574,25 @@ async function bundleConfigFile(fileName, isESM) {
|
|
53553
53574
|
const { text } = result.outputFiles[0];
|
53554
53575
|
return {
|
53555
53576
|
code: text,
|
53556
|
-
dependencies:
|
53577
|
+
dependencies: Object.keys(result.metafile.inputs)
|
53557
53578
|
};
|
53558
53579
|
}
|
53559
53580
|
const _require = createRequire$1(import.meta.url);
|
53560
53581
|
async function loadConfigFromBundledFile(fileName, bundledCode, isESM) {
|
53561
53582
|
if (isESM) {
|
53562
|
-
|
53583
|
+
let nodeModulesDir = typeof process.versions.deno === "string" ? void 0 : findNearestNodeModules(path$d.dirname(fileName));
|
53563
53584
|
if (nodeModulesDir) {
|
53564
|
-
|
53565
|
-
|
53566
|
-
|
53585
|
+
try {
|
53586
|
+
await fsp.mkdir(path$d.resolve(nodeModulesDir, ".vite-temp/"), {
|
53587
|
+
recursive: true
|
53588
|
+
});
|
53589
|
+
} catch (e) {
|
53590
|
+
if (e.code === "EACCES") {
|
53591
|
+
nodeModulesDir = void 0;
|
53592
|
+
} else {
|
53593
|
+
throw e;
|
53594
|
+
}
|
53595
|
+
}
|
53567
53596
|
}
|
53568
53597
|
const hash = `timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
53569
53598
|
const tempFileName = nodeModulesDir ? path$d.resolve(
|
@@ -53600,11 +53629,9 @@ async function runConfigHook(config, plugins, configEnv) {
|
|
53600
53629
|
for (const p of getSortedPluginsByHook("config", plugins)) {
|
53601
53630
|
const hook = p.config;
|
53602
53631
|
const handler = getHookHandler(hook);
|
53603
|
-
|
53604
|
-
|
53605
|
-
|
53606
|
-
conf = mergeConfig(conf, res);
|
53607
|
-
}
|
53632
|
+
const res = await handler(conf, configEnv);
|
53633
|
+
if (res && res !== conf) {
|
53634
|
+
conf = mergeConfig(conf, res);
|
53608
53635
|
}
|
53609
53636
|
}
|
53610
53637
|
return conf;
|
@@ -53614,15 +53641,13 @@ async function runConfigEnvironmentHook(environments, plugins, configEnv, isSsrT
|
|
53614
53641
|
for (const p of getSortedPluginsByHook("configEnvironment", plugins)) {
|
53615
53642
|
const hook = p.configEnvironment;
|
53616
53643
|
const handler = getHookHandler(hook);
|
53617
|
-
|
53618
|
-
|
53619
|
-
|
53620
|
-
|
53621
|
-
|
53622
|
-
|
53623
|
-
|
53624
|
-
environments[name] = mergeConfig(environments[name], res);
|
53625
|
-
}
|
53644
|
+
for (const name of environmentNames) {
|
53645
|
+
const res = await handler(name, environments[name], {
|
53646
|
+
...configEnv,
|
53647
|
+
isSsrTargetWebworker: isSsrTargetWebworkerSet && name === "ssr"
|
53648
|
+
});
|
53649
|
+
if (res) {
|
53650
|
+
environments[name] = mergeConfig(environments[name], res);
|
53626
53651
|
}
|
53627
53652
|
}
|
53628
53653
|
}
|
@@ -53631,7 +53656,7 @@ function optimizeDepsDisabledBackwardCompatibility(resolved, optimizeDeps, optim
|
|
53631
53656
|
const optimizeDepsDisabled = optimizeDeps.disabled;
|
53632
53657
|
if (optimizeDepsDisabled !== void 0) {
|
53633
53658
|
if (optimizeDepsDisabled === true || optimizeDepsDisabled === "dev") {
|
53634
|
-
const commonjsOptionsInclude = resolved.build
|
53659
|
+
const commonjsOptionsInclude = resolved.build.commonjsOptions.include;
|
53635
53660
|
const commonjsPluginDisabled = Array.isArray(commonjsOptionsInclude) && commonjsOptionsInclude.length === 0;
|
53636
53661
|
optimizeDeps.noDiscovery = true;
|
53637
53662
|
optimizeDeps.include = void 0;
|