vite 6.0.1 → 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-ab_8SKHY.js → dep-BiVmWRQp.js} +1 -1
- package/dist/node/chunks/{dep-BnwAUvl5.js → dep-CjE1AkI6.js} +1 -1
- package/dist/node/chunks/{dep-BcnkIxro.js → dep-yUJfKD1i.js} +260 -231
- package/dist/node/cli.js +5 -5
- package/dist/node/index.d.ts +7 -5
- 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 +5 -5
@@ -7,7 +7,7 @@ import { promisify as promisify$4, format as format$2, inspect, stripVTControlCh
|
|
7
7
|
import { performance } from 'node:perf_hooks';
|
8
8
|
import require$$0$5, { createRequire as createRequire$1, builtinModules } from 'node:module';
|
9
9
|
import esbuild, { transform as transform$1, formatMessages, build as build$b } 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, DEV_PROD_CONDITION, JS_TYPES_RE, KNOWN_ASSET_TYPES, CSS_LANGS_RE, METADATA_FILENAME, ESBUILD_MODULES_TARGET, ERR_OPTIMIZE_DEPS_PROCESSING_ERROR, ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR, VITE_PACKAGE_DIR, DEFAULT_DEV_PORT, CLIENT_DIR, VERSION, ROLLUP_HOOKS, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES,
|
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_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR, VITE_PACKAGE_DIR, DEFAULT_DEV_PORT, CLIENT_DIR, VERSION, ROLLUP_HOOKS, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_CLIENT_MAIN_FIELDS, DEFAULT_SERVER_MAIN_FIELDS, DEFAULT_CLIENT_CONDITIONS, DEFAULT_SERVER_CONDITIONS } from '../constants.js';
|
11
11
|
import require$$0$2, { posix, win32, isAbsolute, resolve as resolve$3, relative as relative$1, basename as basename$1, extname, dirname as dirname$1, join, sep } from 'path';
|
12
12
|
import require$$0$3, { existsSync, readFileSync, statSync, readdirSync } from 'fs';
|
13
13
|
import childProcess$2, { exec, execFile, execSync } from 'node:child_process';
|
@@ -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
|
}
|
@@ -15936,7 +15936,7 @@ function resolvePlugin(resolveOptions) {
|
|
15936
15936
|
}
|
15937
15937
|
if (isBuiltin(id)) {
|
15938
15938
|
if (currentEnvironmentOptions.consumer === "server") {
|
15939
|
-
if (options.noExternal === true && // if both noExternal and external are true, noExternal will take the higher priority and bundle it.
|
15939
|
+
if (options.enableBuiltinNoExternalCheck && options.noExternal === true && // if both noExternal and external are true, noExternal will take the higher priority and bundle it.
|
15940
15940
|
// only if the id is explicitly listed in external, we will externalize it and skip this error.
|
15941
15941
|
(options.external === true || !options.external.includes(id))) {
|
15942
15942
|
let message = `Cannot bundle Node.js built-in "${id}"`;
|
@@ -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);
|
@@ -47991,7 +47984,10 @@ function cssPostPlugin(config) {
|
|
47991
47984
|
this.emitFile({
|
47992
47985
|
name: getCssBundleName(),
|
47993
47986
|
type: "asset",
|
47994
|
-
source: extractedCss
|
47987
|
+
source: extractedCss,
|
47988
|
+
// this file is an implicit entry point, use `style.css` as the original file name
|
47989
|
+
// this name is also used as a key in the manifest
|
47990
|
+
originalFileName: "style.css"
|
47995
47991
|
});
|
47996
47992
|
}
|
47997
47993
|
}
|
@@ -48097,7 +48093,15 @@ function getEmptyChunkReplacer(pureCssChunkNames, outputFormat) {
|
|
48097
48093
|
return (code) => code.replace(
|
48098
48094
|
emptyChunkRE,
|
48099
48095
|
// remove css import while preserving source map location
|
48100
|
-
(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
|
+
}
|
48101
48105
|
);
|
48102
48106
|
}
|
48103
48107
|
function createCSSResolvers(config) {
|
@@ -48149,7 +48153,7 @@ function getCssResolversKeys(resolvers) {
|
|
48149
48153
|
}
|
48150
48154
|
async function compileCSSPreprocessors(environment, id, lang, code, workerController) {
|
48151
48155
|
const { config } = environment;
|
48152
|
-
const { preprocessorOptions, devSourcemap } = config.css
|
48156
|
+
const { preprocessorOptions, devSourcemap } = config.css;
|
48153
48157
|
const atImportResolvers = getAtImportResolvers(
|
48154
48158
|
environment.getTopLevelConfig()
|
48155
48159
|
);
|
@@ -48172,7 +48176,7 @@ async function compileCSSPreprocessors(environment, id, lang, code, workerContro
|
|
48172
48176
|
throw preprocessResult.error;
|
48173
48177
|
}
|
48174
48178
|
let deps;
|
48175
|
-
if (preprocessResult.deps) {
|
48179
|
+
if (preprocessResult.deps.length > 0) {
|
48176
48180
|
const normalizedFilename = normalizePath$3(opts.filename);
|
48177
48181
|
deps = new Set(
|
48178
48182
|
[...preprocessResult.deps].filter(
|
@@ -48201,10 +48205,10 @@ function getAtImportResolvers(config) {
|
|
48201
48205
|
}
|
48202
48206
|
async function compileCSS(environment, id, code, workerController, urlReplacer) {
|
48203
48207
|
const { config } = environment;
|
48204
|
-
if (config.css
|
48208
|
+
if (config.css.transformer === "lightningcss") {
|
48205
48209
|
return compileLightningCSS(id, code, environment, urlReplacer);
|
48206
48210
|
}
|
48207
|
-
const { modules: modulesOptions, devSourcemap } = config.css
|
48211
|
+
const { modules: modulesOptions, devSourcemap } = config.css;
|
48208
48212
|
const isModule = modulesOptions !== false && cssModuleRE.test(id);
|
48209
48213
|
const needInlineImport = code.includes("@import");
|
48210
48214
|
const hasUrl = cssUrlRE.test(code) || cssImageSetRE.test(code);
|
@@ -48233,8 +48237,8 @@ async function compileCSS(environment, id, code, workerController, urlReplacer)
|
|
48233
48237
|
const atImportResolvers = getAtImportResolvers(
|
48234
48238
|
environment.getTopLevelConfig()
|
48235
48239
|
);
|
48236
|
-
const postcssOptions = postcssConfig
|
48237
|
-
const postcssPlugins = postcssConfig
|
48240
|
+
const postcssOptions = postcssConfig?.options ?? {};
|
48241
|
+
const postcssPlugins = postcssConfig?.plugins.slice() ?? [];
|
48238
48242
|
if (needInlineImport) {
|
48239
48243
|
postcssPlugins.unshift(
|
48240
48244
|
(await importPostcssImport()).default({
|
@@ -48429,8 +48433,8 @@ function createCachedImport(imp) {
|
|
48429
48433
|
return cached;
|
48430
48434
|
};
|
48431
48435
|
}
|
48432
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
48433
|
-
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; }));
|
48434
48438
|
const importPostcss = createCachedImport(() => import('postcss'));
|
48435
48439
|
const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
|
48436
48440
|
let alwaysFakeWorkerWorkerControllerCache;
|
@@ -48489,7 +48493,7 @@ async function resolvePostcssConfig(config) {
|
|
48489
48493
|
if (result !== void 0) {
|
48490
48494
|
return await result;
|
48491
48495
|
}
|
48492
|
-
const inlineOptions = config.css
|
48496
|
+
const inlineOptions = config.css.postcss;
|
48493
48497
|
if (isObject$2(inlineOptions)) {
|
48494
48498
|
const options = { ...inlineOptions };
|
48495
48499
|
delete options.plugins;
|
@@ -48515,9 +48519,13 @@ ${stack}`;
|
|
48515
48519
|
}
|
48516
48520
|
return null;
|
48517
48521
|
});
|
48518
|
-
result.then(
|
48519
|
-
|
48520
|
-
|
48522
|
+
result.then(
|
48523
|
+
(resolved) => {
|
48524
|
+
postcssConfigCache.set(config, resolved);
|
48525
|
+
},
|
48526
|
+
() => {
|
48527
|
+
}
|
48528
|
+
);
|
48521
48529
|
}
|
48522
48530
|
postcssConfigCache.set(config, result);
|
48523
48531
|
return result;
|
@@ -48547,14 +48555,22 @@ const UrlRewritePostcssPlugin = (opts) => {
|
|
48547
48555
|
const replacerForDeclaration = (rawUrl) => {
|
48548
48556
|
return opts.replacer(rawUrl, importer);
|
48549
48557
|
};
|
48550
|
-
|
48551
|
-
|
48552
|
-
|
48553
|
-
(url) => {
|
48558
|
+
if (isCssUrl && isCssImageSet) {
|
48559
|
+
promises.push(
|
48560
|
+
rewriteCssUrls(declaration.value, replacerForDeclaration).then((url) => rewriteCssImageSet(url, replacerForDeclaration)).then((url) => {
|
48554
48561
|
declaration.value = url;
|
48555
|
-
}
|
48556
|
-
)
|
48557
|
-
|
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
|
+
}
|
48558
48574
|
}
|
48559
48575
|
});
|
48560
48576
|
if (promises.length) {
|
@@ -48639,7 +48655,7 @@ async function doImportCSSReplace(rawUrl, matched, replacer) {
|
|
48639
48655
|
async function minifyCSS(css, config, inlined) {
|
48640
48656
|
if (config.build.cssMinify === "lightningcss") {
|
48641
48657
|
const { code, warnings } = (await importLightningCSS()).transform({
|
48642
|
-
...config.css
|
48658
|
+
...config.css.lightningcss,
|
48643
48659
|
targets: convertTargets(config.build.cssTarget),
|
48644
48660
|
cssModules: void 0,
|
48645
48661
|
// TODO: Pass actual filename here, which can also be passed to esbuild's
|
@@ -48771,7 +48787,7 @@ function loadSss(root) {
|
|
48771
48787
|
function cleanScssBugUrl(url) {
|
48772
48788
|
if (
|
48773
48789
|
// check bug via `window` and `location` global
|
48774
|
-
typeof window !== "undefined" && typeof location !== "undefined" && typeof location
|
48790
|
+
typeof window !== "undefined" && typeof location !== "undefined" && typeof location.href === "string"
|
48775
48791
|
) {
|
48776
48792
|
const prefix = location.href.replace(/\/$/, "");
|
48777
48793
|
return url.replace(prefix, "");
|
@@ -48819,7 +48835,7 @@ const makeScssWorker = (environment, resolvers, alias, maxWorkers, packageName)
|
|
48819
48835
|
const path2 = require("node:path");
|
48820
48836
|
const _internalImporter = (url, importer2, done) => {
|
48821
48837
|
internalImporter(url, importer2, options.filename).then(
|
48822
|
-
(data2) => done
|
48838
|
+
(data2) => done(data2)
|
48823
48839
|
);
|
48824
48840
|
};
|
48825
48841
|
const importer = [_internalImporter];
|
@@ -49140,13 +49156,10 @@ const makeLessWorker = (environment, resolvers, alias, maxWorkers) => {
|
|
49140
49156
|
"@",
|
49141
49157
|
resolvers.less
|
49142
49158
|
);
|
49143
|
-
|
49144
|
-
|
49145
|
-
|
49146
|
-
|
49147
|
-
};
|
49148
|
-
}
|
49149
|
-
return result;
|
49159
|
+
return {
|
49160
|
+
resolved,
|
49161
|
+
contents: "contents" in result ? result.contents : void 0
|
49162
|
+
};
|
49150
49163
|
};
|
49151
49164
|
const worker = new WorkerWithFallback(
|
49152
49165
|
() => {
|
@@ -49447,48 +49460,60 @@ async function compileLightningCSS(id, src, environment, urlReplacer) {
|
|
49447
49460
|
const deps = /* @__PURE__ */ new Set();
|
49448
49461
|
const filename = cleanUrl(path$d.relative(config.root, id));
|
49449
49462
|
const toAbsolute = (filePath) => path$d.isAbsolute(filePath) ? filePath : path$d.join(config.root, filePath);
|
49450
|
-
|
49451
|
-
|
49452
|
-
|
49453
|
-
|
49454
|
-
|
49455
|
-
|
49456
|
-
|
49457
|
-
|
49458
|
-
|
49459
|
-
|
49460
|
-
|
49461
|
-
|
49462
|
-
|
49463
|
-
|
49464
|
-
|
49465
|
-
|
49466
|
-
|
49467
|
-
|
49468
|
-
|
49469
|
-
|
49470
|
-
|
49471
|
-
|
49472
|
-
|
49473
|
-
|
49474
|
-
|
49475
|
-
|
49476
|
-
|
49477
|
-
|
49478
|
-
|
49479
|
-
|
49480
|
-
|
49481
|
-
|
49482
|
-
|
49463
|
+
let res;
|
49464
|
+
try {
|
49465
|
+
res = styleAttrRE.test(id) ? (await importLightningCSS()).transformStyleAttribute({
|
49466
|
+
filename,
|
49467
|
+
code: Buffer.from(src),
|
49468
|
+
targets: config.css.lightningcss?.targets,
|
49469
|
+
minify: config.isProduction && !!config.build.cssMinify,
|
49470
|
+
analyzeDependencies: true
|
49471
|
+
}) : await (await importLightningCSS()).bundleAsync({
|
49472
|
+
...config.css.lightningcss,
|
49473
|
+
filename,
|
49474
|
+
resolver: {
|
49475
|
+
read(filePath) {
|
49476
|
+
if (filePath === filename) {
|
49477
|
+
return src;
|
49478
|
+
}
|
49479
|
+
if (!filePath.endsWith(".css")) {
|
49480
|
+
return src;
|
49481
|
+
}
|
49482
|
+
return fs__default.readFileSync(toAbsolute(filePath), "utf-8");
|
49483
|
+
},
|
49484
|
+
async resolve(id2, from) {
|
49485
|
+
const publicFile = checkPublicFile(
|
49486
|
+
id2,
|
49487
|
+
environment.getTopLevelConfig()
|
49488
|
+
);
|
49489
|
+
if (publicFile) {
|
49490
|
+
return publicFile;
|
49491
|
+
}
|
49492
|
+
const resolved = await getAtImportResolvers(
|
49493
|
+
environment.getTopLevelConfig()
|
49494
|
+
).css(environment, id2, toAbsolute(from));
|
49495
|
+
if (resolved) {
|
49496
|
+
deps.add(resolved);
|
49497
|
+
return resolved;
|
49498
|
+
}
|
49499
|
+
return id2;
|
49483
49500
|
}
|
49484
|
-
|
49485
|
-
|
49486
|
-
|
49487
|
-
|
49488
|
-
|
49489
|
-
|
49490
|
-
|
49491
|
-
|
49501
|
+
},
|
49502
|
+
minify: config.isProduction && !!config.build.cssMinify,
|
49503
|
+
sourceMap: config.command === "build" ? !!config.build.sourcemap : config.css.devSourcemap,
|
49504
|
+
analyzeDependencies: true,
|
49505
|
+
cssModules: cssModuleRE.test(id) ? config.css.lightningcss?.cssModules ?? true : void 0
|
49506
|
+
});
|
49507
|
+
} catch (e) {
|
49508
|
+
e.message = `[lightningcss] ${e.message}`;
|
49509
|
+
e.loc = {
|
49510
|
+
file: toAbsolute(e.fileName),
|
49511
|
+
line: e.loc.line,
|
49512
|
+
column: e.loc.column - 1
|
49513
|
+
// 1-based
|
49514
|
+
};
|
49515
|
+
throw e;
|
49516
|
+
}
|
49492
49517
|
let css = decoder.decode(res.code);
|
49493
49518
|
for (const dep of res.dependencies) {
|
49494
49519
|
switch (dep.type) {
|
@@ -49497,7 +49522,6 @@ async function compileLightningCSS(id, src, environment, urlReplacer) {
|
|
49497
49522
|
css = css.replace(dep.placeholder, () => dep.url);
|
49498
49523
|
break;
|
49499
49524
|
}
|
49500
|
-
deps.add(dep.url);
|
49501
49525
|
if (urlReplacer) {
|
49502
49526
|
const replaceUrl = await urlReplacer(
|
49503
49527
|
dep.url,
|
@@ -50091,7 +50115,7 @@ function buildImportAnalysisPlugin(config) {
|
|
50091
50115
|
);
|
50092
50116
|
chunk.code += `
|
50093
50117
|
//# sourceMappingURL=${genSourceMapUrl(map)}`;
|
50094
|
-
} else
|
50118
|
+
} else {
|
50095
50119
|
const mapAsset = bundle[chunk.fileName + ".map"];
|
50096
50120
|
if (mapAsset && mapAsset.type === "asset") {
|
50097
50121
|
mapAsset.source = map.toString();
|
@@ -50263,8 +50287,8 @@ const buildEnvironmentOptionsDefaults = Object.freeze({
|
|
50263
50287
|
watch: null
|
50264
50288
|
// createEnvironment
|
50265
50289
|
});
|
50266
|
-
function resolveBuildEnvironmentOptions(raw, logger, consumer
|
50267
|
-
const deprecatedPolyfillModulePreload = raw
|
50290
|
+
function resolveBuildEnvironmentOptions(raw, logger, consumer) {
|
50291
|
+
const deprecatedPolyfillModulePreload = raw.polyfillModulePreload;
|
50268
50292
|
const { polyfillModulePreload, ...rest } = raw;
|
50269
50293
|
raw = rest;
|
50270
50294
|
if (deprecatedPolyfillModulePreload !== void 0) {
|
@@ -50307,17 +50331,6 @@ function resolveBuildEnvironmentOptions(raw, logger, consumer, isSsrTargetWebwor
|
|
50307
50331
|
...merged.modulePreload
|
50308
50332
|
}
|
50309
50333
|
};
|
50310
|
-
if (isSsrTargetWebworkerEnvironment) {
|
50311
|
-
resolved.rollupOptions ??= {};
|
50312
|
-
resolved.rollupOptions.output ??= {};
|
50313
|
-
const output = resolved.rollupOptions.output;
|
50314
|
-
for (const out of arraify(output)) {
|
50315
|
-
out.entryFileNames ??= `[name].js`;
|
50316
|
-
out.chunkFileNames ??= `[name]-[hash].js`;
|
50317
|
-
const input = resolved.rollupOptions.input;
|
50318
|
-
out.inlineDynamicImports ??= !input || typeof input === "string" || Object.keys(input).length === 1;
|
50319
|
-
}
|
50320
|
-
}
|
50321
50334
|
return resolved;
|
50322
50335
|
}
|
50323
50336
|
async function resolveBuildPlugins(config) {
|
@@ -50378,12 +50391,12 @@ async function buildEnvironment(environment) {
|
|
50378
50391
|
)
|
50379
50392
|
);
|
50380
50393
|
const resolve = (p) => path$d.resolve(root, p);
|
50381
|
-
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(
|
50382
50395
|
Object.entries(libOptions.entry).map(([alias, file]) => [
|
50383
50396
|
alias,
|
50384
50397
|
resolve(file)
|
50385
50398
|
])
|
50386
|
-
)) : typeof options.ssr === "string" ? resolve(options.ssr) : options.rollupOptions
|
50399
|
+
)) : typeof options.ssr === "string" ? resolve(options.ssr) : options.rollupOptions.input || resolve("index.html");
|
50387
50400
|
if (ssr && typeof input === "string" && input.endsWith(".html")) {
|
50388
50401
|
throw new Error(
|
50389
50402
|
`rollupOptions.input should not be an html file when building for SSR. Please specify a dedicated SSR entry.`
|
@@ -50408,7 +50421,7 @@ async function buildEnvironment(environment) {
|
|
50408
50421
|
output: options.rollupOptions.output,
|
50409
50422
|
input,
|
50410
50423
|
plugins,
|
50411
|
-
external: options.rollupOptions
|
50424
|
+
external: options.rollupOptions.external,
|
50412
50425
|
onwarn(warning, warn) {
|
50413
50426
|
onRollupWarning(warning, warn, environment);
|
50414
50427
|
}
|
@@ -50455,6 +50468,7 @@ ${stackOnly}`;
|
|
50455
50468
|
clearLine();
|
50456
50469
|
logger.error(e.message, { error: e });
|
50457
50470
|
};
|
50471
|
+
const isSsrTargetWebworkerEnvironment = environment.name === "ssr" && environment.getTopLevelConfig().ssr?.target === "webworker";
|
50458
50472
|
let bundle;
|
50459
50473
|
let startTime;
|
50460
50474
|
try {
|
@@ -50477,7 +50491,7 @@ ${stackOnly}`;
|
|
50477
50491
|
);
|
50478
50492
|
}
|
50479
50493
|
const format = output.format || "es";
|
50480
|
-
const jsExt =
|
50494
|
+
const jsExt = ssr && !isSsrTargetWebworkerEnvironment || libOptions ? resolveOutputJsExtension(
|
50481
50495
|
format,
|
50482
50496
|
findNearestPackageData(root, packageCache)?.data.type
|
50483
50497
|
) : "js";
|
@@ -50503,12 +50517,12 @@ ${stackOnly}`;
|
|
50503
50517
|
) : path$d.posix.join(options.assetsDir, `[name]-[hash].${jsExt}`),
|
50504
50518
|
chunkFileNames: libOptions ? `[name]-[hash].${jsExt}` : path$d.posix.join(options.assetsDir, `[name]-[hash].${jsExt}`),
|
50505
50519
|
assetFileNames: libOptions ? `[name].[ext]` : path$d.posix.join(options.assetsDir, `[name]-[hash].[ext]`),
|
50506
|
-
inlineDynamicImports: output.format === "umd" || output.format === "iife",
|
50520
|
+
inlineDynamicImports: output.format === "umd" || output.format === "iife" || isSsrTargetWebworkerEnvironment && (typeof input === "string" || Object.keys(input).length === 1),
|
50507
50521
|
...output
|
50508
50522
|
};
|
50509
50523
|
};
|
50510
50524
|
const outputs = resolveBuildOutputs(
|
50511
|
-
options.rollupOptions
|
50525
|
+
options.rollupOptions.output,
|
50512
50526
|
libOptions,
|
50513
50527
|
logger
|
50514
50528
|
);
|
@@ -50523,7 +50537,7 @@ ${stackOnly}`;
|
|
50523
50537
|
const resolvedOutDirs = getResolvedOutDirs(
|
50524
50538
|
root,
|
50525
50539
|
options.outDir,
|
50526
|
-
options.rollupOptions
|
50540
|
+
options.rollupOptions.output
|
50527
50541
|
);
|
50528
50542
|
const emptyOutDir = resolveEmptyOutDir(
|
50529
50543
|
options.emptyOutDir,
|
@@ -50739,7 +50753,7 @@ If you do want to externalize this module explicitly add it to
|
|
50739
50753
|
warn(warnLog);
|
50740
50754
|
};
|
50741
50755
|
clearLine();
|
50742
|
-
const userOnWarn = environment.config.build.rollupOptions
|
50756
|
+
const userOnWarn = environment.config.build.rollupOptions.onwarn;
|
50743
50757
|
if (userOnWarn) {
|
50744
50758
|
userOnWarn(warning, viteWarn);
|
50745
50759
|
} else {
|
@@ -50989,7 +51003,7 @@ class BuildEnvironment extends BaseEnvironment {
|
|
50989
51003
|
if (setup?.options) {
|
50990
51004
|
options = mergeConfig(
|
50991
51005
|
options,
|
50992
|
-
setup
|
51006
|
+
setup.options
|
50993
51007
|
);
|
50994
51008
|
}
|
50995
51009
|
super(name, config, options);
|
@@ -51374,6 +51388,8 @@ function createDepsOptimizer(environment) {
|
|
51374
51388
|
if (debounceProcessingHandle) clearTimeout(debounceProcessingHandle);
|
51375
51389
|
if (closed) {
|
51376
51390
|
currentlyProcessing = false;
|
51391
|
+
depOptimizationProcessing.resolve();
|
51392
|
+
resolveEnqueuedProcessingPromises();
|
51377
51393
|
return;
|
51378
51394
|
}
|
51379
51395
|
currentlyProcessing = true;
|
@@ -52242,12 +52258,12 @@ class DevEnvironment extends BaseEnvironment {
|
|
52242
52258
|
}
|
52243
52259
|
async close() {
|
52244
52260
|
this._closing = true;
|
52245
|
-
this._crawlEndFinder
|
52261
|
+
this._crawlEndFinder.cancel();
|
52246
52262
|
await Promise.allSettled([
|
52247
52263
|
this.pluginContainer.close(),
|
52248
52264
|
this.depsOptimizer?.close(),
|
52249
52265
|
// WebSocketServer is independent of HotChannel and should not be closed on environment close
|
52250
|
-
isWebSocketServer in this.hot ? Promise.resolve() : this.hot.close
|
52266
|
+
isWebSocketServer in this.hot ? Promise.resolve() : this.hot.close(),
|
52251
52267
|
(async () => {
|
52252
52268
|
while (this._pendingRequests.size > 0) {
|
52253
52269
|
await Promise.allSettled(
|
@@ -52499,7 +52515,7 @@ function compression ({ threshold = 1024, level = -1, brotli = false, gzip = tru
|
|
52499
52515
|
|
52500
52516
|
function resolvePreviewOptions(preview2, server) {
|
52501
52517
|
return {
|
52502
|
-
port: preview2?.port,
|
52518
|
+
port: preview2?.port ?? DEFAULT_PREVIEW_PORT,
|
52503
52519
|
strictPort: preview2?.strictPort ?? server.strictPort,
|
52504
52520
|
host: preview2?.host ?? server.host,
|
52505
52521
|
https: preview2?.https ?? server.https,
|
@@ -52517,7 +52533,7 @@ async function preview(inlineConfig = {}) {
|
|
52517
52533
|
"production",
|
52518
52534
|
true
|
52519
52535
|
);
|
52520
|
-
const clientOutDir = config.environments.client.build.outDir
|
52536
|
+
const clientOutDir = config.environments.client.build.outDir;
|
52521
52537
|
const distDir = path$d.resolve(config.root, clientOutDir);
|
52522
52538
|
if (!fs__default.existsSync(distDir) && // error if no plugins implement `configurePreviewServer`
|
52523
52539
|
config.plugins.every((plugin) => !plugin.configurePreviewServer) && // error if called in CLI only. programmatic usage could access `httpServer`
|
@@ -52531,7 +52547,7 @@ async function preview(inlineConfig = {}) {
|
|
52531
52547
|
const httpServer = await resolveHttpServer(
|
52532
52548
|
config.preview,
|
52533
52549
|
app,
|
52534
|
-
await resolveHttpsConfig(config.preview
|
52550
|
+
await resolveHttpsConfig(config.preview.https)
|
52535
52551
|
);
|
52536
52552
|
setClientErrorHandler(httpServer, config.logger);
|
52537
52553
|
const options = config.preview;
|
@@ -52610,9 +52626,8 @@ async function preview(inlineConfig = {}) {
|
|
52610
52626
|
app.use(notFoundMiddleware());
|
52611
52627
|
}
|
52612
52628
|
const hostname = await resolveHostname(options.host);
|
52613
|
-
const port = options.port ?? configDefaults.preview.port;
|
52614
52629
|
await httpServerStart(httpServer, {
|
52615
|
-
port,
|
52630
|
+
port: options.port,
|
52616
52631
|
strictPort: options.strictPort,
|
52617
52632
|
host: hostname.host,
|
52618
52633
|
logger
|
@@ -52623,7 +52638,7 @@ async function preview(inlineConfig = {}) {
|
|
52623
52638
|
config
|
52624
52639
|
);
|
52625
52640
|
if (options.open) {
|
52626
|
-
const url = server.resolvedUrls
|
52641
|
+
const url = server.resolvedUrls.local[0] ?? server.resolvedUrls.network[0];
|
52627
52642
|
if (url) {
|
52628
52643
|
const path2 = typeof options.open === "string" ? new URL(options.open, url).href : url;
|
52629
52644
|
openBrowser(path2, true, logger);
|
@@ -52687,7 +52702,7 @@ const configDefaults = Object.freeze({
|
|
52687
52702
|
dedupe: [],
|
52688
52703
|
/** @experimental */
|
52689
52704
|
noExternal: [],
|
52690
|
-
|
52705
|
+
external: [],
|
52691
52706
|
preserveSymlinks: false,
|
52692
52707
|
alias: []
|
52693
52708
|
},
|
@@ -52816,8 +52831,7 @@ function resolveEnvironmentOptions(options, alias, preserveSymlinks, logger, env
|
|
52816
52831
|
build: resolveBuildEnvironmentOptions(
|
52817
52832
|
options.build ?? {},
|
52818
52833
|
logger,
|
52819
|
-
consumer
|
52820
|
-
isSsrTargetWebworkerEnvironment
|
52834
|
+
consumer
|
52821
52835
|
)
|
52822
52836
|
};
|
52823
52837
|
}
|
@@ -52870,7 +52884,7 @@ function resolveEnvironmentResolveOptions(resolve, alias, preserveSymlinks, logg
|
|
52870
52884
|
...configDefaults.resolve,
|
52871
52885
|
mainFields: consumer === "client" || isSsrTargetWebworkerEnvironment ? DEFAULT_CLIENT_MAIN_FIELDS : DEFAULT_SERVER_MAIN_FIELDS,
|
52872
52886
|
conditions: consumer === "client" || isSsrTargetWebworkerEnvironment ? DEFAULT_CLIENT_CONDITIONS : DEFAULT_SERVER_CONDITIONS.filter((c) => c !== "browser"),
|
52873
|
-
|
52887
|
+
enableBuiltinNoExternalCheck: !!isSsrTargetWebworkerEnvironment
|
52874
52888
|
},
|
52875
52889
|
resolve ?? {}
|
52876
52890
|
);
|
@@ -52965,7 +52979,9 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
52965
52979
|
return p.apply === command;
|
52966
52980
|
}
|
52967
52981
|
};
|
52968
|
-
const rawPlugins = (await asyncFlatten(config.plugins || [])).filter(
|
52982
|
+
const rawPlugins = (await asyncFlatten(config.plugins || [])).filter(
|
52983
|
+
filterPlugin
|
52984
|
+
);
|
52969
52985
|
const [prePlugins, normalPlugins, postPlugins] = sortUserPlugins(rawPlugins);
|
52970
52986
|
const isBuild = command === "build";
|
52971
52987
|
const userPlugins = [...prePlugins, ...normalPlugins, ...postPlugins];
|
@@ -52991,31 +53007,35 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
52991
53007
|
let configEnvironmentsSsr = config.environments.ssr;
|
52992
53008
|
const warmupOptions = config.server?.warmup;
|
52993
53009
|
if (warmupOptions?.clientFiles) {
|
52994
|
-
configEnvironmentsClient.dev.warmup = warmupOptions
|
53010
|
+
configEnvironmentsClient.dev.warmup = warmupOptions.clientFiles;
|
52995
53011
|
}
|
52996
53012
|
if (warmupOptions?.ssrFiles) {
|
52997
53013
|
configEnvironmentsSsr ??= {};
|
52998
53014
|
configEnvironmentsSsr.dev ??= {};
|
52999
|
-
configEnvironmentsSsr.dev.warmup = warmupOptions
|
53015
|
+
configEnvironmentsSsr.dev.warmup = warmupOptions.ssrFiles;
|
53000
53016
|
}
|
53001
53017
|
if (configEnvironmentsSsr) {
|
53002
53018
|
configEnvironmentsSsr.optimizeDeps = mergeConfig(
|
53003
53019
|
deprecatedSsrOptimizeDepsConfig,
|
53004
53020
|
configEnvironmentsSsr.optimizeDeps ?? {}
|
53005
53021
|
);
|
53006
|
-
configEnvironmentsSsr.resolve
|
53007
|
-
|
53008
|
-
|
53009
|
-
|
53010
|
-
|
53011
|
-
|
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
|
+
);
|
53012
53032
|
}
|
53013
53033
|
if (config.build?.ssrEmitAssets !== void 0) {
|
53014
53034
|
configEnvironmentsSsr ??= {};
|
53015
53035
|
configEnvironmentsSsr.build ??= {};
|
53016
53036
|
configEnvironmentsSsr.build.emitAssets = config.build.ssrEmitAssets;
|
53017
53037
|
}
|
53018
|
-
if (!config.environments
|
53038
|
+
if (!config.environments.client || !config.environments.ssr && !isBuild) {
|
53019
53039
|
throw new Error(
|
53020
53040
|
"Required environments configuration were stripped out in the config hook"
|
53021
53041
|
);
|
@@ -53051,6 +53071,9 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
53051
53071
|
configEnv,
|
53052
53072
|
config.ssr?.target === "webworker"
|
53053
53073
|
);
|
53074
|
+
config.resolve ??= {};
|
53075
|
+
config.resolve.conditions = config.environments.client.resolve?.conditions;
|
53076
|
+
config.resolve.mainFields = config.environments.client.resolve?.mainFields;
|
53054
53077
|
const resolvedDefaultResolve = resolveResolveOptions(config.resolve, logger);
|
53055
53078
|
const resolvedEnvironments = {};
|
53056
53079
|
for (const environmentName of Object.keys(config.environments)) {
|
@@ -53105,7 +53128,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
53105
53128
|
}
|
53106
53129
|
const isProduction = process.env.NODE_ENV === "production";
|
53107
53130
|
const relativeBaseShortcut = config.base === "" || config.base === "./";
|
53108
|
-
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);
|
53109
53132
|
const pkgDir = findNearestPackageData(resolvedRoot, packageCache)?.dir;
|
53110
53133
|
const cacheDir = normalizePath$3(
|
53111
53134
|
config.cacheDir ? path$d.resolve(resolvedRoot, config.cacheDir) : pkgDir ? path$d.join(pkgDir, `node_modules/.vite`) : path$d.join(resolvedRoot, `.vite`)
|
@@ -53346,7 +53369,7 @@ assetFileNames isn't equal for every build.rollupOptions.output. A single patter
|
|
53346
53369
|
}
|
53347
53370
|
return resolved;
|
53348
53371
|
}
|
53349
|
-
function resolveBaseUrl(base =
|
53372
|
+
function resolveBaseUrl(base = configDefaults.base, isBuild, logger) {
|
53350
53373
|
if (base[0] === ".") {
|
53351
53374
|
logger.warn(
|
53352
53375
|
colors$1.yellow(
|
@@ -53447,6 +53470,8 @@ async function bundleConfigFile(fileName, isESM) {
|
|
53447
53470
|
format: isESM ? "esm" : "cjs",
|
53448
53471
|
mainFields: ["main"],
|
53449
53472
|
sourcemap: "inline",
|
53473
|
+
// the last slash is needed to make the path correct
|
53474
|
+
sourceRoot: path$d.dirname(fileName) + path$d.sep,
|
53450
53475
|
metafile: true,
|
53451
53476
|
define: {
|
53452
53477
|
__dirname: dirnameVarName,
|
@@ -53483,7 +53508,7 @@ async function bundleConfigFile(fileName, isESM) {
|
|
53483
53508
|
})?.id;
|
53484
53509
|
};
|
53485
53510
|
build2.onResolve(
|
53486
|
-
{ filter: /^[
|
53511
|
+
{ filter: /^[^.#].*/ },
|
53487
53512
|
async ({ path: id, importer, kind }) => {
|
53488
53513
|
if (kind === "entry-point" || path$d.isAbsolute(id) || isNodeBuiltin(id)) {
|
53489
53514
|
return;
|
@@ -53549,17 +53574,25 @@ async function bundleConfigFile(fileName, isESM) {
|
|
53549
53574
|
const { text } = result.outputFiles[0];
|
53550
53575
|
return {
|
53551
53576
|
code: text,
|
53552
|
-
dependencies:
|
53577
|
+
dependencies: Object.keys(result.metafile.inputs)
|
53553
53578
|
};
|
53554
53579
|
}
|
53555
53580
|
const _require = createRequire$1(import.meta.url);
|
53556
53581
|
async function loadConfigFromBundledFile(fileName, bundledCode, isESM) {
|
53557
53582
|
if (isESM) {
|
53558
|
-
|
53583
|
+
let nodeModulesDir = typeof process.versions.deno === "string" ? void 0 : findNearestNodeModules(path$d.dirname(fileName));
|
53559
53584
|
if (nodeModulesDir) {
|
53560
|
-
|
53561
|
-
|
53562
|
-
|
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
|
+
}
|
53563
53596
|
}
|
53564
53597
|
const hash = `timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
53565
53598
|
const tempFileName = nodeModulesDir ? path$d.resolve(
|
@@ -53596,11 +53629,9 @@ async function runConfigHook(config, plugins, configEnv) {
|
|
53596
53629
|
for (const p of getSortedPluginsByHook("config", plugins)) {
|
53597
53630
|
const hook = p.config;
|
53598
53631
|
const handler = getHookHandler(hook);
|
53599
|
-
|
53600
|
-
|
53601
|
-
|
53602
|
-
conf = mergeConfig(conf, res);
|
53603
|
-
}
|
53632
|
+
const res = await handler(conf, configEnv);
|
53633
|
+
if (res && res !== conf) {
|
53634
|
+
conf = mergeConfig(conf, res);
|
53604
53635
|
}
|
53605
53636
|
}
|
53606
53637
|
return conf;
|
@@ -53610,15 +53641,13 @@ async function runConfigEnvironmentHook(environments, plugins, configEnv, isSsrT
|
|
53610
53641
|
for (const p of getSortedPluginsByHook("configEnvironment", plugins)) {
|
53611
53642
|
const hook = p.configEnvironment;
|
53612
53643
|
const handler = getHookHandler(hook);
|
53613
|
-
|
53614
|
-
|
53615
|
-
|
53616
|
-
|
53617
|
-
|
53618
|
-
|
53619
|
-
|
53620
|
-
environments[name] = mergeConfig(environments[name], res);
|
53621
|
-
}
|
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);
|
53622
53651
|
}
|
53623
53652
|
}
|
53624
53653
|
}
|
@@ -53627,7 +53656,7 @@ function optimizeDepsDisabledBackwardCompatibility(resolved, optimizeDeps, optim
|
|
53627
53656
|
const optimizeDepsDisabled = optimizeDeps.disabled;
|
53628
53657
|
if (optimizeDepsDisabled !== void 0) {
|
53629
53658
|
if (optimizeDepsDisabled === true || optimizeDepsDisabled === "dev") {
|
53630
|
-
const commonjsOptionsInclude = resolved.build
|
53659
|
+
const commonjsOptionsInclude = resolved.build.commonjsOptions.include;
|
53631
53660
|
const commonjsPluginDisabled = Array.isArray(commonjsOptionsInclude) && commonjsOptionsInclude.length === 0;
|
53632
53661
|
optimizeDeps.noDiscovery = true;
|
53633
53662
|
optimizeDeps.include = void 0;
|