vite 5.0.0-beta.4 → 5.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +45 -1
- package/dist/client/client.mjs.map +1 -1
- package/dist/client/env.mjs.map +1 -1
- package/dist/node/chunks/{dep-ae1dfb84.js → dep-c3c41c00.js} +1 -1
- package/dist/node/chunks/{dep-a86a117b.js → dep-ce41d4ea.js} +1 -1
- package/dist/node/chunks/{dep-69dc786c.js → dep-db07a1ea.js} +529 -326
- package/dist/node/cli.js +5 -5
- package/dist/node/index.d.ts +16 -7
- package/dist/node/index.js +2 -2
- package/dist/node-cjs/publicUtils.cjs +22 -11
- package/package.json +15 -15
|
@@ -23,7 +23,7 @@ import os$4 from 'node:os';
|
|
|
23
23
|
import { exec } from 'node:child_process';
|
|
24
24
|
import { createHash as createHash$2 } from 'node:crypto';
|
|
25
25
|
import { promises } from 'node:dns';
|
|
26
|
-
import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, wildcardHosts, loopbackHosts, VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, ENV_ENTRY, DEP_VERSION_RE, DEFAULT_MAIN_FIELDS, DEFAULT_EXTENSIONS
|
|
26
|
+
import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, wildcardHosts, loopbackHosts, VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, ENV_ENTRY, DEP_VERSION_RE, DEFAULT_MAIN_FIELDS, DEFAULT_EXTENSIONS, SPECIAL_QUERY_RE, CSS_LANGS_RE, ESBUILD_MODULES_TARGET, KNOWN_ASSET_TYPES, CLIENT_DIR, JS_TYPES_RE, VERSION as VERSION$1, VITE_PACKAGE_DIR, DEFAULT_DEV_PORT, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
|
|
27
27
|
import require$$3$1 from 'crypto';
|
|
28
28
|
import { Buffer as Buffer$1 } from 'node:buffer';
|
|
29
29
|
import require$$0$8, { createRequire as createRequire$2 } from 'module';
|
|
@@ -7460,9 +7460,9 @@ function isReference(node, parent) {
|
|
|
7460
7460
|
return false;
|
|
7461
7461
|
}
|
|
7462
7462
|
|
|
7463
|
-
var version$3 = "25.0.
|
|
7463
|
+
var version$3 = "25.0.5";
|
|
7464
7464
|
var peerDependencies = {
|
|
7465
|
-
rollup: "^2.68.0||^3.0.0"
|
|
7465
|
+
rollup: "^2.68.0||^3.0.0||^4.0.0"
|
|
7466
7466
|
};
|
|
7467
7467
|
|
|
7468
7468
|
function tryParse(parse, code, id) {
|
|
@@ -7485,6 +7485,7 @@ function hasCjsKeywords(code, ignoreGlobal) {
|
|
|
7485
7485
|
|
|
7486
7486
|
/* eslint-disable no-underscore-dangle */
|
|
7487
7487
|
|
|
7488
|
+
|
|
7488
7489
|
function analyzeTopLevelStatements(parse, code, id) {
|
|
7489
7490
|
const ast = tryParse(parse, code, id);
|
|
7490
7491
|
|
|
@@ -7531,6 +7532,7 @@ function analyzeTopLevelStatements(parse, code, id) {
|
|
|
7531
7532
|
|
|
7532
7533
|
/* eslint-disable import/prefer-default-export */
|
|
7533
7534
|
|
|
7535
|
+
|
|
7534
7536
|
function deconflict(scopes, globals, identifier) {
|
|
7535
7537
|
let i = 1;
|
|
7536
7538
|
let deconflicted = makeLegalIdentifier(identifier);
|
|
@@ -7919,6 +7921,7 @@ function getEsImportProxy(id, defaultIsModuleExports) {
|
|
|
7919
7921
|
|
|
7920
7922
|
/* eslint-disable no-param-reassign, no-undefined */
|
|
7921
7923
|
|
|
7924
|
+
|
|
7922
7925
|
function getCandidatesForExtension(resolved, extension) {
|
|
7923
7926
|
return [resolved + extension, `${resolved}${sep}index${extension}`];
|
|
7924
7927
|
}
|
|
@@ -8229,6 +8232,7 @@ function getRequireResolver(extensions, detectCyclesAndConditional, currentlyRes
|
|
|
8229
8232
|
currentlyResolvingForParent.add(source);
|
|
8230
8233
|
const resolved =
|
|
8231
8234
|
(await rollupContext.resolve(source, parentId, {
|
|
8235
|
+
skipSelf: false,
|
|
8232
8236
|
custom: { 'node-resolve': { isRequire: true } }
|
|
8233
8237
|
})) || resolveExtensions(source, parentId, extensions);
|
|
8234
8238
|
currentlyResolvingForParent.delete(source);
|
|
@@ -8897,6 +8901,7 @@ function getGenerateRequireName() {
|
|
|
8897
8901
|
|
|
8898
8902
|
/* eslint-disable no-param-reassign, no-shadow, no-underscore-dangle, no-continue */
|
|
8899
8903
|
|
|
8904
|
+
|
|
8900
8905
|
const exportsPattern = /^(?:module\.)?exports(?:\.([a-zA-Z_$][a-zA-Z_$0-9]*))?$/;
|
|
8901
8906
|
|
|
8902
8907
|
const functionType = /^(?:FunctionDeclaration|FunctionExpression|ArrowFunctionExpression)$/;
|
|
@@ -9167,6 +9172,9 @@ async function transformCommonjs(
|
|
|
9167
9172
|
}
|
|
9168
9173
|
if (!ignoreDynamicRequires) {
|
|
9169
9174
|
if (isShorthandProperty(parent)) {
|
|
9175
|
+
// as key and value are the same object, isReference regards
|
|
9176
|
+
// both as references, so we need to skip now
|
|
9177
|
+
skippedNodes.add(parent.value);
|
|
9170
9178
|
magicString.prependRight(node.start, 'require: ');
|
|
9171
9179
|
}
|
|
9172
9180
|
replacedDynamicRequires.push(node);
|
|
@@ -9709,7 +9717,7 @@ function commonjs(options = {}) {
|
|
|
9709
9717
|
try {
|
|
9710
9718
|
return transformAndCheckExports.call(this, code, id);
|
|
9711
9719
|
} catch (err) {
|
|
9712
|
-
return this.error(err, err.
|
|
9720
|
+
return this.error(err, err.pos);
|
|
9713
9721
|
}
|
|
9714
9722
|
}
|
|
9715
9723
|
};
|
|
@@ -11868,11 +11876,22 @@ const replaceSlashOrColonRE = /[/:]/g;
|
|
|
11868
11876
|
const replaceDotRE = /\./g;
|
|
11869
11877
|
const replaceNestedIdRE = /(\s*>\s*)/g;
|
|
11870
11878
|
const replaceHashRE = /#/g;
|
|
11871
|
-
const flattenId = (id) =>
|
|
11872
|
-
|
|
11873
|
-
|
|
11874
|
-
|
|
11875
|
-
|
|
11879
|
+
const flattenId = (id) => {
|
|
11880
|
+
const flatId = limitFlattenIdLength(id
|
|
11881
|
+
.replace(replaceSlashOrColonRE, '_')
|
|
11882
|
+
.replace(replaceDotRE, '__')
|
|
11883
|
+
.replace(replaceNestedIdRE, '___')
|
|
11884
|
+
.replace(replaceHashRE, '____'));
|
|
11885
|
+
return flatId;
|
|
11886
|
+
};
|
|
11887
|
+
const FLATTEN_ID_HASH_LENGTH = 8;
|
|
11888
|
+
const FLATTEN_ID_MAX_FILE_LENGTH = 170;
|
|
11889
|
+
const limitFlattenIdLength = (id, limit = FLATTEN_ID_MAX_FILE_LENGTH) => {
|
|
11890
|
+
if (id.length <= limit) {
|
|
11891
|
+
return id;
|
|
11892
|
+
}
|
|
11893
|
+
return id.slice(0, limit - (FLATTEN_ID_HASH_LENGTH + 1)) + '_' + getHash(id);
|
|
11894
|
+
};
|
|
11876
11895
|
const normalizeId = (id) => id.replace(replaceNestedIdRE, ' > ');
|
|
11877
11896
|
// Supported by Node, Deno, Bun
|
|
11878
11897
|
const NODE_BUILTIN_NAMESPACE = 'node:';
|
|
@@ -12565,20 +12584,12 @@ function arraify(target) {
|
|
|
12565
12584
|
const multilineCommentsRE$1 = /\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g;
|
|
12566
12585
|
const singlelineCommentsRE$1 = /\/\/.*/g;
|
|
12567
12586
|
const requestQuerySplitRE = /\?(?!.*[/|}])/;
|
|
12568
|
-
// @ts-expect-error jest only exists when running Jest
|
|
12569
|
-
const usingDynamicImport = typeof jest === 'undefined';
|
|
12570
12587
|
/**
|
|
12571
12588
|
* Dynamically import files. It will make sure it's not being compiled away by TS/Rollup.
|
|
12572
12589
|
*
|
|
12573
|
-
* As a temporary workaround for Jest's lack of stable ESM support, we fallback to require
|
|
12574
|
-
* if we're in a Jest environment.
|
|
12575
|
-
* See https://github.com/vitejs/vite/pull/5197#issuecomment-938054077
|
|
12576
|
-
*
|
|
12577
12590
|
* @param file File path to import.
|
|
12578
12591
|
*/
|
|
12579
|
-
const dynamicImport =
|
|
12580
|
-
? new Function('file', 'return import(file)')
|
|
12581
|
-
: _require$2;
|
|
12592
|
+
const dynamicImport = new Function('file', 'return import(file)');
|
|
12582
12593
|
function parseRequest(id) {
|
|
12583
12594
|
const [_, search] = id.split(requestQuerySplitRE, 2);
|
|
12584
12595
|
if (!search) {
|
|
@@ -13215,11 +13226,13 @@ const NATIVE_SEP_RE = new RegExp('\\' + path$o.sep, 'g');
|
|
|
13215
13226
|
/** @type {Map<string,RegExp>}*/
|
|
13216
13227
|
const PATTERN_REGEX_CACHE = new Map();
|
|
13217
13228
|
const GLOB_ALL_PATTERN = `**/*`;
|
|
13218
|
-
const
|
|
13219
|
-
const
|
|
13229
|
+
const TS_EXTENSIONS = ['.ts', '.tsx', '.mts', '.cts'];
|
|
13230
|
+
const JS_EXTENSIONS = ['.js', '.jsx', '.mjs', '.cjs'];
|
|
13231
|
+
const TSJS_EXTENSIONS = TS_EXTENSIONS.concat(JS_EXTENSIONS);
|
|
13232
|
+
const TS_EXTENSIONS_RE_GROUP = `\\.(?:${TS_EXTENSIONS.map((ext) => ext.substring(1)).join('|')})`;
|
|
13233
|
+
const TSJS_EXTENSIONS_RE_GROUP = `\\.(?:${TSJS_EXTENSIONS.map((ext) => ext.substring(1)).join(
|
|
13220
13234
|
'|'
|
|
13221
13235
|
)})`;
|
|
13222
|
-
|
|
13223
13236
|
const IS_POSIX = path$o.posix.sep === path$o.sep;
|
|
13224
13237
|
|
|
13225
13238
|
/**
|
|
@@ -13245,10 +13258,8 @@ async function resolveTSConfigJson(filename, cache) {
|
|
|
13245
13258
|
return; // ignore files that are not json
|
|
13246
13259
|
}
|
|
13247
13260
|
const tsconfig = path$o.resolve(filename);
|
|
13248
|
-
if (cache) {
|
|
13249
|
-
|
|
13250
|
-
return tsconfig;
|
|
13251
|
-
}
|
|
13261
|
+
if (cache && (cache.hasParseResult(tsconfig) || cache.hasParseResult(filename))) {
|
|
13262
|
+
return tsconfig;
|
|
13252
13263
|
}
|
|
13253
13264
|
return promises$1.stat(tsconfig).then((stat) => {
|
|
13254
13265
|
if (stat.isFile() || stat.isFIFO()) {
|
|
@@ -13317,12 +13328,15 @@ const resolve2posix = IS_POSIX
|
|
|
13317
13328
|
/**
|
|
13318
13329
|
*
|
|
13319
13330
|
* @param {import('./public.d.ts').TSConfckParseResult} result
|
|
13331
|
+
* @param {import('./public.d.ts').TSConfckParseOptions} [options]
|
|
13320
13332
|
* @returns {string[]}
|
|
13321
13333
|
*/
|
|
13322
|
-
function resolveReferencedTSConfigFiles(result) {
|
|
13334
|
+
function resolveReferencedTSConfigFiles(result, options) {
|
|
13323
13335
|
const dir = path$o.dirname(result.tsconfigFile);
|
|
13324
13336
|
return result.tsconfig.references.map((ref) => {
|
|
13325
|
-
const refPath = ref.path.endsWith('.json')
|
|
13337
|
+
const refPath = ref.path.endsWith('.json')
|
|
13338
|
+
? ref.path
|
|
13339
|
+
: path$o.join(ref.path, options?.configName ?? 'tsconfig.json');
|
|
13326
13340
|
return resolve2posix(dir, refPath);
|
|
13327
13341
|
});
|
|
13328
13342
|
}
|
|
@@ -13333,9 +13347,11 @@ function resolveReferencedTSConfigFiles(result) {
|
|
|
13333
13347
|
* @returns {import('./public.d.ts').TSConfckParseResult}
|
|
13334
13348
|
*/
|
|
13335
13349
|
function resolveSolutionTSConfig(filename, result) {
|
|
13350
|
+
const allowJs = result.tsconfig.compilerOptions?.allowJs;
|
|
13351
|
+
const extensions = allowJs ? TSJS_EXTENSIONS : TS_EXTENSIONS;
|
|
13336
13352
|
if (
|
|
13337
13353
|
result.referenced &&
|
|
13338
|
-
|
|
13354
|
+
extensions.some((ext) => filename.endsWith(ext)) &&
|
|
13339
13355
|
!isIncluded(filename, result)
|
|
13340
13356
|
) {
|
|
13341
13357
|
const solutionTSConfig = result.referenced.find((referenced) =>
|
|
@@ -13361,13 +13377,15 @@ function isIncluded(filename, result) {
|
|
|
13361
13377
|
if (files.includes(filename)) {
|
|
13362
13378
|
return true;
|
|
13363
13379
|
}
|
|
13380
|
+
const allowJs = result.tsconfig.compilerOptions?.allowJs;
|
|
13364
13381
|
const isIncluded = isGlobMatch(
|
|
13365
13382
|
absoluteFilename,
|
|
13366
13383
|
dir,
|
|
13367
|
-
result.tsconfig.include || (result.tsconfig.files ? [] : [GLOB_ALL_PATTERN])
|
|
13384
|
+
result.tsconfig.include || (result.tsconfig.files ? [] : [GLOB_ALL_PATTERN]),
|
|
13385
|
+
allowJs
|
|
13368
13386
|
);
|
|
13369
13387
|
if (isIncluded) {
|
|
13370
|
-
const isExcluded = isGlobMatch(absoluteFilename, dir, result.tsconfig.exclude || []);
|
|
13388
|
+
const isExcluded = isGlobMatch(absoluteFilename, dir, result.tsconfig.exclude || [], allowJs);
|
|
13371
13389
|
return !isExcluded;
|
|
13372
13390
|
}
|
|
13373
13391
|
return false;
|
|
@@ -13379,9 +13397,11 @@ function isIncluded(filename, result) {
|
|
|
13379
13397
|
* @param filename {string} posix style abolute path to filename to test
|
|
13380
13398
|
* @param dir {string} posix style absolute path to directory of tsconfig containing patterns
|
|
13381
13399
|
* @param patterns {string[]} glob patterns to match against
|
|
13400
|
+
* @param allowJs {boolean} allowJs setting in tsconfig to include js extensions in checks
|
|
13382
13401
|
* @returns {boolean} true when at least one pattern matches filename
|
|
13383
13402
|
*/
|
|
13384
|
-
function isGlobMatch(filename, dir, patterns) {
|
|
13403
|
+
function isGlobMatch(filename, dir, patterns, allowJs) {
|
|
13404
|
+
const extensions = allowJs ? TSJS_EXTENSIONS : TS_EXTENSIONS;
|
|
13385
13405
|
return patterns.some((pattern) => {
|
|
13386
13406
|
// filename must end with part of pattern that comes after last wildcard
|
|
13387
13407
|
let lastWildcardIndex = pattern.length;
|
|
@@ -13403,7 +13423,7 @@ function isGlobMatch(filename, dir, patterns) {
|
|
|
13403
13423
|
}
|
|
13404
13424
|
|
|
13405
13425
|
// if pattern ends with *, filename must end with a default extension
|
|
13406
|
-
if (pattern.endsWith('*') && !
|
|
13426
|
+
if (pattern.endsWith('*') && !extensions.some((ext) => filename.endsWith(ext))) {
|
|
13407
13427
|
return false;
|
|
13408
13428
|
}
|
|
13409
13429
|
|
|
@@ -13439,7 +13459,7 @@ function isGlobMatch(filename, dir, patterns) {
|
|
|
13439
13459
|
if (PATTERN_REGEX_CACHE.has(resolvedPattern)) {
|
|
13440
13460
|
return PATTERN_REGEX_CACHE.get(resolvedPattern).test(filename);
|
|
13441
13461
|
}
|
|
13442
|
-
const regex = pattern2regex(resolvedPattern);
|
|
13462
|
+
const regex = pattern2regex(resolvedPattern, allowJs);
|
|
13443
13463
|
PATTERN_REGEX_CACHE.set(resolvedPattern, regex);
|
|
13444
13464
|
return regex.test(filename);
|
|
13445
13465
|
});
|
|
@@ -13447,9 +13467,10 @@ function isGlobMatch(filename, dir, patterns) {
|
|
|
13447
13467
|
|
|
13448
13468
|
/**
|
|
13449
13469
|
* @param {string} resolvedPattern
|
|
13470
|
+
* @param {boolean} allowJs
|
|
13450
13471
|
* @returns {RegExp}
|
|
13451
13472
|
*/
|
|
13452
|
-
function pattern2regex(resolvedPattern) {
|
|
13473
|
+
function pattern2regex(resolvedPattern, allowJs) {
|
|
13453
13474
|
let regexStr = '^';
|
|
13454
13475
|
for (let i = 0; i < resolvedPattern.length; i++) {
|
|
13455
13476
|
const char = resolvedPattern[i];
|
|
@@ -13474,7 +13495,7 @@ function pattern2regex(resolvedPattern) {
|
|
|
13474
13495
|
|
|
13475
13496
|
// add known file endings if pattern ends on *
|
|
13476
13497
|
if (resolvedPattern.endsWith('*')) {
|
|
13477
|
-
regexStr +=
|
|
13498
|
+
regexStr += allowJs ? TSJS_EXTENSIONS_RE_GROUP : TS_EXTENSIONS_RE_GROUP;
|
|
13478
13499
|
}
|
|
13479
13500
|
regexStr += '$';
|
|
13480
13501
|
|
|
@@ -13494,12 +13515,15 @@ async function find(filename, options) {
|
|
|
13494
13515
|
return null;
|
|
13495
13516
|
}
|
|
13496
13517
|
const cache = options?.cache;
|
|
13497
|
-
|
|
13498
|
-
|
|
13518
|
+
const configName = options?.configName ?? 'tsconfig.json';
|
|
13519
|
+
if (cache?.hasConfigPath(dir, configName)) {
|
|
13520
|
+
return cache.getConfigPath(dir, configName);
|
|
13499
13521
|
}
|
|
13500
13522
|
const { /** @type {Promise<string|null>} */ promise, resolve, reject } = makePromise();
|
|
13501
|
-
|
|
13502
|
-
|
|
13523
|
+
if (options?.root && !path$o.isAbsolute(options.root)) {
|
|
13524
|
+
options.root = path$o.resolve(options.root);
|
|
13525
|
+
}
|
|
13526
|
+
findUp(dir, { promise, resolve, reject }, options);
|
|
13503
13527
|
return promise;
|
|
13504
13528
|
}
|
|
13505
13529
|
|
|
@@ -13507,16 +13531,15 @@ async function find(filename, options) {
|
|
|
13507
13531
|
*
|
|
13508
13532
|
* @param {string} dir
|
|
13509
13533
|
* @param {{promise:Promise<string|null>,resolve:(result:string|null)=>void,reject:(err:any)=>void}} madePromise
|
|
13510
|
-
* @param {import('./
|
|
13511
|
-
* @param {string} [root]
|
|
13534
|
+
* @param {import('./public.d.ts').TSConfckFindOptions} [options] - options
|
|
13512
13535
|
*/
|
|
13513
|
-
function findUp(dir, { resolve, reject, promise },
|
|
13514
|
-
const
|
|
13536
|
+
function findUp(dir, { resolve, reject, promise }, options) {
|
|
13537
|
+
const { cache, root, configName } = options ?? {};
|
|
13515
13538
|
if (cache) {
|
|
13516
|
-
if (cache.
|
|
13539
|
+
if (cache.hasConfigPath(dir, configName)) {
|
|
13517
13540
|
let cached;
|
|
13518
13541
|
try {
|
|
13519
|
-
cached = cache.
|
|
13542
|
+
cached = cache.getConfigPath(dir, configName);
|
|
13520
13543
|
} catch (e) {
|
|
13521
13544
|
reject(e);
|
|
13522
13545
|
return;
|
|
@@ -13527,9 +13550,10 @@ function findUp(dir, { resolve, reject, promise }, cache, root) {
|
|
|
13527
13550
|
resolve(cached);
|
|
13528
13551
|
}
|
|
13529
13552
|
} else {
|
|
13530
|
-
cache.
|
|
13553
|
+
cache.setConfigPath(dir, promise, configName);
|
|
13531
13554
|
}
|
|
13532
13555
|
}
|
|
13556
|
+
const tsconfig = path$o.join(dir, options?.configName ?? 'tsconfig.json');
|
|
13533
13557
|
fs$l.stat(tsconfig, (err, stats) => {
|
|
13534
13558
|
if (stats && (stats.isFile() || stats.isFIFO())) {
|
|
13535
13559
|
resolve(tsconfig);
|
|
@@ -13540,7 +13564,7 @@ function findUp(dir, { resolve, reject, promise }, cache, root) {
|
|
|
13540
13564
|
if (root === dir || (parent = path$o.dirname(dir)) === dir) {
|
|
13541
13565
|
resolve(null);
|
|
13542
13566
|
} else {
|
|
13543
|
-
findUp(parent, { promise, resolve, reject },
|
|
13567
|
+
findUp(parent, { promise, resolve, reject }, options);
|
|
13544
13568
|
}
|
|
13545
13569
|
}
|
|
13546
13570
|
});
|
|
@@ -13752,7 +13776,7 @@ async function parse$f(filename, options) {
|
|
|
13752
13776
|
result = await cache.getParseResult(tsconfigFile);
|
|
13753
13777
|
} else {
|
|
13754
13778
|
result = await parseFile$1(tsconfigFile, cache, filename === tsconfigFile);
|
|
13755
|
-
await Promise.all([parseExtends(result, cache), parseReferences(result,
|
|
13779
|
+
await Promise.all([parseExtends(result, cache), parseReferences(result, options)]);
|
|
13756
13780
|
}
|
|
13757
13781
|
resolve(resolveSolutionTSConfig(filename, result));
|
|
13758
13782
|
return promise;
|
|
@@ -13777,9 +13801,11 @@ async function parseFile$1(tsconfigFile, cache, skipCache) {
|
|
|
13777
13801
|
.readFile(tsconfigFile, 'utf-8')
|
|
13778
13802
|
.then(toJson)
|
|
13779
13803
|
.then((json) => {
|
|
13804
|
+
const parsed = JSON.parse(json);
|
|
13805
|
+
applyDefaults(parsed, tsconfigFile);
|
|
13780
13806
|
return {
|
|
13781
13807
|
tsconfigFile,
|
|
13782
|
-
tsconfig: normalizeTSConfig(
|
|
13808
|
+
tsconfig: normalizeTSConfig(parsed, path$o.dirname(tsconfigFile))
|
|
13783
13809
|
};
|
|
13784
13810
|
})
|
|
13785
13811
|
.catch((e) => {
|
|
@@ -13813,16 +13839,18 @@ function normalizeTSConfig(tsconfig, dir) {
|
|
|
13813
13839
|
/**
|
|
13814
13840
|
*
|
|
13815
13841
|
* @param {import('./public.d.ts').TSConfckParseResult} result
|
|
13816
|
-
* @param {import('./
|
|
13842
|
+
* @param {import('./public.d.ts').TSConfckParseOptions} [options]
|
|
13817
13843
|
* @returns {Promise<void>}
|
|
13818
13844
|
*/
|
|
13819
|
-
async function parseReferences(result,
|
|
13845
|
+
async function parseReferences(result, options) {
|
|
13820
13846
|
if (!result.tsconfig.references) {
|
|
13821
13847
|
return;
|
|
13822
13848
|
}
|
|
13823
|
-
const referencedFiles = resolveReferencedTSConfigFiles(result);
|
|
13824
|
-
const referenced = await Promise.all(
|
|
13825
|
-
|
|
13849
|
+
const referencedFiles = resolveReferencedTSConfigFiles(result, options);
|
|
13850
|
+
const referenced = await Promise.all(
|
|
13851
|
+
referencedFiles.map((file) => parseFile$1(file, options?.cache))
|
|
13852
|
+
);
|
|
13853
|
+
await Promise.all(referenced.map((ref) => parseExtends(ref, options?.cache)));
|
|
13826
13854
|
referenced.forEach((ref) => {
|
|
13827
13855
|
ref.solution = result;
|
|
13828
13856
|
});
|
|
@@ -14074,34 +14102,66 @@ class TSConfckParseError extends Error {
|
|
|
14074
14102
|
}
|
|
14075
14103
|
}
|
|
14076
14104
|
|
|
14105
|
+
/**
|
|
14106
|
+
*
|
|
14107
|
+
* @param {any} tsconfig
|
|
14108
|
+
* @param {string} tsconfigFile
|
|
14109
|
+
*/
|
|
14110
|
+
function applyDefaults(tsconfig, tsconfigFile) {
|
|
14111
|
+
if (isJSConfig(tsconfigFile)) {
|
|
14112
|
+
tsconfig.compilerOptions = {
|
|
14113
|
+
...DEFAULT_JSCONFIG_COMPILER_OPTIONS,
|
|
14114
|
+
...tsconfig.compilerOptions
|
|
14115
|
+
};
|
|
14116
|
+
}
|
|
14117
|
+
}
|
|
14118
|
+
|
|
14119
|
+
const DEFAULT_JSCONFIG_COMPILER_OPTIONS = {
|
|
14120
|
+
allowJs: true,
|
|
14121
|
+
maxNodeModuleJsDepth: 2,
|
|
14122
|
+
allowSyntheticDefaultImports: true,
|
|
14123
|
+
skipLibCheck: true,
|
|
14124
|
+
noEmit: true
|
|
14125
|
+
};
|
|
14126
|
+
|
|
14127
|
+
/**
|
|
14128
|
+
* @param {string} configFileName
|
|
14129
|
+
*/
|
|
14130
|
+
function isJSConfig(configFileName) {
|
|
14131
|
+
return path$o.basename(configFileName) === 'jsconfig.json';
|
|
14132
|
+
}
|
|
14133
|
+
|
|
14077
14134
|
/** @template T */
|
|
14078
14135
|
class TSConfckCache {
|
|
14079
14136
|
/**
|
|
14080
14137
|
* clear cache, use this if you have a long running process and tsconfig files have been added,changed or deleted
|
|
14081
14138
|
*/
|
|
14082
14139
|
clear() {
|
|
14083
|
-
this.#
|
|
14140
|
+
this.#configPaths.clear();
|
|
14084
14141
|
this.#parsed.clear();
|
|
14085
14142
|
}
|
|
14086
14143
|
|
|
14087
14144
|
/**
|
|
14088
|
-
* has cached closest
|
|
14145
|
+
* has cached closest config for files in dir
|
|
14089
14146
|
* @param {string} dir
|
|
14147
|
+
* @param {string} [configName=tsconfig.json]
|
|
14090
14148
|
* @returns {boolean}
|
|
14091
14149
|
*/
|
|
14092
|
-
|
|
14093
|
-
return this.#
|
|
14150
|
+
hasConfigPath(dir, configName = 'tsconfig.json') {
|
|
14151
|
+
return this.#configPaths.has(`${dir}/${configName}`);
|
|
14094
14152
|
}
|
|
14095
14153
|
|
|
14096
14154
|
/**
|
|
14097
14155
|
* get cached closest tsconfig for files in dir
|
|
14098
14156
|
* @param {string} dir
|
|
14157
|
+
* @param {string} [configName=tsconfig.json]
|
|
14099
14158
|
* @returns {Promise<string|null>|string|null}
|
|
14100
14159
|
* @throws {unknown} if cached value is an error
|
|
14101
14160
|
*/
|
|
14102
|
-
|
|
14103
|
-
const
|
|
14104
|
-
|
|
14161
|
+
getConfigPath(dir, configName = 'tsconfig.json') {
|
|
14162
|
+
const key = `${dir}/${configName}`;
|
|
14163
|
+
const value = this.#configPaths.get(key);
|
|
14164
|
+
if (value == null || value.length || value.then) {
|
|
14105
14165
|
return value;
|
|
14106
14166
|
} else {
|
|
14107
14167
|
throw value;
|
|
@@ -14157,19 +14217,21 @@ class TSConfckCache {
|
|
|
14157
14217
|
* @internal
|
|
14158
14218
|
* @private
|
|
14159
14219
|
* @param {string} dir
|
|
14160
|
-
* @param {Promise<string|null>}
|
|
14220
|
+
* @param {Promise<string|null>} configPath
|
|
14221
|
+
* @param {string} [configName=tsconfig.json]
|
|
14161
14222
|
*/
|
|
14162
|
-
|
|
14163
|
-
|
|
14164
|
-
|
|
14223
|
+
setConfigPath(dir, configPath, configName = 'tsconfig.json') {
|
|
14224
|
+
const key = `${dir}/${configName}`;
|
|
14225
|
+
this.#configPaths.set(key, configPath);
|
|
14226
|
+
configPath
|
|
14165
14227
|
.then((path) => {
|
|
14166
|
-
if (this.#
|
|
14167
|
-
this.#
|
|
14228
|
+
if (this.#configPaths.get(key) === configPath) {
|
|
14229
|
+
this.#configPaths.set(key, path);
|
|
14168
14230
|
}
|
|
14169
14231
|
})
|
|
14170
14232
|
.catch((e) => {
|
|
14171
|
-
if (this.#
|
|
14172
|
-
this.#
|
|
14233
|
+
if (this.#configPaths.get(key) === configPath) {
|
|
14234
|
+
this.#configPaths.set(key, e);
|
|
14173
14235
|
}
|
|
14174
14236
|
});
|
|
14175
14237
|
}
|
|
@@ -14180,7 +14242,7 @@ class TSConfckCache {
|
|
|
14180
14242
|
* @private
|
|
14181
14243
|
* @type{Map<string,(Promise<string|null>|string|null)>}
|
|
14182
14244
|
*/
|
|
14183
|
-
#
|
|
14245
|
+
#configPaths = new Map();
|
|
14184
14246
|
|
|
14185
14247
|
/**
|
|
14186
14248
|
* map files to their parsed tsconfig result
|
|
@@ -14192,8 +14254,9 @@ class TSConfckCache {
|
|
|
14192
14254
|
}
|
|
14193
14255
|
|
|
14194
14256
|
const debug$g = createDebugger('vite:esbuild');
|
|
14195
|
-
// IIFE content looks like `var MyLib = function() {`.
|
|
14196
|
-
|
|
14257
|
+
// IIFE content looks like `var MyLib = function() {`.
|
|
14258
|
+
// Spaces are removed and parameters are mangled when minified
|
|
14259
|
+
const IIFE_BEGIN_RE = /(const|var)\s+\S+\s*=\s*function\([^()]*\)\s*\{\s*"use strict";/;
|
|
14197
14260
|
const validExtensionRE = /\.\w+$/;
|
|
14198
14261
|
const jsxExtensionsRE = /\.(?:j|t)sx\b/;
|
|
14199
14262
|
let server;
|
|
@@ -15579,16 +15642,35 @@ class Mappings {
|
|
|
15579
15642
|
|
|
15580
15643
|
addEdit(sourceIndex, content, loc, nameIndex) {
|
|
15581
15644
|
if (content.length) {
|
|
15645
|
+
let contentLineEnd = content.indexOf('\n', 0);
|
|
15646
|
+
let previousContentLineEnd = -1;
|
|
15647
|
+
while (contentLineEnd >= 0) {
|
|
15648
|
+
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
15649
|
+
if (nameIndex >= 0) {
|
|
15650
|
+
segment.push(nameIndex);
|
|
15651
|
+
}
|
|
15652
|
+
this.rawSegments.push(segment);
|
|
15653
|
+
|
|
15654
|
+
this.generatedCodeLine += 1;
|
|
15655
|
+
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
15656
|
+
this.generatedCodeColumn = 0;
|
|
15657
|
+
|
|
15658
|
+
previousContentLineEnd = contentLineEnd;
|
|
15659
|
+
contentLineEnd = content.indexOf('\n', contentLineEnd + 1);
|
|
15660
|
+
}
|
|
15661
|
+
|
|
15582
15662
|
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
15583
15663
|
if (nameIndex >= 0) {
|
|
15584
15664
|
segment.push(nameIndex);
|
|
15585
15665
|
}
|
|
15586
15666
|
this.rawSegments.push(segment);
|
|
15667
|
+
|
|
15668
|
+
this.advance(content.slice(previousContentLineEnd + 1));
|
|
15587
15669
|
} else if (this.pending) {
|
|
15588
15670
|
this.rawSegments.push(this.pending);
|
|
15671
|
+
this.advance(content);
|
|
15589
15672
|
}
|
|
15590
15673
|
|
|
15591
|
-
this.advance(content);
|
|
15592
15674
|
this.pending = null;
|
|
15593
15675
|
}
|
|
15594
15676
|
|
|
@@ -27857,7 +27939,7 @@ function stringifyQuery(query) {
|
|
|
27857
27939
|
}
|
|
27858
27940
|
|
|
27859
27941
|
new Set(builtinModules);
|
|
27860
|
-
function matchAll(regex, string, addition) {
|
|
27942
|
+
function matchAll$1(regex, string, addition) {
|
|
27861
27943
|
const matches = [];
|
|
27862
27944
|
for (const match of string.matchAll(regex)) {
|
|
27863
27945
|
matches.push({
|
|
@@ -28396,7 +28478,7 @@ pathToFileURL(process.cwd());
|
|
|
28396
28478
|
const ESM_STATIC_IMPORT_RE = /(?<=\s|^|;)import\s*([\s"']*(?<imports>[\p{L}\p{M}\w\t\n\r $*,/{}@.]+)from\s*)?["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][\s;]*/gmu;
|
|
28397
28479
|
const TYPE_RE = /^\s*?type\s/;
|
|
28398
28480
|
function findStaticImports(code) {
|
|
28399
|
-
return matchAll(ESM_STATIC_IMPORT_RE, code, { type: "static" });
|
|
28481
|
+
return matchAll$1(ESM_STATIC_IMPORT_RE, code, { type: "static" });
|
|
28400
28482
|
}
|
|
28401
28483
|
function parseStaticImport(matched) {
|
|
28402
28484
|
const cleanedImports = clearImports(matched.imports);
|
|
@@ -28461,10 +28543,15 @@ function resolvePlugin(resolveOptions) {
|
|
|
28461
28543
|
const targetWeb = !ssr || ssrTarget === 'webworker';
|
|
28462
28544
|
// this is passed by @rollup/plugin-commonjs
|
|
28463
28545
|
const isRequire = resolveOpts?.custom?.['node-resolve']?.isRequire ?? false;
|
|
28546
|
+
// end user can configure different conditions for ssr and client.
|
|
28547
|
+
// falls back to client conditions if no ssr conditions supplied
|
|
28548
|
+
const ssrConditions = resolveOptions.ssrConfig?.resolve?.conditions ||
|
|
28549
|
+
resolveOptions.conditions;
|
|
28464
28550
|
const options = {
|
|
28465
28551
|
isRequire,
|
|
28466
28552
|
...resolveOptions,
|
|
28467
28553
|
scan: resolveOpts?.scan ?? resolveOptions.scan,
|
|
28554
|
+
conditions: ssr ? ssrConditions : resolveOptions.conditions,
|
|
28468
28555
|
};
|
|
28469
28556
|
const resolvedImports = resolveSubpathImports(id, importer, options, targetWeb);
|
|
28470
28557
|
if (resolvedImports) {
|
|
@@ -28852,7 +28939,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr = f
|
|
|
28852
28939
|
...options,
|
|
28853
28940
|
isRequire: false,
|
|
28854
28941
|
mainFields: DEFAULT_MAIN_FIELDS,
|
|
28855
|
-
extensions: DEFAULT_EXTENSIONS
|
|
28942
|
+
extensions: DEFAULT_EXTENSIONS,
|
|
28856
28943
|
});
|
|
28857
28944
|
}
|
|
28858
28945
|
if (!resolved) {
|
|
@@ -37957,6 +38044,31 @@ function buildHtmlPlugin(config) {
|
|
|
37957
38044
|
const publicBase = getBaseInHTML(relativeUrlPath, config);
|
|
37958
38045
|
const publicToRelative = (filename, importer) => publicBase + filename;
|
|
37959
38046
|
const toOutputPublicFilePath = (url) => toOutputFilePathInHtml(url.slice(1), 'public', relativeUrlPath, 'html', config, publicToRelative);
|
|
38047
|
+
// Determines true start position for the node, either the < character
|
|
38048
|
+
// position, or the newline at the end of the previous line's node.
|
|
38049
|
+
const nodeStartWithLeadingWhitespace = (node) => {
|
|
38050
|
+
if (node.sourceCodeLocation.startOffset === 0)
|
|
38051
|
+
return node.sourceCodeLocation.startOffset;
|
|
38052
|
+
// Gets the offset for the start of the line including the
|
|
38053
|
+
// newline trailing the previous node
|
|
38054
|
+
const lineStartOffset = node.sourceCodeLocation.startOffset -
|
|
38055
|
+
node.sourceCodeLocation.startCol;
|
|
38056
|
+
const line = s.slice(lineStartOffset, node.sourceCodeLocation.startOffset);
|
|
38057
|
+
// <previous-line-node></previous-line-node>
|
|
38058
|
+
// <target-node></target-node>
|
|
38059
|
+
//
|
|
38060
|
+
// Here we want to target the newline at the end of the previous line
|
|
38061
|
+
// as the start position for our target.
|
|
38062
|
+
//
|
|
38063
|
+
// <previous-node></previous-node>
|
|
38064
|
+
// <doubled-up-node></doubled-up-node><target-node></target-node>
|
|
38065
|
+
//
|
|
38066
|
+
// However, if there is content between our target node start and the
|
|
38067
|
+
// previous newline, we cannot strip it out without risking content deletion.
|
|
38068
|
+
return line.trim()
|
|
38069
|
+
? node.sourceCodeLocation.startOffset
|
|
38070
|
+
: lineStartOffset;
|
|
38071
|
+
};
|
|
37960
38072
|
// pre-transform
|
|
37961
38073
|
html = await applyHtmlTransforms(html, preHooks, {
|
|
37962
38074
|
path: publicPath,
|
|
@@ -38052,7 +38164,7 @@ function buildHtmlPlugin(config) {
|
|
|
38052
38164
|
const importExpression = `\nimport ${JSON.stringify(url)}`;
|
|
38053
38165
|
styleUrls.push({
|
|
38054
38166
|
url,
|
|
38055
|
-
start: node
|
|
38167
|
+
start: nodeStartWithLeadingWhitespace(node),
|
|
38056
38168
|
end: node.sourceCodeLocation.endOffset,
|
|
38057
38169
|
});
|
|
38058
38170
|
js += importExpression;
|
|
@@ -38107,7 +38219,7 @@ function buildHtmlPlugin(config) {
|
|
|
38107
38219
|
if (shouldRemove) {
|
|
38108
38220
|
// remove the script tag from the html. we are going to inject new
|
|
38109
38221
|
// ones in the end.
|
|
38110
|
-
s.remove(node
|
|
38222
|
+
s.remove(nodeStartWithLeadingWhitespace(node), node.sourceCodeLocation.endOffset);
|
|
38111
38223
|
}
|
|
38112
38224
|
});
|
|
38113
38225
|
isAsyncScriptMap.get(config).set(id, everyScriptIsAsync);
|
|
@@ -39047,13 +39159,7 @@ function cssPostPlugin(config) {
|
|
|
39047
39159
|
.filter((chunk) => chunk.type === 'chunk')
|
|
39048
39160
|
.map((chunk) => [chunk.preliminaryFileName, chunk.fileName]));
|
|
39049
39161
|
const pureCssChunkNames = [...pureCssChunks].map((pureCssChunk) => prelimaryNameToChunkMap[pureCssChunk.fileName]);
|
|
39050
|
-
const
|
|
39051
|
-
.map((file) => path$o.basename(file))
|
|
39052
|
-
.join('|')
|
|
39053
|
-
.replace(/\./g, '\\.');
|
|
39054
|
-
const emptyChunkRE = new RegExp(opts.format === 'es'
|
|
39055
|
-
? `\\bimport\\s*["'][^"']*(?:${emptyChunkFiles})["'];\n?`
|
|
39056
|
-
: `\\brequire\\(\\s*["'][^"']*(?:${emptyChunkFiles})["']\\);\n?`, 'g');
|
|
39162
|
+
const replaceEmptyChunk = getEmptyChunkReplacer(pureCssChunkNames, opts.format);
|
|
39057
39163
|
for (const file in bundle) {
|
|
39058
39164
|
const chunk = bundle[file];
|
|
39059
39165
|
if (chunk.type === 'chunk') {
|
|
@@ -39069,9 +39175,7 @@ function cssPostPlugin(config) {
|
|
|
39069
39175
|
}
|
|
39070
39176
|
return true;
|
|
39071
39177
|
});
|
|
39072
|
-
chunk.code = chunk.code
|
|
39073
|
-
// remove css import while preserving source map location
|
|
39074
|
-
(m) => `/* empty css ${''.padEnd(m.length - 15)}*/`);
|
|
39178
|
+
chunk.code = replaceEmptyChunk(chunk.code);
|
|
39075
39179
|
}
|
|
39076
39180
|
}
|
|
39077
39181
|
const removedPureCssFiles = removedPureCssFilesCache.get(config);
|
|
@@ -39112,6 +39216,23 @@ function cssPostPlugin(config) {
|
|
|
39112
39216
|
},
|
|
39113
39217
|
};
|
|
39114
39218
|
}
|
|
39219
|
+
/**
|
|
39220
|
+
* Create a replacer function that takes code and replaces given pure CSS chunk imports
|
|
39221
|
+
* @param pureCssChunkNames The chunks that only contain pure CSS and should be replaced
|
|
39222
|
+
* @param outputFormat The module output format to decide whether to replace `import` or `require`
|
|
39223
|
+
*/
|
|
39224
|
+
function getEmptyChunkReplacer(pureCssChunkNames, outputFormat) {
|
|
39225
|
+
const emptyChunkFiles = pureCssChunkNames
|
|
39226
|
+
.map((file) => path$o.basename(file))
|
|
39227
|
+
.join('|')
|
|
39228
|
+
.replace(/\./g, '\\.');
|
|
39229
|
+
const emptyChunkRE = new RegExp(outputFormat === 'es'
|
|
39230
|
+
? `\\bimport\\s*["'][^"']*(?:${emptyChunkFiles})["'];\n?`
|
|
39231
|
+
: `\\brequire\\(\\s*["'][^"']*(?:${emptyChunkFiles})["']\\);\n?`, 'g');
|
|
39232
|
+
return (code) => code.replace(emptyChunkRE,
|
|
39233
|
+
// remove css import while preserving source map location
|
|
39234
|
+
(m) => `/* empty css ${''.padEnd(m.length - 15)}*/`);
|
|
39235
|
+
}
|
|
39115
39236
|
function createCSSResolvers(config) {
|
|
39116
39237
|
let cssResolve;
|
|
39117
39238
|
let sassResolve;
|
|
@@ -39407,8 +39528,8 @@ function createCachedImport(imp) {
|
|
|
39407
39528
|
return cached;
|
|
39408
39529
|
};
|
|
39409
39530
|
}
|
|
39410
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
|
39411
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
|
39531
|
+
const importPostcssImport = createCachedImport(() => import('./dep-ce41d4ea.js').then(function (n) { return n.i; }));
|
|
39532
|
+
const importPostcssModules = createCachedImport(() => import('./dep-c3c41c00.js').then(function (n) { return n.i; }));
|
|
39412
39533
|
const importPostcss = createCachedImport(() => import('postcss'));
|
|
39413
39534
|
/**
|
|
39414
39535
|
* @experimental
|
|
@@ -40745,11 +40866,13 @@ function createIsConfiguredAsSsrExternal(config) {
|
|
|
40745
40866
|
const noExternalFilter = noExternal !== 'undefined' &&
|
|
40746
40867
|
typeof noExternal !== 'boolean' &&
|
|
40747
40868
|
createFilter(undefined, noExternal, { resolve: false });
|
|
40869
|
+
const targetConditions = config.ssr.resolve?.externalConditions || [];
|
|
40748
40870
|
const resolveOptions = {
|
|
40749
40871
|
...config.resolve,
|
|
40750
40872
|
root,
|
|
40751
40873
|
isProduction: false,
|
|
40752
40874
|
isBuild: true,
|
|
40875
|
+
conditions: targetConditions,
|
|
40753
40876
|
};
|
|
40754
40877
|
const isExternalizable = (id, importer, configuredAsExternal) => {
|
|
40755
40878
|
if (!bareImportRE.test(id) || id.includes('\0')) {
|
|
@@ -42299,6 +42422,9 @@ function importAnalysisPlugin(config) {
|
|
|
42299
42422
|
importerModule.isSelfAccepting = false;
|
|
42300
42423
|
return this.error(`Failed to resolve import "${url}" from "${path$o.relative(process.cwd(), importerFile)}". Does the file exist?`, pos);
|
|
42301
42424
|
}
|
|
42425
|
+
if (isExternalUrl(resolved.id)) {
|
|
42426
|
+
return [resolved.id, resolved.id];
|
|
42427
|
+
}
|
|
42302
42428
|
const isRelative = url[0] === '.';
|
|
42303
42429
|
const isSelfImport = !isRelative && cleanUrl(url) === cleanUrl(importer);
|
|
42304
42430
|
// normalize all imports into resolved URLs
|
|
@@ -42316,9 +42442,6 @@ function importAnalysisPlugin(config) {
|
|
|
42316
42442
|
else {
|
|
42317
42443
|
url = resolved.id;
|
|
42318
42444
|
}
|
|
42319
|
-
if (isExternalUrl(url)) {
|
|
42320
|
-
return [url, url];
|
|
42321
|
-
}
|
|
42322
42445
|
// if the resolved id is not a valid browser import specifier,
|
|
42323
42446
|
// prefix it to make it valid. We will strip this before feeding it
|
|
42324
42447
|
// back into the transform pipeline
|
|
@@ -42516,7 +42639,10 @@ function importAnalysisPlugin(config) {
|
|
|
42516
42639
|
return;
|
|
42517
42640
|
}
|
|
42518
42641
|
// Unexpected error, log the issue but avoid an unhandled exception
|
|
42519
|
-
config.logger.error(
|
|
42642
|
+
config.logger.error(`Pre-transform error: ${e.message}`, {
|
|
42643
|
+
error: e,
|
|
42644
|
+
timestamp: true,
|
|
42645
|
+
});
|
|
42520
42646
|
});
|
|
42521
42647
|
}
|
|
42522
42648
|
}
|
|
@@ -45018,7 +45144,8 @@ async function computeEntries(config) {
|
|
|
45018
45144
|
}
|
|
45019
45145
|
// Non-supported entry file types and virtual files should not be scanned for
|
|
45020
45146
|
// dependencies.
|
|
45021
|
-
entries = entries.filter((entry) => isScannable(entry) &&
|
|
45147
|
+
entries = entries.filter((entry) => isScannable(entry, config.optimizeDeps.extensions) &&
|
|
45148
|
+
fs$l.existsSync(entry));
|
|
45022
45149
|
return entries;
|
|
45023
45150
|
}
|
|
45024
45151
|
async function prepareEsbuildScanner(config, entries, deps, missing, scanContext) {
|
|
@@ -45148,12 +45275,11 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
45148
45275
|
namespace: 'html',
|
|
45149
45276
|
};
|
|
45150
45277
|
});
|
|
45151
|
-
|
|
45152
|
-
|
|
45153
|
-
let raw = await fsp.readFile(path, 'utf-8');
|
|
45278
|
+
const htmlTypeOnLoadCallback = async ({ path: p }) => {
|
|
45279
|
+
let raw = await fsp.readFile(p, 'utf-8');
|
|
45154
45280
|
// Avoid matching the content of the comment
|
|
45155
45281
|
raw = raw.replace(commentRE, '<!---->');
|
|
45156
|
-
const isHtml =
|
|
45282
|
+
const isHtml = p.endsWith('.html');
|
|
45157
45283
|
scriptRE.lastIndex = 0;
|
|
45158
45284
|
let js = '';
|
|
45159
45285
|
let scriptId = 0;
|
|
@@ -45179,7 +45305,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
45179
45305
|
if (lang === 'ts' || lang === 'tsx' || lang === 'jsx') {
|
|
45180
45306
|
loader = lang;
|
|
45181
45307
|
}
|
|
45182
|
-
else if (
|
|
45308
|
+
else if (p.endsWith('.astro')) {
|
|
45183
45309
|
loader = 'ts';
|
|
45184
45310
|
}
|
|
45185
45311
|
const srcMatch = openTag.match(srcRE);
|
|
@@ -45197,11 +45323,12 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
45197
45323
|
// since they may be used in the template
|
|
45198
45324
|
const contents = content +
|
|
45199
45325
|
(loader.startsWith('ts') ? extractImportPaths(content) : '');
|
|
45200
|
-
const key = `${
|
|
45326
|
+
const key = `${p}?id=${scriptId++}`;
|
|
45201
45327
|
if (contents.includes('import.meta.glob')) {
|
|
45202
45328
|
scripts[key] = {
|
|
45203
45329
|
loader: 'js',
|
|
45204
|
-
contents: await doTransformGlobImport(contents,
|
|
45330
|
+
contents: await doTransformGlobImport(contents, p, loader),
|
|
45331
|
+
resolveDir: normalizePath$3(path$o.dirname(p)),
|
|
45205
45332
|
pluginData: {
|
|
45206
45333
|
htmlType: { loader },
|
|
45207
45334
|
},
|
|
@@ -45211,6 +45338,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
45211
45338
|
scripts[key] = {
|
|
45212
45339
|
loader,
|
|
45213
45340
|
contents,
|
|
45341
|
+
resolveDir: normalizePath$3(path$o.dirname(p)),
|
|
45214
45342
|
pluginData: {
|
|
45215
45343
|
htmlType: { loader },
|
|
45216
45344
|
},
|
|
@@ -45223,7 +45351,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
45223
45351
|
// Especially for Svelte files, exports in <script context="module"> means module exports,
|
|
45224
45352
|
// exports in <script> means component props. To avoid having two same export name from the
|
|
45225
45353
|
// star exports, we need to ignore exports in <script>
|
|
45226
|
-
if (
|
|
45354
|
+
if (p.endsWith('.svelte') && context !== 'module') {
|
|
45227
45355
|
js += `import ${virtualModulePath}\n`;
|
|
45228
45356
|
}
|
|
45229
45357
|
else {
|
|
@@ -45235,14 +45363,20 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
45235
45363
|
// anywhere in a string. Svelte and Astro files can't have
|
|
45236
45364
|
// `export default` as code so we know if it's encountered it's a
|
|
45237
45365
|
// false positive (e.g. contained in a string)
|
|
45238
|
-
if (!
|
|
45366
|
+
if (!p.endsWith('.vue') || !js.includes('export default')) {
|
|
45239
45367
|
js += '\nexport default {}';
|
|
45240
45368
|
}
|
|
45241
45369
|
return {
|
|
45242
45370
|
loader: 'js',
|
|
45243
45371
|
contents: js,
|
|
45244
45372
|
};
|
|
45245
|
-
}
|
|
45373
|
+
};
|
|
45374
|
+
// extract scripts inside HTML-like files and treat it as a js module
|
|
45375
|
+
build.onLoad({ filter: htmlTypesRE, namespace: 'html' }, htmlTypeOnLoadCallback);
|
|
45376
|
+
// the onResolve above will use namespace=html but esbuild doesn't
|
|
45377
|
+
// call onResolve for glob imports and those will use namespace=file
|
|
45378
|
+
// https://github.com/evanw/esbuild/issues/3317
|
|
45379
|
+
build.onLoad({ filter: htmlTypesRE, namespace: 'file' }, htmlTypeOnLoadCallback);
|
|
45246
45380
|
// bare imports: record and externalize ----------------------------------
|
|
45247
45381
|
build.onResolve({
|
|
45248
45382
|
// avoid matching windows volume
|
|
@@ -45270,7 +45404,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
45270
45404
|
}
|
|
45271
45405
|
return externalUnlessEntry({ path: id });
|
|
45272
45406
|
}
|
|
45273
|
-
else if (isScannable(resolved)) {
|
|
45407
|
+
else if (isScannable(resolved, config.optimizeDeps.extensions)) {
|
|
45274
45408
|
const namespace = htmlTypesRE.test(resolved) ? 'html' : undefined;
|
|
45275
45409
|
// linked package, keep crawling
|
|
45276
45410
|
return {
|
|
@@ -45315,7 +45449,8 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
45315
45449
|
},
|
|
45316
45450
|
});
|
|
45317
45451
|
if (resolved) {
|
|
45318
|
-
if (shouldExternalizeDep(resolved, id) ||
|
|
45452
|
+
if (shouldExternalizeDep(resolved, id) ||
|
|
45453
|
+
!isScannable(resolved, config.optimizeDeps.extensions)) {
|
|
45319
45454
|
return externalUnlessEntry({ path: id });
|
|
45320
45455
|
}
|
|
45321
45456
|
const namespace = htmlTypesRE.test(resolved) ? 'html' : undefined;
|
|
@@ -45387,8 +45522,11 @@ function shouldExternalizeDep(resolvedId, rawId) {
|
|
|
45387
45522
|
}
|
|
45388
45523
|
return false;
|
|
45389
45524
|
}
|
|
45390
|
-
function isScannable(id) {
|
|
45391
|
-
return JS_TYPES_RE.test(id) ||
|
|
45525
|
+
function isScannable(id, extensions) {
|
|
45526
|
+
return (JS_TYPES_RE.test(id) ||
|
|
45527
|
+
htmlTypesRE.test(id) ||
|
|
45528
|
+
extensions?.includes(path$o.extname(id)) ||
|
|
45529
|
+
false);
|
|
45392
45530
|
}
|
|
45393
45531
|
// esbuild v0.18 only transforms decorators when `experimentalDecorators` is set to `true`.
|
|
45394
45532
|
// To preserve compat with the esbuild breaking change, we set `experimentalDecorators` to
|
|
@@ -47326,6 +47464,23 @@ function buildImportAnalysisPlugin(config) {
|
|
|
47326
47464
|
}
|
|
47327
47465
|
const s = new MagicString(code);
|
|
47328
47466
|
const rewroteMarkerStartPos = new Set(); // position of the leading double quote
|
|
47467
|
+
const fileDeps = [];
|
|
47468
|
+
const addFileDep = (url, runtime = false) => {
|
|
47469
|
+
const index = fileDeps.findIndex((dep) => dep.url === url);
|
|
47470
|
+
if (index === -1) {
|
|
47471
|
+
return fileDeps.push({ url, runtime }) - 1;
|
|
47472
|
+
}
|
|
47473
|
+
else {
|
|
47474
|
+
return index;
|
|
47475
|
+
}
|
|
47476
|
+
};
|
|
47477
|
+
const getFileDep = (index) => {
|
|
47478
|
+
const fileDep = fileDeps[index];
|
|
47479
|
+
if (!fileDep) {
|
|
47480
|
+
throw new Error(`Cannot find file dep at index ${index}`);
|
|
47481
|
+
}
|
|
47482
|
+
return fileDep;
|
|
47483
|
+
};
|
|
47329
47484
|
if (imports.length) {
|
|
47330
47485
|
for (let index = 0; index < imports.length; index++) {
|
|
47331
47486
|
// To handle escape sequences in specifier strings, the .n field will be provided where possible.
|
|
@@ -47353,12 +47508,12 @@ function buildImportAnalysisPlugin(config) {
|
|
|
47353
47508
|
analyzed.add(filename);
|
|
47354
47509
|
const chunk = bundle[filename];
|
|
47355
47510
|
if (chunk) {
|
|
47356
|
-
deps.add(chunk.fileName);
|
|
47511
|
+
deps.add(addFileDep(chunk.fileName));
|
|
47357
47512
|
chunk.imports.forEach(addDeps);
|
|
47358
47513
|
// Ensure that the css imported by current chunk is loaded after the dependencies.
|
|
47359
47514
|
// So the style of current chunk won't be overwritten unexpectedly.
|
|
47360
47515
|
chunk.viteMetadata.importedCss.forEach((file) => {
|
|
47361
|
-
deps.add(file);
|
|
47516
|
+
deps.add(addFileDep(file));
|
|
47362
47517
|
});
|
|
47363
47518
|
}
|
|
47364
47519
|
else {
|
|
@@ -47367,7 +47522,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
47367
47522
|
if (chunk) {
|
|
47368
47523
|
if (chunk.viteMetadata.importedCss.size) {
|
|
47369
47524
|
chunk.viteMetadata.importedCss.forEach((file) => {
|
|
47370
|
-
deps.add(file);
|
|
47525
|
+
deps.add(addFileDep(file));
|
|
47371
47526
|
});
|
|
47372
47527
|
hasRemovedPureCssChunk = true;
|
|
47373
47528
|
}
|
|
@@ -47390,7 +47545,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
47390
47545
|
? modulePreload === false
|
|
47391
47546
|
? // CSS deps use the same mechanism as module preloads, so even if disabled,
|
|
47392
47547
|
// we still need to pass these deps to the preload helper in dynamic imports.
|
|
47393
|
-
[...deps].filter((d) => d.endsWith('.css'))
|
|
47548
|
+
[...deps].filter((d) => getFileDep(d).url.endsWith('.css'))
|
|
47394
47549
|
: [...deps]
|
|
47395
47550
|
: [];
|
|
47396
47551
|
let renderedDeps;
|
|
@@ -47406,13 +47561,18 @@ function buildImportAnalysisPlugin(config) {
|
|
|
47406
47561
|
const cssDeps = [];
|
|
47407
47562
|
const otherDeps = [];
|
|
47408
47563
|
for (const dep of depsArray) {
|
|
47409
|
-
(dep.endsWith('.css')
|
|
47564
|
+
if (getFileDep(dep).url.endsWith('.css')) {
|
|
47565
|
+
cssDeps.push(dep);
|
|
47566
|
+
}
|
|
47567
|
+
else {
|
|
47568
|
+
otherDeps.push(dep);
|
|
47569
|
+
}
|
|
47410
47570
|
}
|
|
47411
47571
|
resolvedDeps = [
|
|
47412
|
-
...resolveDependencies(normalizedFile, otherDeps, {
|
|
47572
|
+
...resolveDependencies(normalizedFile, otherDeps.map((otherDep) => getFileDep(otherDep).url), {
|
|
47413
47573
|
hostId: file,
|
|
47414
47574
|
hostType: 'js',
|
|
47415
|
-
}),
|
|
47575
|
+
}).map((otherDep) => addFileDep(otherDep)),
|
|
47416
47576
|
...cssDeps,
|
|
47417
47577
|
];
|
|
47418
47578
|
}
|
|
@@ -47420,26 +47580,36 @@ function buildImportAnalysisPlugin(config) {
|
|
|
47420
47580
|
resolvedDeps = depsArray;
|
|
47421
47581
|
}
|
|
47422
47582
|
renderedDeps = resolvedDeps.map((dep) => {
|
|
47423
|
-
const replacement = toOutputFilePathInJS(dep, 'asset', chunk.fileName, 'js', config, toRelativePath);
|
|
47424
|
-
|
|
47425
|
-
|
|
47426
|
-
|
|
47427
|
-
return
|
|
47583
|
+
const replacement = toOutputFilePathInJS(getFileDep(dep).url, 'asset', chunk.fileName, 'js', config, toRelativePath);
|
|
47584
|
+
if (typeof replacement === 'string') {
|
|
47585
|
+
return addFileDep(replacement);
|
|
47586
|
+
}
|
|
47587
|
+
return addFileDep(replacement.runtime, true);
|
|
47428
47588
|
});
|
|
47429
47589
|
}
|
|
47430
47590
|
else {
|
|
47431
47591
|
renderedDeps = depsArray.map((d) =>
|
|
47432
47592
|
// Don't include the assets dir if the default asset file names
|
|
47433
47593
|
// are used, the path will be reconstructed by the import preload helper
|
|
47434
|
-
|
|
47435
|
-
? toRelativePath(d, file)
|
|
47436
|
-
: d)
|
|
47594
|
+
optimizeModulePreloadRelativePaths
|
|
47595
|
+
? addFileDep(toRelativePath(getFileDep(d).url, file))
|
|
47596
|
+
: d);
|
|
47437
47597
|
}
|
|
47438
|
-
s.update(markerStartPos, markerStartPos + preloadMarker.length + 2, `[${renderedDeps.join(',')}]`);
|
|
47598
|
+
s.update(markerStartPos, markerStartPos + preloadMarker.length + 2, `__vite__mapDeps([${renderedDeps.join(',')}])`);
|
|
47439
47599
|
rewroteMarkerStartPos.add(markerStartPos);
|
|
47440
47600
|
}
|
|
47441
47601
|
}
|
|
47442
47602
|
}
|
|
47603
|
+
const fileDepsCode = `[${fileDeps
|
|
47604
|
+
.map((fileDep) => fileDep.runtime ? fileDep.url : JSON.stringify(fileDep.url))
|
|
47605
|
+
.join(',')}]`;
|
|
47606
|
+
s.append(`\
|
|
47607
|
+
function __vite__mapDeps(indexes) {
|
|
47608
|
+
if (!__vite__mapDeps.viteFileDeps) {
|
|
47609
|
+
__vite__mapDeps.viteFileDeps = ${fileDepsCode}
|
|
47610
|
+
}
|
|
47611
|
+
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
|
|
47612
|
+
}`);
|
|
47443
47613
|
// there may still be markers due to inlined dynamic imports, remove
|
|
47444
47614
|
// all the markers regardless
|
|
47445
47615
|
let markerStartPos = indexOfMatchInSlice(code, preloadMarkerWithQuote);
|
|
@@ -54689,206 +54859,249 @@ chokidar.watch = watch;
|
|
|
54689
54859
|
|
|
54690
54860
|
var shellQuote$1 = {};
|
|
54691
54861
|
|
|
54692
|
-
|
|
54693
|
-
|
|
54694
|
-
|
|
54695
|
-
|
|
54696
|
-
|
|
54697
|
-
|
|
54698
|
-
|
|
54699
|
-
|
|
54700
|
-
|
|
54701
|
-
|
|
54702
|
-
|
|
54703
|
-
|
|
54704
|
-
|
|
54705
|
-
}
|
|
54706
|
-
}).join(' ');
|
|
54862
|
+
var quote = function quote(xs) {
|
|
54863
|
+
return xs.map(function (s) {
|
|
54864
|
+
if (s && typeof s === 'object') {
|
|
54865
|
+
return s.op.replace(/(.)/g, '\\$1');
|
|
54866
|
+
}
|
|
54867
|
+
if ((/["\s]/).test(s) && !(/'/).test(s)) {
|
|
54868
|
+
return "'" + s.replace(/(['\\])/g, '\\$1') + "'";
|
|
54869
|
+
}
|
|
54870
|
+
if ((/["'\s]/).test(s)) {
|
|
54871
|
+
return '"' + s.replace(/(["\\$`!])/g, '\\$1') + '"';
|
|
54872
|
+
}
|
|
54873
|
+
return String(s).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g, '$1\\$2');
|
|
54874
|
+
}).join(' ');
|
|
54707
54875
|
};
|
|
54708
54876
|
|
|
54709
54877
|
// '<(' is process substitution operator and
|
|
54710
54878
|
// can be parsed the same as control operator
|
|
54711
54879
|
var CONTROL = '(?:' + [
|
|
54712
|
-
|
|
54880
|
+
'\\|\\|',
|
|
54881
|
+
'\\&\\&',
|
|
54882
|
+
';;',
|
|
54883
|
+
'\\|\\&',
|
|
54884
|
+
'\\<\\(',
|
|
54885
|
+
'\\<\\<\\<',
|
|
54886
|
+
'>>',
|
|
54887
|
+
'>\\&',
|
|
54888
|
+
'<\\&',
|
|
54889
|
+
'[&;()|<>]'
|
|
54713
54890
|
].join('|') + ')';
|
|
54891
|
+
var controlRE = new RegExp('^' + CONTROL + '$');
|
|
54714
54892
|
var META = '|&;()<> \\t';
|
|
54715
|
-
var BAREWORD = '(\\\\[\'"' + META + ']|[^\\s\'"' + META + '])+';
|
|
54716
54893
|
var SINGLE_QUOTE = '"((\\\\"|[^"])*?)"';
|
|
54717
54894
|
var DOUBLE_QUOTE = '\'((\\\\\'|[^\'])*?)\'';
|
|
54895
|
+
var hash = /^#$/;
|
|
54896
|
+
|
|
54897
|
+
var SQ = "'";
|
|
54898
|
+
var DQ = '"';
|
|
54899
|
+
var DS = '$';
|
|
54718
54900
|
|
|
54719
54901
|
var TOKEN = '';
|
|
54902
|
+
var mult = 0x100000000; // Math.pow(16, 8);
|
|
54720
54903
|
for (var i = 0; i < 4; i++) {
|
|
54721
|
-
|
|
54904
|
+
TOKEN += (mult * Math.random()).toString(16);
|
|
54722
54905
|
}
|
|
54906
|
+
var startsWithToken = new RegExp('^' + TOKEN);
|
|
54723
54907
|
|
|
54724
|
-
|
|
54725
|
-
|
|
54726
|
-
if (typeof env !== 'function') return mapped;
|
|
54727
|
-
return mapped.reduce(function (acc, s) {
|
|
54728
|
-
if (typeof s === 'object') return acc.concat(s);
|
|
54729
|
-
var xs = s.split(RegExp('(' + TOKEN + '.*?' + TOKEN + ')', 'g'));
|
|
54730
|
-
if (xs.length === 1) return acc.concat(xs[0]);
|
|
54731
|
-
return acc.concat(xs.filter(Boolean).map(function (x) {
|
|
54732
|
-
if (RegExp('^' + TOKEN).test(x)) {
|
|
54733
|
-
return JSON.parse(x.split(TOKEN)[1]);
|
|
54734
|
-
}
|
|
54735
|
-
else return x;
|
|
54736
|
-
}));
|
|
54737
|
-
}, []);
|
|
54738
|
-
};
|
|
54908
|
+
function matchAll(s, r) {
|
|
54909
|
+
var origIndex = r.lastIndex;
|
|
54739
54910
|
|
|
54740
|
-
|
|
54741
|
-
|
|
54742
|
-
'(' + CONTROL + ')', // control chars
|
|
54743
|
-
'(' + BAREWORD + '|' + SINGLE_QUOTE + '|' + DOUBLE_QUOTE + ')*'
|
|
54744
|
-
].join('|'), 'g');
|
|
54745
|
-
var match = s.match(chunker).filter(Boolean);
|
|
54746
|
-
var commented = false;
|
|
54911
|
+
var matches = [];
|
|
54912
|
+
var matchObj;
|
|
54747
54913
|
|
|
54748
|
-
|
|
54749
|
-
|
|
54750
|
-
|
|
54751
|
-
|
|
54752
|
-
|
|
54753
|
-
|
|
54754
|
-
}
|
|
54755
|
-
if (RegExp('^' + CONTROL + '$').test(s)) {
|
|
54756
|
-
return { op: s };
|
|
54757
|
-
}
|
|
54914
|
+
while ((matchObj = r.exec(s))) {
|
|
54915
|
+
matches.push(matchObj);
|
|
54916
|
+
if (r.lastIndex === matchObj.index) {
|
|
54917
|
+
r.lastIndex += 1;
|
|
54918
|
+
}
|
|
54919
|
+
}
|
|
54758
54920
|
|
|
54759
|
-
|
|
54760
|
-
//
|
|
54761
|
-
// 1. inside single quotes, all characters are printed literally.
|
|
54762
|
-
// 2. inside double quotes, all characters are printed literally
|
|
54763
|
-
// except variables prefixed by '$' and backslashes followed by
|
|
54764
|
-
// either a double quote or another backslash.
|
|
54765
|
-
// 3. outside of any quotes, backslashes are treated as escape
|
|
54766
|
-
// characters and not printed (unless they are themselves escaped)
|
|
54767
|
-
// 4. quote context can switch mid-token if there is no whitespace
|
|
54768
|
-
// between the two quote contexts (e.g. all'one'"token" parses as
|
|
54769
|
-
// "allonetoken")
|
|
54770
|
-
var SQ = "'";
|
|
54771
|
-
var DQ = '"';
|
|
54772
|
-
var DS = '$';
|
|
54773
|
-
var BS = opts.escape || '\\';
|
|
54774
|
-
var quote = false;
|
|
54775
|
-
var esc = false;
|
|
54776
|
-
var out = '';
|
|
54777
|
-
var isGlob = false;
|
|
54778
|
-
|
|
54779
|
-
for (var i = 0, len = s.length; i < len; i++) {
|
|
54780
|
-
var c = s.charAt(i);
|
|
54781
|
-
isGlob = isGlob || (!quote && (c === '*' || c === '?'));
|
|
54782
|
-
if (esc) {
|
|
54783
|
-
out += c;
|
|
54784
|
-
esc = false;
|
|
54785
|
-
}
|
|
54786
|
-
else if (quote) {
|
|
54787
|
-
if (c === quote) {
|
|
54788
|
-
quote = false;
|
|
54789
|
-
}
|
|
54790
|
-
else if (quote == SQ) {
|
|
54791
|
-
out += c;
|
|
54792
|
-
}
|
|
54793
|
-
else { // Double quote
|
|
54794
|
-
if (c === BS) {
|
|
54795
|
-
i += 1;
|
|
54796
|
-
c = s.charAt(i);
|
|
54797
|
-
if (c === DQ || c === BS || c === DS) {
|
|
54798
|
-
out += c;
|
|
54799
|
-
} else {
|
|
54800
|
-
out += BS + c;
|
|
54801
|
-
}
|
|
54802
|
-
}
|
|
54803
|
-
else if (c === DS) {
|
|
54804
|
-
out += parseEnvVar();
|
|
54805
|
-
}
|
|
54806
|
-
else {
|
|
54807
|
-
out += c;
|
|
54808
|
-
}
|
|
54809
|
-
}
|
|
54810
|
-
}
|
|
54811
|
-
else if (c === DQ || c === SQ) {
|
|
54812
|
-
quote = c;
|
|
54813
|
-
}
|
|
54814
|
-
else if (RegExp('^' + CONTROL + '$').test(c)) {
|
|
54815
|
-
return { op: s };
|
|
54816
|
-
}
|
|
54817
|
-
else if (RegExp('^#$').test(c)) {
|
|
54818
|
-
commented = true;
|
|
54819
|
-
if (out.length){
|
|
54820
|
-
return [out, { comment: s.slice(i+1) + match.slice(j+1).join(' ') }];
|
|
54821
|
-
}
|
|
54822
|
-
return [{ comment: s.slice(i+1) + match.slice(j+1).join(' ') }];
|
|
54823
|
-
}
|
|
54824
|
-
else if (c === BS) {
|
|
54825
|
-
esc = true;
|
|
54826
|
-
}
|
|
54827
|
-
else if (c === DS) {
|
|
54828
|
-
out += parseEnvVar();
|
|
54829
|
-
}
|
|
54830
|
-
else out += c;
|
|
54831
|
-
}
|
|
54921
|
+
r.lastIndex = origIndex;
|
|
54832
54922
|
|
|
54833
|
-
|
|
54923
|
+
return matches;
|
|
54924
|
+
}
|
|
54834
54925
|
|
|
54835
|
-
|
|
54926
|
+
function getVar(env, pre, key) {
|
|
54927
|
+
var r = typeof env === 'function' ? env(key) : env[key];
|
|
54928
|
+
if (typeof r === 'undefined' && key != '') {
|
|
54929
|
+
r = '';
|
|
54930
|
+
} else if (typeof r === 'undefined') {
|
|
54931
|
+
r = '$';
|
|
54932
|
+
}
|
|
54836
54933
|
|
|
54837
|
-
|
|
54838
|
-
|
|
54839
|
-
|
|
54840
|
-
|
|
54841
|
-
|
|
54842
|
-
i += 1;
|
|
54843
|
-
if (s.charAt(i) === '}') {
|
|
54844
|
-
throw new Error("Bad substitution: " + s.substr(i - 2, 3));
|
|
54845
|
-
}
|
|
54846
|
-
varend = s.indexOf('}', i);
|
|
54847
|
-
if (varend < 0) {
|
|
54848
|
-
throw new Error("Bad substitution: " + s.substr(i));
|
|
54849
|
-
}
|
|
54850
|
-
varname = s.substr(i, varend - i);
|
|
54851
|
-
i = varend;
|
|
54852
|
-
}
|
|
54853
|
-
else if (/[*@#?$!_\-]/.test(s.charAt(i))) {
|
|
54854
|
-
varname = s.charAt(i);
|
|
54855
|
-
i += 1;
|
|
54856
|
-
}
|
|
54857
|
-
else {
|
|
54858
|
-
varend = s.substr(i).match(/[^\w\d_]/);
|
|
54859
|
-
if (!varend) {
|
|
54860
|
-
varname = s.substr(i);
|
|
54861
|
-
i = s.length;
|
|
54862
|
-
} else {
|
|
54863
|
-
varname = s.substr(i, varend.index);
|
|
54864
|
-
i += varend.index - 1;
|
|
54865
|
-
}
|
|
54866
|
-
}
|
|
54867
|
-
return getVar(null, '', varname);
|
|
54868
|
-
}
|
|
54869
|
-
})
|
|
54870
|
-
// finalize parsed aruments
|
|
54871
|
-
.reduce(function(prev, arg){
|
|
54872
|
-
if (arg === undefined){
|
|
54873
|
-
return prev;
|
|
54874
|
-
}
|
|
54875
|
-
return prev.concat(arg);
|
|
54876
|
-
},[]);
|
|
54934
|
+
if (typeof r === 'object') {
|
|
54935
|
+
return pre + TOKEN + JSON.stringify(r) + TOKEN;
|
|
54936
|
+
}
|
|
54937
|
+
return pre + r;
|
|
54938
|
+
}
|
|
54877
54939
|
|
|
54878
|
-
|
|
54879
|
-
|
|
54880
|
-
|
|
54881
|
-
|
|
54882
|
-
|
|
54883
|
-
|
|
54940
|
+
function parseInternal(string, env, opts) {
|
|
54941
|
+
if (!opts) {
|
|
54942
|
+
opts = {};
|
|
54943
|
+
}
|
|
54944
|
+
var BS = opts.escape || '\\';
|
|
54945
|
+
var BAREWORD = '(\\' + BS + '[\'"' + META + ']|[^\\s\'"' + META + '])+';
|
|
54884
54946
|
|
|
54885
|
-
|
|
54886
|
-
|
|
54887
|
-
|
|
54888
|
-
|
|
54889
|
-
|
|
54947
|
+
var chunker = new RegExp([
|
|
54948
|
+
'(' + CONTROL + ')', // control chars
|
|
54949
|
+
'(' + BAREWORD + '|' + SINGLE_QUOTE + '|' + DOUBLE_QUOTE + ')+'
|
|
54950
|
+
].join('|'), 'g');
|
|
54951
|
+
|
|
54952
|
+
var matches = matchAll(string, chunker);
|
|
54953
|
+
|
|
54954
|
+
if (matches.length === 0) {
|
|
54955
|
+
return [];
|
|
54956
|
+
}
|
|
54957
|
+
if (!env) {
|
|
54958
|
+
env = {};
|
|
54959
|
+
}
|
|
54960
|
+
|
|
54961
|
+
var commented = false;
|
|
54962
|
+
|
|
54963
|
+
return matches.map(function (match) {
|
|
54964
|
+
var s = match[0];
|
|
54965
|
+
if (!s || commented) {
|
|
54966
|
+
return void undefined;
|
|
54967
|
+
}
|
|
54968
|
+
if (controlRE.test(s)) {
|
|
54969
|
+
return { op: s };
|
|
54970
|
+
}
|
|
54971
|
+
|
|
54972
|
+
// Hand-written scanner/parser for Bash quoting rules:
|
|
54973
|
+
//
|
|
54974
|
+
// 1. inside single quotes, all characters are printed literally.
|
|
54975
|
+
// 2. inside double quotes, all characters are printed literally
|
|
54976
|
+
// except variables prefixed by '$' and backslashes followed by
|
|
54977
|
+
// either a double quote or another backslash.
|
|
54978
|
+
// 3. outside of any quotes, backslashes are treated as escape
|
|
54979
|
+
// characters and not printed (unless they are themselves escaped)
|
|
54980
|
+
// 4. quote context can switch mid-token if there is no whitespace
|
|
54981
|
+
// between the two quote contexts (e.g. all'one'"token" parses as
|
|
54982
|
+
// "allonetoken")
|
|
54983
|
+
var quote = false;
|
|
54984
|
+
var esc = false;
|
|
54985
|
+
var out = '';
|
|
54986
|
+
var isGlob = false;
|
|
54987
|
+
var i;
|
|
54988
|
+
|
|
54989
|
+
function parseEnvVar() {
|
|
54990
|
+
i += 1;
|
|
54991
|
+
var varend;
|
|
54992
|
+
var varname;
|
|
54993
|
+
var char = s.charAt(i);
|
|
54994
|
+
|
|
54995
|
+
if (char === '{') {
|
|
54996
|
+
i += 1;
|
|
54997
|
+
if (s.charAt(i) === '}') {
|
|
54998
|
+
throw new Error('Bad substitution: ' + s.slice(i - 2, i + 1));
|
|
54999
|
+
}
|
|
55000
|
+
varend = s.indexOf('}', i);
|
|
55001
|
+
if (varend < 0) {
|
|
55002
|
+
throw new Error('Bad substitution: ' + s.slice(i));
|
|
55003
|
+
}
|
|
55004
|
+
varname = s.slice(i, varend);
|
|
55005
|
+
i = varend;
|
|
55006
|
+
} else if ((/[*@#?$!_-]/).test(char)) {
|
|
55007
|
+
varname = char;
|
|
55008
|
+
i += 1;
|
|
55009
|
+
} else {
|
|
55010
|
+
var slicedFromI = s.slice(i);
|
|
55011
|
+
varend = slicedFromI.match(/[^\w\d_]/);
|
|
55012
|
+
if (!varend) {
|
|
55013
|
+
varname = slicedFromI;
|
|
55014
|
+
i = s.length;
|
|
55015
|
+
} else {
|
|
55016
|
+
varname = slicedFromI.slice(0, varend.index);
|
|
55017
|
+
i += varend.index - 1;
|
|
55018
|
+
}
|
|
55019
|
+
}
|
|
55020
|
+
return getVar(env, '', varname);
|
|
55021
|
+
}
|
|
55022
|
+
|
|
55023
|
+
for (i = 0; i < s.length; i++) {
|
|
55024
|
+
var c = s.charAt(i);
|
|
55025
|
+
isGlob = isGlob || (!quote && (c === '*' || c === '?'));
|
|
55026
|
+
if (esc) {
|
|
55027
|
+
out += c;
|
|
55028
|
+
esc = false;
|
|
55029
|
+
} else if (quote) {
|
|
55030
|
+
if (c === quote) {
|
|
55031
|
+
quote = false;
|
|
55032
|
+
} else if (quote == SQ) {
|
|
55033
|
+
out += c;
|
|
55034
|
+
} else { // Double quote
|
|
55035
|
+
if (c === BS) {
|
|
55036
|
+
i += 1;
|
|
55037
|
+
c = s.charAt(i);
|
|
55038
|
+
if (c === DQ || c === BS || c === DS) {
|
|
55039
|
+
out += c;
|
|
55040
|
+
} else {
|
|
55041
|
+
out += BS + c;
|
|
55042
|
+
}
|
|
55043
|
+
} else if (c === DS) {
|
|
55044
|
+
out += parseEnvVar();
|
|
55045
|
+
} else {
|
|
55046
|
+
out += c;
|
|
55047
|
+
}
|
|
55048
|
+
}
|
|
55049
|
+
} else if (c === DQ || c === SQ) {
|
|
55050
|
+
quote = c;
|
|
55051
|
+
} else if (controlRE.test(c)) {
|
|
55052
|
+
return { op: s };
|
|
55053
|
+
} else if (hash.test(c)) {
|
|
55054
|
+
commented = true;
|
|
55055
|
+
var commentObj = { comment: string.slice(match.index + i + 1) };
|
|
55056
|
+
if (out.length) {
|
|
55057
|
+
return [out, commentObj];
|
|
55058
|
+
}
|
|
55059
|
+
return [commentObj];
|
|
55060
|
+
} else if (c === BS) {
|
|
55061
|
+
esc = true;
|
|
55062
|
+
} else if (c === DS) {
|
|
55063
|
+
out += parseEnvVar();
|
|
55064
|
+
} else {
|
|
55065
|
+
out += c;
|
|
55066
|
+
}
|
|
55067
|
+
}
|
|
55068
|
+
|
|
55069
|
+
if (isGlob) {
|
|
55070
|
+
return { op: 'glob', pattern: out };
|
|
55071
|
+
}
|
|
55072
|
+
|
|
55073
|
+
return out;
|
|
55074
|
+
}).reduce(function (prev, arg) { // finalize parsed arguments
|
|
55075
|
+
// TODO: replace this whole reduce with a concat
|
|
55076
|
+
return typeof arg === 'undefined' ? prev : prev.concat(arg);
|
|
55077
|
+
}, []);
|
|
54890
55078
|
}
|
|
54891
55079
|
|
|
55080
|
+
var parse$5 = function parse(s, env, opts) {
|
|
55081
|
+
var mapped = parseInternal(s, env, opts);
|
|
55082
|
+
if (typeof env !== 'function') {
|
|
55083
|
+
return mapped;
|
|
55084
|
+
}
|
|
55085
|
+
return mapped.reduce(function (acc, s) {
|
|
55086
|
+
if (typeof s === 'object') {
|
|
55087
|
+
return acc.concat(s);
|
|
55088
|
+
}
|
|
55089
|
+
var xs = s.split(RegExp('(' + TOKEN + '.*?' + TOKEN + ')', 'g'));
|
|
55090
|
+
if (xs.length === 1) {
|
|
55091
|
+
return acc.concat(xs[0]);
|
|
55092
|
+
}
|
|
55093
|
+
return acc.concat(xs.filter(Boolean).map(function (x) {
|
|
55094
|
+
if (startsWithToken.test(x)) {
|
|
55095
|
+
return JSON.parse(x.split(TOKEN)[1]);
|
|
55096
|
+
}
|
|
55097
|
+
return x;
|
|
55098
|
+
}));
|
|
55099
|
+
}, []);
|
|
55100
|
+
};
|
|
55101
|
+
|
|
55102
|
+
shellQuote$1.quote = quote;
|
|
55103
|
+
shellQuote$1.parse = parse$5;
|
|
55104
|
+
|
|
54892
55105
|
var osx = {
|
|
54893
55106
|
'/Applications/Atom.app/Contents/MacOS/Atom': 'atom',
|
|
54894
55107
|
'/Applications/Atom Beta.app/Contents/MacOS/Atom Beta':
|
|
@@ -54932,10 +55145,10 @@ var osx = {
|
|
|
54932
55145
|
var linux = {
|
|
54933
55146
|
atom: 'atom',
|
|
54934
55147
|
Brackets: 'brackets',
|
|
54935
|
-
code: 'code',
|
|
54936
55148
|
'code-insiders': 'code-insiders',
|
|
54937
|
-
|
|
55149
|
+
code: 'code',
|
|
54938
55150
|
vscodium: 'vscodium',
|
|
55151
|
+
codium: 'codium',
|
|
54939
55152
|
emacs: 'emacs',
|
|
54940
55153
|
gvim: 'gvim',
|
|
54941
55154
|
'idea.sh': 'idea',
|
|
@@ -56529,18 +56742,20 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
|
56529
56742
|
};
|
|
56530
56743
|
urlStack = urlStack.concat(url);
|
|
56531
56744
|
const isCircular = (url) => urlStack.includes(url);
|
|
56532
|
-
const { isProduction, resolve: { dedupe, preserveSymlinks }, root, } = server.config;
|
|
56745
|
+
const { isProduction, resolve: { dedupe, preserveSymlinks }, root, ssr, } = server.config;
|
|
56746
|
+
const overrideConditions = ssr.resolve?.externalConditions || [];
|
|
56533
56747
|
const resolveOptions = {
|
|
56534
56748
|
mainFields: ['main'],
|
|
56535
56749
|
browserField: true,
|
|
56536
56750
|
conditions: [],
|
|
56537
|
-
overrideConditions: ['production', 'development'],
|
|
56751
|
+
overrideConditions: [...overrideConditions, 'production', 'development'],
|
|
56538
56752
|
extensions: ['.js', '.cjs', '.json'],
|
|
56539
56753
|
dedupe,
|
|
56540
56754
|
preserveSymlinks,
|
|
56541
56755
|
isBuild: false,
|
|
56542
56756
|
isProduction,
|
|
56543
56757
|
root,
|
|
56758
|
+
ssrConfig: ssr,
|
|
56544
56759
|
};
|
|
56545
56760
|
// Since dynamic imports can happen in parallel, we need to
|
|
56546
56761
|
// account for multiple pending deps and duplicate imports.
|
|
@@ -56638,22 +56853,13 @@ async function nodeImport(id, importer, resolveOptions) {
|
|
|
56638
56853
|
url = id;
|
|
56639
56854
|
}
|
|
56640
56855
|
else {
|
|
56641
|
-
const resolved = tryNodeResolve(id, importer,
|
|
56642
|
-
// Non-external modules can import ESM-only modules, but only outside
|
|
56643
|
-
// of test runs, because we use Node `require` in Jest to avoid segfault.
|
|
56644
|
-
// @ts-expect-error jest only exists when running Jest
|
|
56645
|
-
typeof jest === 'undefined'
|
|
56646
|
-
? { ...resolveOptions, tryEsmOnly: true }
|
|
56647
|
-
: resolveOptions, false);
|
|
56856
|
+
const resolved = tryNodeResolve(id, importer, { ...resolveOptions, tryEsmOnly: true }, false, undefined, true);
|
|
56648
56857
|
if (!resolved) {
|
|
56649
56858
|
const err = new Error(`Cannot find module '${id}' imported from '${importer}'`);
|
|
56650
56859
|
err.code = 'ERR_MODULE_NOT_FOUND';
|
|
56651
56860
|
throw err;
|
|
56652
56861
|
}
|
|
56653
|
-
url = resolved.id;
|
|
56654
|
-
if (usingDynamicImport) {
|
|
56655
|
-
url = pathToFileURL(url).toString();
|
|
56656
|
-
}
|
|
56862
|
+
url = pathToFileURL(resolved.id).toString();
|
|
56657
56863
|
}
|
|
56658
56864
|
const mod = await dynamicImport(url);
|
|
56659
56865
|
return proxyESM(mod);
|
|
@@ -65015,7 +65221,7 @@ function transformMiddleware(server) {
|
|
|
65015
65221
|
}
|
|
65016
65222
|
else {
|
|
65017
65223
|
warning =
|
|
65018
|
-
`
|
|
65224
|
+
`Files in the public directory are served at the root path.\n` +
|
|
65019
65225
|
`Instead of ${colors$1.cyan(url)}, use ${colors$1.cyan(url.replace(publicPath, '/'))}.`;
|
|
65020
65226
|
}
|
|
65021
65227
|
logger.warn(colors$1.yellow(warning));
|
|
@@ -65340,7 +65546,10 @@ function preTransformRequest(server, url, base) {
|
|
|
65340
65546
|
return;
|
|
65341
65547
|
}
|
|
65342
65548
|
// Unexpected error, log the issue but avoid an unhandled exception
|
|
65343
|
-
server.config.logger.error(e.message
|
|
65549
|
+
server.config.logger.error(`Pre-transform error: ${e.message}`, {
|
|
65550
|
+
error: e,
|
|
65551
|
+
timestamp: true,
|
|
65552
|
+
});
|
|
65344
65553
|
});
|
|
65345
65554
|
}
|
|
65346
65555
|
|
|
@@ -66453,7 +66662,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
|
66453
66662
|
mainFields: config.resolve?.mainFields ?? DEFAULT_MAIN_FIELDS,
|
|
66454
66663
|
browserField: config.resolve?.browserField ?? true,
|
|
66455
66664
|
conditions: config.resolve?.conditions ?? [],
|
|
66456
|
-
extensions: config.resolve?.extensions ?? DEFAULT_EXTENSIONS
|
|
66665
|
+
extensions: config.resolve?.extensions ?? DEFAULT_EXTENSIONS,
|
|
66457
66666
|
dedupe: config.resolve?.dedupe ?? [],
|
|
66458
66667
|
preserveSymlinks: config.resolve?.preserveSymlinks ?? false,
|
|
66459
66668
|
alias: resolvedAlias,
|
|
@@ -66661,12 +66870,6 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
|
66661
66870
|
else if (middlewareMode === 'html') {
|
|
66662
66871
|
logger.warn(colors$1.yellow(`Setting server.middlewareMode to 'html' is deprecated, set server.middlewareMode to \`true\` instead`));
|
|
66663
66872
|
}
|
|
66664
|
-
if (config.server?.force &&
|
|
66665
|
-
!isBuild &&
|
|
66666
|
-
config.optimizeDeps?.force === undefined) {
|
|
66667
|
-
resolved.optimizeDeps.force = true;
|
|
66668
|
-
logger.warn(colors$1.yellow(`server.force is deprecated, use optimizeDeps.force instead`));
|
|
66669
|
-
}
|
|
66670
66873
|
debug?.(`using resolved config: %O`, {
|
|
66671
66874
|
...resolved,
|
|
66672
66875
|
plugins: resolved.plugins.map((p) => p.name),
|
|
@@ -66848,7 +67051,7 @@ async function bundleConfigFile(fileName, isESM) {
|
|
|
66848
67051
|
conditions: [],
|
|
66849
67052
|
overrideConditions: ['node'],
|
|
66850
67053
|
dedupe: [],
|
|
66851
|
-
extensions: DEFAULT_EXTENSIONS
|
|
67054
|
+
extensions: DEFAULT_EXTENSIONS,
|
|
66852
67055
|
preserveSymlinks: false,
|
|
66853
67056
|
packageCache,
|
|
66854
67057
|
isRequire,
|