vite 6.0.0-alpha.17 → 6.0.0-alpha.19
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 +112 -203
- package/client.d.ts +4 -0
- package/dist/client/client.mjs +614 -612
- package/dist/client/env.mjs +18 -24
- package/dist/node/chunks/{dep-DVlS5vGL.js → dep-BWEMV5Th.js} +44780 -46989
- package/dist/node/chunks/{dep-CrWVpuYf.js → dep-D-7KCb9p.js} +32 -2
- package/dist/node/chunks/{dep-DJVII9WQ.js → dep-MbEgMyUv.js} +12 -16
- package/dist/node/chunks/{dep-CNsiFGD3.js → dep-bCS_cgqC.js} +1 -1
- package/dist/node/cli.js +253 -263
- package/dist/node/constants.js +105 -108
- package/dist/node/index.d.ts +157 -108
- package/dist/node/index.js +125 -143
- package/dist/node/module-runner.d.ts +21 -7
- package/dist/node/module-runner.js +201 -151
- package/dist/node-cjs/publicUtils.cjs +538 -625
- package/package.json +20 -23
- package/types/customEvent.d.ts +1 -0
- package/dist/client/client.mjs.map +0 -1
- package/dist/client/env.mjs.map +0 -1
@@ -14,17 +14,18 @@ var readline = require('node:readline');
|
|
14
14
|
var require$$2 = require('os');
|
15
15
|
|
16
16
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
17
|
-
const { version: version$2 } = JSON.parse(
|
17
|
+
const { version: version$2 } = JSON.parse(
|
18
|
+
fs$1.readFileSync(new URL("../../package.json", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)))).toString()
|
19
|
+
);
|
18
20
|
const VERSION = version$2;
|
19
|
-
/**
|
20
|
-
* Prefix for resolved fs paths, since windows paths may not be valid as URLs.
|
21
|
-
*/
|
22
21
|
const FS_PREFIX = `/@fs/`;
|
23
22
|
const VITE_PACKAGE_DIR = path$3.resolve(
|
24
|
-
// import.meta.url is `dist/node/constants.js` after bundle
|
25
|
-
node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href))),
|
26
|
-
|
27
|
-
|
23
|
+
// import.meta.url is `dist/node/constants.js` after bundle
|
24
|
+
node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href))),
|
25
|
+
"../../.."
|
26
|
+
);
|
27
|
+
const CLIENT_ENTRY = path$3.resolve(VITE_PACKAGE_DIR, "dist/client/client.mjs");
|
28
|
+
path$3.resolve(VITE_PACKAGE_DIR, "dist/client/env.mjs");
|
28
29
|
path$3.dirname(CLIENT_ENTRY);
|
29
30
|
|
30
31
|
const comma = ','.charCodeAt(0);
|
@@ -1127,11 +1128,11 @@ function requireNode () {
|
|
1127
1128
|
}
|
1128
1129
|
|
1129
1130
|
/**
|
1130
|
-
* Invokes `util.
|
1131
|
+
* Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
|
1131
1132
|
*/
|
1132
1133
|
|
1133
1134
|
function log(...args) {
|
1134
|
-
return process.stderr.write(util.
|
1135
|
+
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
|
1135
1136
|
}
|
1136
1137
|
|
1137
1138
|
/**
|
@@ -3353,380 +3354,318 @@ const builtins = 'arguments Infinity NaN undefined null true false eval uneval i
|
|
3353
3354
|
const forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(' '));
|
3354
3355
|
forbiddenIdentifiers.add('');
|
3355
3356
|
|
3356
|
-
const isWindows = typeof process !==
|
3357
|
+
const isWindows = typeof process !== "undefined" && process.platform === "win32";
|
3357
3358
|
const windowsSlashRE = /\\/g;
|
3358
3359
|
function slash(p) {
|
3359
|
-
|
3360
|
+
return p.replace(windowsSlashRE, "/");
|
3360
3361
|
}
|
3361
3362
|
const postfixRE = /[?#].*$/;
|
3362
3363
|
function cleanUrl(url) {
|
3363
|
-
|
3364
|
+
return url.replace(postfixRE, "");
|
3364
3365
|
}
|
3365
3366
|
function withTrailingSlash(path) {
|
3366
|
-
|
3367
|
-
|
3368
|
-
|
3369
|
-
|
3367
|
+
if (path[path.length - 1] !== "/") {
|
3368
|
+
return `${path}/`;
|
3369
|
+
}
|
3370
|
+
return path;
|
3370
3371
|
}
|
3371
3372
|
|
3372
3373
|
if (process.versions.pnp) {
|
3373
|
-
|
3374
|
-
|
3375
|
-
|
3376
|
-
|
3374
|
+
try {
|
3375
|
+
node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)))("pnpapi");
|
3376
|
+
} catch {
|
3377
|
+
}
|
3377
3378
|
}
|
3378
3379
|
|
3379
3380
|
const createFilter = createFilter$1;
|
3380
|
-
|
3381
|
-
node_module.builtinModules.filter((id) => !id.includes(':'));
|
3381
|
+
node_module.builtinModules.filter((id) => !id.includes(":"));
|
3382
3382
|
function isInNodeModules(id) {
|
3383
|
-
|
3383
|
+
return id.includes("node_modules");
|
3384
3384
|
}
|
3385
|
-
// TODO: use import()
|
3386
3385
|
const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)));
|
3387
|
-
function resolveDependencyVersion(dep, pkgRelativePath =
|
3388
|
-
|
3389
|
-
|
3386
|
+
function resolveDependencyVersion(dep, pkgRelativePath = "../../package.json") {
|
3387
|
+
const pkgPath = path$3.resolve(_require.resolve(dep), pkgRelativePath);
|
3388
|
+
return JSON.parse(fs$1.readFileSync(pkgPath, "utf-8")).version;
|
3390
3389
|
}
|
3391
|
-
const rollupVersion = resolveDependencyVersion(
|
3392
|
-
// set in bin/vite.js
|
3390
|
+
const rollupVersion = resolveDependencyVersion("rollup");
|
3393
3391
|
const filter = process.env.VITE_DEBUG_FILTER;
|
3394
3392
|
const DEBUG = process.env.DEBUG;
|
3395
3393
|
function createDebugger(namespace, options = {}) {
|
3396
|
-
|
3397
|
-
|
3398
|
-
|
3399
|
-
|
3400
|
-
|
3401
|
-
|
3402
|
-
|
3403
|
-
|
3404
|
-
|
3405
|
-
|
3406
|
-
|
3407
|
-
|
3408
|
-
|
3409
|
-
|
3394
|
+
const log = debug$2(namespace);
|
3395
|
+
const { onlyWhenFocused } = options;
|
3396
|
+
let enabled = log.enabled;
|
3397
|
+
if (enabled && onlyWhenFocused) {
|
3398
|
+
const ns = typeof onlyWhenFocused === "string" ? onlyWhenFocused : namespace;
|
3399
|
+
enabled = !!DEBUG?.includes(ns);
|
3400
|
+
}
|
3401
|
+
if (enabled) {
|
3402
|
+
return (...args) => {
|
3403
|
+
if (!filter || args.some((a) => a?.includes?.(filter))) {
|
3404
|
+
log(...args);
|
3405
|
+
}
|
3406
|
+
};
|
3407
|
+
}
|
3410
3408
|
}
|
3411
3409
|
function testCaseInsensitiveFS() {
|
3412
|
-
|
3413
|
-
|
3414
|
-
|
3415
|
-
|
3416
|
-
|
3417
|
-
|
3418
|
-
|
3419
|
-
|
3410
|
+
if (!CLIENT_ENTRY.endsWith("client.mjs")) {
|
3411
|
+
throw new Error(
|
3412
|
+
`cannot test case insensitive FS, CLIENT_ENTRY const doesn't contain client.mjs`
|
3413
|
+
);
|
3414
|
+
}
|
3415
|
+
if (!fs$1.existsSync(CLIENT_ENTRY)) {
|
3416
|
+
throw new Error(
|
3417
|
+
"cannot test case insensitive FS, CLIENT_ENTRY does not point to an existing file: " + CLIENT_ENTRY
|
3418
|
+
);
|
3419
|
+
}
|
3420
|
+
return fs$1.existsSync(CLIENT_ENTRY.replace("client.mjs", "cLiEnT.mjs"));
|
3420
3421
|
}
|
3421
3422
|
const isCaseInsensitiveFS = testCaseInsensitiveFS();
|
3422
3423
|
const VOLUME_RE = /^[A-Z]:/i;
|
3423
3424
|
function normalizePath(id) {
|
3424
|
-
|
3425
|
+
return path$3.posix.normalize(isWindows ? slash(id) : id);
|
3425
3426
|
}
|
3426
3427
|
function fsPathFromId(id) {
|
3427
|
-
|
3428
|
-
|
3428
|
+
const fsPath = normalizePath(
|
3429
|
+
id.startsWith(FS_PREFIX) ? id.slice(FS_PREFIX.length) : id
|
3430
|
+
);
|
3431
|
+
return fsPath[0] === "/" || VOLUME_RE.test(fsPath) ? fsPath : `/${fsPath}`;
|
3429
3432
|
}
|
3430
3433
|
function fsPathFromUrl(url) {
|
3431
|
-
|
3434
|
+
return fsPathFromId(cleanUrl(url));
|
3432
3435
|
}
|
3433
|
-
/**
|
3434
|
-
* Check if dir is a parent of file
|
3435
|
-
*
|
3436
|
-
* Warning: parameters are not validated, only works with normalized absolute paths
|
3437
|
-
*
|
3438
|
-
* @param dir - normalized absolute path
|
3439
|
-
* @param file - normalized absolute path
|
3440
|
-
* @returns true if dir is a parent of file
|
3441
|
-
*/
|
3442
3436
|
function isParentDirectory(dir, file) {
|
3443
|
-
|
3444
|
-
|
3445
|
-
(isCaseInsensitiveFS && file.toLowerCase().startsWith(dir.toLowerCase())));
|
3437
|
+
dir = withTrailingSlash(dir);
|
3438
|
+
return file.startsWith(dir) || isCaseInsensitiveFS && file.toLowerCase().startsWith(dir.toLowerCase());
|
3446
3439
|
}
|
3447
|
-
/**
|
3448
|
-
* Check if 2 file name are identical
|
3449
|
-
*
|
3450
|
-
* Warning: parameters are not validated, only works with normalized absolute paths
|
3451
|
-
*
|
3452
|
-
* @param file1 - normalized absolute path
|
3453
|
-
* @param file2 - normalized absolute path
|
3454
|
-
* @returns true if both files url are identical
|
3455
|
-
*/
|
3456
3440
|
function isSameFileUri(file1, file2) {
|
3457
|
-
|
3458
|
-
(isCaseInsensitiveFS && file1.toLowerCase() === file2.toLowerCase()));
|
3441
|
+
return file1 === file2 || isCaseInsensitiveFS && file1.toLowerCase() === file2.toLowerCase();
|
3459
3442
|
}
|
3460
3443
|
const trailingSeparatorRE = /[?&]$/;
|
3461
3444
|
const timestampRE = /\bt=\d{13}&?\b/;
|
3462
3445
|
function removeTimestampQuery(url) {
|
3463
|
-
|
3446
|
+
return url.replace(timestampRE, "").replace(trailingSeparatorRE, "");
|
3464
3447
|
}
|
3465
3448
|
function isObject$1(value) {
|
3466
|
-
|
3449
|
+
return Object.prototype.toString.call(value) === "[object Object]";
|
3467
3450
|
}
|
3468
3451
|
function tryStatSync(file) {
|
3469
|
-
|
3470
|
-
|
3471
|
-
|
3472
|
-
|
3473
|
-
catch {
|
3474
|
-
// Ignore errors
|
3475
|
-
}
|
3452
|
+
try {
|
3453
|
+
return fs$1.statSync(file, { throwIfNoEntry: false });
|
3454
|
+
} catch {
|
3455
|
+
}
|
3476
3456
|
}
|
3477
|
-
const splitRE = /\r?\n/g;
|
3478
3457
|
function isFileReadable(filename) {
|
3479
|
-
|
3480
|
-
|
3481
|
-
|
3482
|
-
|
3483
|
-
|
3484
|
-
|
3485
|
-
|
3486
|
-
|
3487
|
-
|
3488
|
-
return false;
|
3489
|
-
}
|
3458
|
+
if (!tryStatSync(filename)) {
|
3459
|
+
return false;
|
3460
|
+
}
|
3461
|
+
try {
|
3462
|
+
fs$1.accessSync(filename, fs$1.constants.R_OK);
|
3463
|
+
return true;
|
3464
|
+
} catch {
|
3465
|
+
return false;
|
3466
|
+
}
|
3490
3467
|
}
|
3491
3468
|
function arraify(target) {
|
3492
|
-
|
3469
|
+
return Array.isArray(target) ? target : [target];
|
3493
3470
|
}
|
3494
3471
|
path$3.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href))));
|
3495
3472
|
function backwardCompatibleWorkerPlugins(plugins) {
|
3496
|
-
|
3497
|
-
|
3498
|
-
|
3499
|
-
|
3500
|
-
|
3501
|
-
|
3502
|
-
|
3473
|
+
if (Array.isArray(plugins)) {
|
3474
|
+
return plugins;
|
3475
|
+
}
|
3476
|
+
if (typeof plugins === "function") {
|
3477
|
+
return plugins();
|
3478
|
+
}
|
3479
|
+
return [];
|
3503
3480
|
}
|
3504
3481
|
function mergeConfigRecursively(defaults, overrides, rootPath) {
|
3505
|
-
|
3506
|
-
|
3507
|
-
|
3508
|
-
|
3509
|
-
|
3510
|
-
|
3511
|
-
|
3512
|
-
|
3513
|
-
|
3514
|
-
|
3515
|
-
}
|
3516
|
-
// fields that require special handling
|
3517
|
-
if (key === 'alias' && (rootPath === 'resolve' || rootPath === '')) {
|
3518
|
-
merged[key] = mergeAlias(existing, value);
|
3519
|
-
continue;
|
3520
|
-
}
|
3521
|
-
else if (key === 'assetsInclude' && rootPath === '') {
|
3522
|
-
merged[key] = [].concat(existing, value);
|
3523
|
-
continue;
|
3524
|
-
}
|
3525
|
-
else if (key === 'noExternal' && // TODO: environments
|
3526
|
-
rootPath === 'ssr' &&
|
3527
|
-
(existing === true || value === true)) {
|
3528
|
-
merged[key] = true;
|
3529
|
-
continue;
|
3530
|
-
}
|
3531
|
-
else if (key === 'plugins' && rootPath === 'worker') {
|
3532
|
-
merged[key] = () => [
|
3533
|
-
...backwardCompatibleWorkerPlugins(existing),
|
3534
|
-
...backwardCompatibleWorkerPlugins(value),
|
3535
|
-
];
|
3536
|
-
continue;
|
3537
|
-
}
|
3538
|
-
if (Array.isArray(existing) || Array.isArray(value)) {
|
3539
|
-
merged[key] = [...arraify(existing), ...arraify(value)];
|
3540
|
-
continue;
|
3541
|
-
}
|
3542
|
-
if (isObject$1(existing) && isObject$1(value)) {
|
3543
|
-
merged[key] = mergeConfigRecursively(existing, value, rootPath ? `${rootPath}.${key}` : key);
|
3544
|
-
continue;
|
3545
|
-
}
|
3546
|
-
merged[key] = value;
|
3482
|
+
const merged = { ...defaults };
|
3483
|
+
for (const key in overrides) {
|
3484
|
+
const value = overrides[key];
|
3485
|
+
if (value == null) {
|
3486
|
+
continue;
|
3487
|
+
}
|
3488
|
+
const existing = merged[key];
|
3489
|
+
if (existing == null) {
|
3490
|
+
merged[key] = value;
|
3491
|
+
continue;
|
3547
3492
|
}
|
3548
|
-
|
3493
|
+
if (key === "alias" && (rootPath === "resolve" || rootPath === "")) {
|
3494
|
+
merged[key] = mergeAlias(existing, value);
|
3495
|
+
continue;
|
3496
|
+
} else if (key === "assetsInclude" && rootPath === "") {
|
3497
|
+
merged[key] = [].concat(existing, value);
|
3498
|
+
continue;
|
3499
|
+
} else if (key === "noExternal" && // TODO: environments
|
3500
|
+
rootPath === "ssr" && (existing === true || value === true)) {
|
3501
|
+
merged[key] = true;
|
3502
|
+
continue;
|
3503
|
+
} else if (key === "plugins" && rootPath === "worker") {
|
3504
|
+
merged[key] = () => [
|
3505
|
+
...backwardCompatibleWorkerPlugins(existing),
|
3506
|
+
...backwardCompatibleWorkerPlugins(value)
|
3507
|
+
];
|
3508
|
+
continue;
|
3509
|
+
}
|
3510
|
+
if (Array.isArray(existing) || Array.isArray(value)) {
|
3511
|
+
merged[key] = [...arraify(existing), ...arraify(value)];
|
3512
|
+
continue;
|
3513
|
+
}
|
3514
|
+
if (isObject$1(existing) && isObject$1(value)) {
|
3515
|
+
merged[key] = mergeConfigRecursively(
|
3516
|
+
existing,
|
3517
|
+
value,
|
3518
|
+
rootPath ? `${rootPath}.${key}` : key
|
3519
|
+
);
|
3520
|
+
continue;
|
3521
|
+
}
|
3522
|
+
merged[key] = value;
|
3523
|
+
}
|
3524
|
+
return merged;
|
3549
3525
|
}
|
3550
3526
|
function mergeConfig(defaults, overrides, isRoot = true) {
|
3551
|
-
|
3552
|
-
|
3553
|
-
|
3554
|
-
|
3527
|
+
if (typeof defaults === "function" || typeof overrides === "function") {
|
3528
|
+
throw new Error(`Cannot merge config in form of callback`);
|
3529
|
+
}
|
3530
|
+
return mergeConfigRecursively(defaults, overrides, isRoot ? "" : ".");
|
3555
3531
|
}
|
3556
3532
|
function mergeAlias(a, b) {
|
3557
|
-
|
3558
|
-
|
3559
|
-
|
3560
|
-
|
3561
|
-
|
3562
|
-
|
3563
|
-
}
|
3564
|
-
// the order is flipped because the alias is resolved from top-down,
|
3565
|
-
// where the later should have higher priority
|
3566
|
-
return [...normalizeAlias(b), ...normalizeAlias(a)];
|
3533
|
+
if (!a) return b;
|
3534
|
+
if (!b) return a;
|
3535
|
+
if (isObject$1(a) && isObject$1(b)) {
|
3536
|
+
return { ...a, ...b };
|
3537
|
+
}
|
3538
|
+
return [...normalizeAlias(b), ...normalizeAlias(a)];
|
3567
3539
|
}
|
3568
3540
|
function normalizeAlias(o = []) {
|
3569
|
-
|
3570
|
-
|
3571
|
-
|
3572
|
-
|
3573
|
-
|
3574
|
-
|
3575
|
-
}
|
3576
|
-
// https://github.com/vitejs/vite/issues/1363
|
3577
|
-
// work around https://github.com/rollup/plugins/issues/759
|
3578
|
-
function normalizeSingleAlias({ find, replacement, customResolver, }) {
|
3579
|
-
if (typeof find === 'string' &&
|
3580
|
-
find[find.length - 1] === '/' &&
|
3581
|
-
replacement[replacement.length - 1] === '/') {
|
3582
|
-
find = find.slice(0, find.length - 1);
|
3583
|
-
replacement = replacement.slice(0, replacement.length - 1);
|
3584
|
-
}
|
3585
|
-
const alias = {
|
3586
|
-
find,
|
3587
|
-
replacement,
|
3588
|
-
};
|
3589
|
-
if (customResolver) {
|
3590
|
-
alias.customResolver = customResolver;
|
3591
|
-
}
|
3592
|
-
return alias;
|
3541
|
+
return Array.isArray(o) ? o.map(normalizeSingleAlias) : Object.keys(o).map(
|
3542
|
+
(find) => normalizeSingleAlias({
|
3543
|
+
find,
|
3544
|
+
replacement: o[find]
|
3545
|
+
})
|
3546
|
+
);
|
3593
3547
|
}
|
3594
|
-
|
3595
|
-
|
3596
|
-
|
3597
|
-
|
3598
|
-
|
3599
|
-
|
3600
|
-
|
3601
|
-
|
3602
|
-
|
3603
|
-
|
3604
|
-
|
3605
|
-
|
3606
|
-
|
3607
|
-
|
3608
|
-
|
3548
|
+
function normalizeSingleAlias({
|
3549
|
+
find,
|
3550
|
+
replacement,
|
3551
|
+
customResolver
|
3552
|
+
}) {
|
3553
|
+
if (typeof find === "string" && find[find.length - 1] === "/" && replacement[replacement.length - 1] === "/") {
|
3554
|
+
find = find.slice(0, find.length - 1);
|
3555
|
+
replacement = replacement.slice(0, replacement.length - 1);
|
3556
|
+
}
|
3557
|
+
const alias = {
|
3558
|
+
find,
|
3559
|
+
replacement
|
3560
|
+
};
|
3561
|
+
if (customResolver) {
|
3562
|
+
alias.customResolver = customResolver;
|
3563
|
+
}
|
3564
|
+
return alias;
|
3609
3565
|
}
|
3610
3566
|
|
3611
|
-
|
3612
|
-
//
|
3613
|
-
|
3614
|
-
|
3615
|
-
/\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
3567
|
+
const CSS_LANGS_RE = (
|
3568
|
+
// eslint-disable-next-line regexp/no-unused-capturing-group
|
3569
|
+
/\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/
|
3570
|
+
);
|
3616
3571
|
const isCSSRequest = (request) => CSS_LANGS_RE.test(request);
|
3617
|
-
// Use splitVendorChunkPlugin() to get the same manualChunks strategy as Vite 2.7
|
3618
|
-
// We don't recommend using this strategy as a general solution moving forward
|
3619
|
-
// splitVendorChunk is a simple index/vendor strategy that was used in Vite
|
3620
|
-
// until v2.8. It is exposed to let people continue to use it in case it was
|
3621
|
-
// working well for their setups.
|
3622
|
-
// The cache needs to be reset on buildStart for watch mode to work correctly
|
3623
|
-
// Don't use this manualChunks strategy for ssr, lib mode, and 'umd' or 'iife'
|
3624
|
-
/**
|
3625
|
-
* @deprecated use build.rollupOptions.output.manualChunks or framework specific configuration
|
3626
|
-
*/
|
3627
3572
|
class SplitVendorChunkCache {
|
3628
|
-
|
3629
|
-
|
3630
|
-
|
3631
|
-
|
3632
|
-
|
3633
|
-
|
3634
|
-
|
3573
|
+
cache;
|
3574
|
+
constructor() {
|
3575
|
+
this.cache = /* @__PURE__ */ new Map();
|
3576
|
+
}
|
3577
|
+
reset() {
|
3578
|
+
this.cache = /* @__PURE__ */ new Map();
|
3579
|
+
}
|
3635
3580
|
}
|
3636
|
-
/**
|
3637
|
-
* @deprecated use build.rollupOptions.output.manualChunks or framework specific configuration
|
3638
|
-
*/
|
3639
3581
|
function splitVendorChunk(options = {}) {
|
3640
|
-
|
3641
|
-
|
3642
|
-
|
3643
|
-
|
3644
|
-
|
3645
|
-
|
3646
|
-
}
|
3647
|
-
};
|
3582
|
+
const cache = options.cache ?? new SplitVendorChunkCache();
|
3583
|
+
return (id, { getModuleInfo }) => {
|
3584
|
+
if (isInNodeModules(id) && !isCSSRequest(id) && staticImportedByEntry(id, getModuleInfo, cache.cache)) {
|
3585
|
+
return "vendor";
|
3586
|
+
}
|
3587
|
+
};
|
3648
3588
|
}
|
3649
3589
|
function staticImportedByEntry(id, getModuleInfo, cache, importStack = []) {
|
3650
|
-
|
3651
|
-
|
3652
|
-
|
3653
|
-
|
3654
|
-
|
3655
|
-
|
3656
|
-
|
3657
|
-
|
3658
|
-
|
3659
|
-
|
3660
|
-
|
3661
|
-
|
3662
|
-
|
3663
|
-
|
3664
|
-
|
3665
|
-
|
3666
|
-
|
3667
|
-
|
3668
|
-
|
3669
|
-
|
3590
|
+
if (cache.has(id)) {
|
3591
|
+
return cache.get(id);
|
3592
|
+
}
|
3593
|
+
if (importStack.includes(id)) {
|
3594
|
+
cache.set(id, false);
|
3595
|
+
return false;
|
3596
|
+
}
|
3597
|
+
const mod = getModuleInfo(id);
|
3598
|
+
if (!mod) {
|
3599
|
+
cache.set(id, false);
|
3600
|
+
return false;
|
3601
|
+
}
|
3602
|
+
if (mod.isEntry) {
|
3603
|
+
cache.set(id, true);
|
3604
|
+
return true;
|
3605
|
+
}
|
3606
|
+
const someImporterIs = mod.importers.some(
|
3607
|
+
(importer) => staticImportedByEntry(
|
3608
|
+
importer,
|
3609
|
+
getModuleInfo,
|
3610
|
+
cache,
|
3611
|
+
importStack.concat(id)
|
3612
|
+
)
|
3613
|
+
);
|
3614
|
+
cache.set(id, someImporterIs);
|
3615
|
+
return someImporterIs;
|
3670
3616
|
}
|
3671
|
-
/**
|
3672
|
-
* @deprecated use build.rollupOptions.output.manualChunks or framework specific configuration
|
3673
|
-
*/
|
3674
3617
|
function splitVendorChunkPlugin() {
|
3675
|
-
|
3676
|
-
|
3677
|
-
|
3678
|
-
|
3679
|
-
|
3680
|
-
|
3681
|
-
|
3682
|
-
|
3683
|
-
}
|
3618
|
+
const caches = [];
|
3619
|
+
function createSplitVendorChunk(output, config) {
|
3620
|
+
const cache = new SplitVendorChunkCache();
|
3621
|
+
caches.push(cache);
|
3622
|
+
const build = config.build ?? {};
|
3623
|
+
const format = output?.format;
|
3624
|
+
if (!build.ssr && !build.lib && format !== "umd" && format !== "iife") {
|
3625
|
+
return splitVendorChunk({ cache });
|
3684
3626
|
}
|
3685
|
-
|
3686
|
-
|
3687
|
-
|
3688
|
-
|
3689
|
-
|
3690
|
-
|
3691
|
-
|
3692
|
-
|
3693
|
-
|
3694
|
-
|
3695
|
-
|
3696
|
-
|
3697
|
-
|
3698
|
-
|
3699
|
-
|
3700
|
-
}
|
3701
|
-
else {
|
3702
|
-
// else, leave the object form of manualChunks untouched, as
|
3703
|
-
// we can't safely replicate rollup handling.
|
3704
|
-
// eslint-disable-next-line no-console
|
3705
|
-
console.warn("(!) the `splitVendorChunk` plugin doesn't have any effect when using the object form of `build.rollupOptions.output.manualChunks`. Consider using the function form instead.");
|
3706
|
-
}
|
3707
|
-
}
|
3708
|
-
else {
|
3709
|
-
output.manualChunks = viteManualChunks;
|
3710
|
-
}
|
3711
|
-
}
|
3712
|
-
}
|
3713
|
-
}
|
3714
|
-
else {
|
3715
|
-
return {
|
3716
|
-
build: {
|
3717
|
-
rollupOptions: {
|
3718
|
-
output: {
|
3719
|
-
manualChunks: createSplitVendorChunk({}, config),
|
3720
|
-
},
|
3721
|
-
},
|
3722
|
-
},
|
3627
|
+
}
|
3628
|
+
return {
|
3629
|
+
name: "vite:split-vendor-chunk",
|
3630
|
+
config(config) {
|
3631
|
+
let outputs = config?.build?.rollupOptions?.output;
|
3632
|
+
if (outputs) {
|
3633
|
+
outputs = arraify(outputs);
|
3634
|
+
for (const output of outputs) {
|
3635
|
+
const viteManualChunks = createSplitVendorChunk(output, config);
|
3636
|
+
if (viteManualChunks) {
|
3637
|
+
if (output.manualChunks) {
|
3638
|
+
if (typeof output.manualChunks === "function") {
|
3639
|
+
const userManualChunks = output.manualChunks;
|
3640
|
+
output.manualChunks = (id, api) => {
|
3641
|
+
return userManualChunks(id, api) ?? viteManualChunks(id, api);
|
3723
3642
|
};
|
3643
|
+
} else {
|
3644
|
+
console.warn(
|
3645
|
+
"(!) the `splitVendorChunk` plugin doesn't have any effect when using the object form of `build.rollupOptions.output.manualChunks`. Consider using the function form instead."
|
3646
|
+
);
|
3647
|
+
}
|
3648
|
+
} else {
|
3649
|
+
output.manualChunks = viteManualChunks;
|
3724
3650
|
}
|
3725
|
-
|
3726
|
-
|
3727
|
-
|
3728
|
-
|
3729
|
-
|
3651
|
+
}
|
3652
|
+
}
|
3653
|
+
} else {
|
3654
|
+
return {
|
3655
|
+
build: {
|
3656
|
+
rollupOptions: {
|
3657
|
+
output: {
|
3658
|
+
manualChunks: createSplitVendorChunk({}, config)
|
3659
|
+
}
|
3660
|
+
}
|
3661
|
+
}
|
3662
|
+
};
|
3663
|
+
}
|
3664
|
+
},
|
3665
|
+
buildStart() {
|
3666
|
+
caches.forEach((cache) => cache.reset());
|
3667
|
+
}
|
3668
|
+
};
|
3730
3669
|
}
|
3731
3670
|
|
3732
3671
|
var convertSourceMap$1 = {};
|
@@ -5346,319 +5285,291 @@ class MagicString {
|
|
5346
5285
|
}
|
5347
5286
|
}
|
5348
5287
|
|
5349
|
-
const debug$1 = createDebugger(
|
5350
|
-
|
5288
|
+
const debug$1 = createDebugger("vite:sourcemap", {
|
5289
|
+
onlyWhenFocused: true
|
5351
5290
|
});
|
5352
5291
|
function genSourceMapUrl(map) {
|
5353
|
-
|
5354
|
-
|
5355
|
-
|
5356
|
-
|
5292
|
+
if (typeof map !== "string") {
|
5293
|
+
map = JSON.stringify(map);
|
5294
|
+
}
|
5295
|
+
return `data:application/json;base64,${Buffer.from(map).toString("base64")}`;
|
5357
5296
|
}
|
5358
5297
|
function getCodeWithSourcemap(type, code, map) {
|
5359
|
-
|
5360
|
-
|
5361
|
-
|
5362
|
-
|
5363
|
-
|
5364
|
-
|
5365
|
-
|
5366
|
-
|
5367
|
-
|
5368
|
-
|
5298
|
+
if (debug$1) {
|
5299
|
+
code += `
|
5300
|
+
/*${JSON.stringify(map, null, 2).replace(/\*\//g, "*\\/")}*/
|
5301
|
+
`;
|
5302
|
+
}
|
5303
|
+
if (type === "js") {
|
5304
|
+
code += `
|
5305
|
+
//# sourceMappingURL=${genSourceMapUrl(map)}`;
|
5306
|
+
} else if (type === "css") {
|
5307
|
+
code += `
|
5308
|
+
/*# sourceMappingURL=${genSourceMapUrl(map)} */`;
|
5309
|
+
}
|
5310
|
+
return code;
|
5369
5311
|
}
|
5370
5312
|
|
5371
|
-
const debug = createDebugger(
|
5372
|
-
|
5313
|
+
const debug = createDebugger("vite:send", {
|
5314
|
+
onlyWhenFocused: true
|
5373
5315
|
});
|
5374
5316
|
const alias = {
|
5375
|
-
|
5376
|
-
|
5377
|
-
|
5378
|
-
|
5317
|
+
js: "text/javascript",
|
5318
|
+
css: "text/css",
|
5319
|
+
html: "text/html",
|
5320
|
+
json: "application/json"
|
5379
5321
|
};
|
5380
5322
|
function send(req, res, content, type, options) {
|
5381
|
-
|
5382
|
-
|
5383
|
-
|
5384
|
-
|
5385
|
-
|
5386
|
-
|
5387
|
-
|
5388
|
-
|
5389
|
-
|
5390
|
-
|
5391
|
-
res.
|
5392
|
-
res.
|
5393
|
-
|
5394
|
-
|
5395
|
-
|
5396
|
-
|
5323
|
+
const {
|
5324
|
+
etag = getEtag(content, { weak: true }),
|
5325
|
+
cacheControl = "no-cache",
|
5326
|
+
headers,
|
5327
|
+
map
|
5328
|
+
} = options;
|
5329
|
+
if (res.writableEnded) {
|
5330
|
+
return;
|
5331
|
+
}
|
5332
|
+
if (req.headers["if-none-match"] === etag) {
|
5333
|
+
res.statusCode = 304;
|
5334
|
+
res.end();
|
5335
|
+
return;
|
5336
|
+
}
|
5337
|
+
res.setHeader("Content-Type", alias[type] || type);
|
5338
|
+
res.setHeader("Cache-Control", cacheControl);
|
5339
|
+
res.setHeader("Etag", etag);
|
5340
|
+
if (headers) {
|
5341
|
+
for (const name in headers) {
|
5342
|
+
res.setHeader(name, headers[name]);
|
5397
5343
|
}
|
5398
|
-
|
5399
|
-
|
5400
|
-
|
5401
|
-
|
5402
|
-
}
|
5344
|
+
}
|
5345
|
+
if (map && "version" in map && map.mappings) {
|
5346
|
+
if (type === "js" || type === "css") {
|
5347
|
+
content = getCodeWithSourcemap(type, content.toString(), map);
|
5403
5348
|
}
|
5404
|
-
|
5405
|
-
|
5406
|
-
|
5407
|
-
|
5408
|
-
|
5409
|
-
|
5410
|
-
|
5411
|
-
|
5412
|
-
|
5413
|
-
|
5414
|
-
|
5415
|
-
|
5416
|
-
|
5417
|
-
|
5418
|
-
|
5419
|
-
|
5420
|
-
}
|
5349
|
+
} else if (type === "js" && (!map || map.mappings !== "")) {
|
5350
|
+
const code = content.toString();
|
5351
|
+
if (convertSourceMap.mapFileCommentRegex.test(code)) {
|
5352
|
+
debug?.(`Skipped injecting fallback sourcemap for ${req.url}`);
|
5353
|
+
} else {
|
5354
|
+
const urlWithoutTimestamp = removeTimestampQuery(req.url);
|
5355
|
+
const ms = new MagicString(code);
|
5356
|
+
content = getCodeWithSourcemap(
|
5357
|
+
type,
|
5358
|
+
code,
|
5359
|
+
ms.generateMap({
|
5360
|
+
source: path$3.basename(urlWithoutTimestamp),
|
5361
|
+
hires: "boundary",
|
5362
|
+
includeContent: true
|
5363
|
+
})
|
5364
|
+
);
|
5421
5365
|
}
|
5422
|
-
|
5423
|
-
|
5424
|
-
|
5366
|
+
}
|
5367
|
+
res.statusCode = 200;
|
5368
|
+
res.end(content);
|
5369
|
+
return;
|
5425
5370
|
}
|
5426
5371
|
|
5427
|
-
/* eslint no-console: 0 */
|
5428
5372
|
const LogLevels = {
|
5429
|
-
|
5430
|
-
|
5431
|
-
|
5432
|
-
|
5373
|
+
silent: 0,
|
5374
|
+
error: 1,
|
5375
|
+
warn: 2,
|
5376
|
+
info: 3
|
5433
5377
|
};
|
5434
5378
|
let lastType;
|
5435
5379
|
let lastMsg;
|
5436
5380
|
let sameCount = 0;
|
5437
5381
|
function clearScreen() {
|
5438
|
-
|
5439
|
-
|
5440
|
-
|
5441
|
-
|
5442
|
-
|
5382
|
+
const repeatCount = process.stdout.rows - 2;
|
5383
|
+
const blank = repeatCount > 0 ? "\n".repeat(repeatCount) : "";
|
5384
|
+
console.log(blank);
|
5385
|
+
readline.cursorTo(process.stdout, 0, 0);
|
5386
|
+
readline.clearScreenDown(process.stdout);
|
5443
5387
|
}
|
5444
|
-
// Only initialize the timeFormatter when the timestamp option is used, and
|
5445
|
-
// reuse it across all loggers
|
5446
5388
|
let timeFormatter;
|
5447
5389
|
function getTimeFormatter() {
|
5448
|
-
|
5449
|
-
|
5450
|
-
|
5451
|
-
|
5452
|
-
|
5453
|
-
|
5390
|
+
timeFormatter ??= new Intl.DateTimeFormat(void 0, {
|
5391
|
+
hour: "numeric",
|
5392
|
+
minute: "numeric",
|
5393
|
+
second: "numeric"
|
5394
|
+
});
|
5395
|
+
return timeFormatter;
|
5454
5396
|
}
|
5455
|
-
|
5456
|
-
|
5457
|
-
|
5458
|
-
|
5459
|
-
|
5460
|
-
|
5461
|
-
|
5462
|
-
|
5463
|
-
|
5464
|
-
|
5465
|
-
|
5466
|
-
|
5467
|
-
|
5468
|
-
|
5469
|
-
|
5470
|
-
|
5471
|
-
|
5397
|
+
function createLogger(level = "info", options = {}) {
|
5398
|
+
if (options.customLogger) {
|
5399
|
+
return options.customLogger;
|
5400
|
+
}
|
5401
|
+
const loggedErrors = /* @__PURE__ */ new WeakSet();
|
5402
|
+
const { prefix = "[vite]", allowClearScreen = true } = options;
|
5403
|
+
const thresh = LogLevels[level];
|
5404
|
+
const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
|
5405
|
+
const clear = canClearScreen ? clearScreen : () => {
|
5406
|
+
};
|
5407
|
+
function format(type, msg, options2 = {}) {
|
5408
|
+
if (options2.timestamp) {
|
5409
|
+
let tag = "";
|
5410
|
+
if (type === "info") {
|
5411
|
+
tag = colors.cyan(colors.bold(prefix));
|
5412
|
+
} else if (type === "warn") {
|
5413
|
+
tag = colors.yellow(colors.bold(prefix));
|
5414
|
+
} else {
|
5415
|
+
tag = colors.red(colors.bold(prefix));
|
5416
|
+
}
|
5417
|
+
const environment = options2.environment ? options2.environment + " " : "";
|
5418
|
+
return `${colors.dim(getTimeFormatter().format(/* @__PURE__ */ new Date()))} ${tag} ${environment}${msg}`;
|
5419
|
+
} else {
|
5420
|
+
return msg;
|
5472
5421
|
}
|
5473
|
-
|
5474
|
-
|
5475
|
-
|
5476
|
-
|
5477
|
-
|
5478
|
-
|
5479
|
-
|
5480
|
-
|
5481
|
-
|
5482
|
-
|
5483
|
-
|
5484
|
-
|
5485
|
-
|
5486
|
-
|
5422
|
+
}
|
5423
|
+
function output(type, msg, options2 = {}) {
|
5424
|
+
if (thresh >= LogLevels[type]) {
|
5425
|
+
const method = type === "info" ? "log" : type;
|
5426
|
+
if (options2.error) {
|
5427
|
+
loggedErrors.add(options2.error);
|
5428
|
+
}
|
5429
|
+
if (canClearScreen) {
|
5430
|
+
if (type === lastType && msg === lastMsg) {
|
5431
|
+
sameCount++;
|
5432
|
+
clear();
|
5433
|
+
console[method](
|
5434
|
+
format(type, msg, options2),
|
5435
|
+
colors.yellow(`(x${sameCount + 1})`)
|
5436
|
+
);
|
5437
|
+
} else {
|
5438
|
+
sameCount = 0;
|
5439
|
+
lastMsg = msg;
|
5440
|
+
lastType = type;
|
5441
|
+
if (options2.clear) {
|
5442
|
+
clear();
|
5443
|
+
}
|
5444
|
+
console[method](format(type, msg, options2));
|
5487
5445
|
}
|
5446
|
+
} else {
|
5447
|
+
console[method](format(type, msg, options2));
|
5448
|
+
}
|
5488
5449
|
}
|
5489
|
-
|
5490
|
-
|
5491
|
-
|
5492
|
-
|
5493
|
-
|
5494
|
-
|
5495
|
-
|
5496
|
-
|
5497
|
-
|
5498
|
-
|
5499
|
-
|
5500
|
-
|
5501
|
-
|
5502
|
-
|
5503
|
-
|
5504
|
-
|
5505
|
-
|
5506
|
-
|
5507
|
-
|
5508
|
-
|
5509
|
-
|
5510
|
-
|
5511
|
-
|
5512
|
-
|
5513
|
-
|
5514
|
-
|
5450
|
+
}
|
5451
|
+
const warnedMessages = /* @__PURE__ */ new Set();
|
5452
|
+
const logger = {
|
5453
|
+
hasWarned: false,
|
5454
|
+
info(msg, opts) {
|
5455
|
+
output("info", msg, opts);
|
5456
|
+
},
|
5457
|
+
warn(msg, opts) {
|
5458
|
+
logger.hasWarned = true;
|
5459
|
+
output("warn", msg, opts);
|
5460
|
+
},
|
5461
|
+
warnOnce(msg, opts) {
|
5462
|
+
if (warnedMessages.has(msg)) return;
|
5463
|
+
logger.hasWarned = true;
|
5464
|
+
output("warn", msg, opts);
|
5465
|
+
warnedMessages.add(msg);
|
5466
|
+
},
|
5467
|
+
error(msg, opts) {
|
5468
|
+
logger.hasWarned = true;
|
5469
|
+
output("error", msg, opts);
|
5470
|
+
},
|
5471
|
+
clearScreen(type) {
|
5472
|
+
if (thresh >= LogLevels[type]) {
|
5473
|
+
clear();
|
5474
|
+
}
|
5475
|
+
},
|
5476
|
+
hasErrorLogged(error) {
|
5477
|
+
return loggedErrors.has(error);
|
5515
5478
|
}
|
5516
|
-
|
5517
|
-
|
5518
|
-
hasWarned: false,
|
5519
|
-
info(msg, opts) {
|
5520
|
-
output('info', msg, opts);
|
5521
|
-
},
|
5522
|
-
warn(msg, opts) {
|
5523
|
-
logger.hasWarned = true;
|
5524
|
-
output('warn', msg, opts);
|
5525
|
-
},
|
5526
|
-
warnOnce(msg, opts) {
|
5527
|
-
if (warnedMessages.has(msg))
|
5528
|
-
return;
|
5529
|
-
logger.hasWarned = true;
|
5530
|
-
output('warn', msg, opts);
|
5531
|
-
warnedMessages.add(msg);
|
5532
|
-
},
|
5533
|
-
error(msg, opts) {
|
5534
|
-
logger.hasWarned = true;
|
5535
|
-
output('error', msg, opts);
|
5536
|
-
},
|
5537
|
-
clearScreen(type) {
|
5538
|
-
if (thresh >= LogLevels[type]) {
|
5539
|
-
clear();
|
5540
|
-
}
|
5541
|
-
},
|
5542
|
-
hasErrorLogged(error) {
|
5543
|
-
return loggedErrors.has(error);
|
5544
|
-
},
|
5545
|
-
};
|
5546
|
-
return logger;
|
5479
|
+
};
|
5480
|
+
return logger;
|
5547
5481
|
}
|
5548
5482
|
|
5549
|
-
// https://github.com/vitejs/vite/issues/2820#issuecomment-812495079
|
5550
5483
|
const ROOT_FILES = [
|
5551
|
-
|
5552
|
-
|
5553
|
-
|
5554
|
-
|
5555
|
-
|
5556
|
-
|
5557
|
-
|
5558
|
-
|
5559
|
-
|
5560
|
-
|
5484
|
+
// '.git',
|
5485
|
+
// https://pnpm.io/workspaces/
|
5486
|
+
"pnpm-workspace.yaml",
|
5487
|
+
// https://rushjs.io/pages/advanced/config_files/
|
5488
|
+
// 'rush.json',
|
5489
|
+
// https://nx.dev/latest/react/getting-started/nx-setup
|
5490
|
+
// 'workspace.json',
|
5491
|
+
// 'nx.json',
|
5492
|
+
// https://github.com/lerna/lerna#lernajson
|
5493
|
+
"lerna.json"
|
5561
5494
|
];
|
5562
|
-
// npm: https://docs.npmjs.com/cli/v7/using-npm/workspaces#installing-workspaces
|
5563
|
-
// yarn: https://classic.yarnpkg.com/en/docs/workspaces/#toc-how-to-use-it
|
5564
5495
|
function hasWorkspacePackageJSON(root) {
|
5565
|
-
|
5566
|
-
|
5567
|
-
|
5568
|
-
|
5569
|
-
|
5570
|
-
|
5571
|
-
|
5572
|
-
|
5573
|
-
|
5574
|
-
|
5575
|
-
}
|
5496
|
+
const path = path$3.join(root, "package.json");
|
5497
|
+
if (!isFileReadable(path)) {
|
5498
|
+
return false;
|
5499
|
+
}
|
5500
|
+
try {
|
5501
|
+
const content = JSON.parse(fs$1.readFileSync(path, "utf-8")) || {};
|
5502
|
+
return !!content.workspaces;
|
5503
|
+
} catch {
|
5504
|
+
return false;
|
5505
|
+
}
|
5576
5506
|
}
|
5577
5507
|
function hasRootFile(root) {
|
5578
|
-
|
5508
|
+
return ROOT_FILES.some((file) => fs$1.existsSync(path$3.join(root, file)));
|
5579
5509
|
}
|
5580
5510
|
function hasPackageJSON(root) {
|
5581
|
-
|
5582
|
-
|
5511
|
+
const path = path$3.join(root, "package.json");
|
5512
|
+
return fs$1.existsSync(path);
|
5583
5513
|
}
|
5584
|
-
/**
|
5585
|
-
* Search up for the nearest `package.json`
|
5586
|
-
*/
|
5587
5514
|
function searchForPackageRoot(current, root = current) {
|
5588
|
-
|
5589
|
-
|
5590
|
-
|
5591
|
-
|
5592
|
-
if (!dir || dir === current)
|
5593
|
-
return root;
|
5594
|
-
return searchForPackageRoot(dir, root);
|
5515
|
+
if (hasPackageJSON(current)) return current;
|
5516
|
+
const dir = path$3.dirname(current);
|
5517
|
+
if (!dir || dir === current) return root;
|
5518
|
+
return searchForPackageRoot(dir, root);
|
5595
5519
|
}
|
5596
|
-
/**
|
5597
|
-
* Search up for the nearest workspace root
|
5598
|
-
*/
|
5599
5520
|
function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
|
5600
|
-
|
5601
|
-
|
5602
|
-
|
5603
|
-
|
5604
|
-
|
5605
|
-
// reach the fs root
|
5606
|
-
if (!dir || dir === current)
|
5607
|
-
return root;
|
5608
|
-
return searchForWorkspaceRoot(dir, root);
|
5521
|
+
if (hasRootFile(current)) return current;
|
5522
|
+
if (hasWorkspacePackageJSON(current)) return current;
|
5523
|
+
const dir = path$3.dirname(current);
|
5524
|
+
if (!dir || dir === current) return root;
|
5525
|
+
return searchForWorkspaceRoot(dir, root);
|
5609
5526
|
}
|
5610
5527
|
|
5611
|
-
const safeModulePathsCache = new WeakMap();
|
5528
|
+
const safeModulePathsCache = /* @__PURE__ */ new WeakMap();
|
5612
5529
|
function isSafeModulePath(config, filePath) {
|
5613
|
-
|
5614
|
-
|
5615
|
-
|
5616
|
-
|
5617
|
-
|
5618
|
-
|
5530
|
+
let safeModulePaths = safeModulePathsCache.get(config);
|
5531
|
+
if (!safeModulePaths) {
|
5532
|
+
safeModulePaths = /* @__PURE__ */ new Set();
|
5533
|
+
safeModulePathsCache.set(config, safeModulePaths);
|
5534
|
+
}
|
5535
|
+
return safeModulePaths.has(filePath);
|
5619
5536
|
}
|
5620
|
-
const fsDenyGlobCache = new WeakMap();
|
5537
|
+
const fsDenyGlobCache = /* @__PURE__ */ new WeakMap();
|
5621
5538
|
function fsDenyGlob(config, filePath) {
|
5622
|
-
|
5623
|
-
|
5624
|
-
|
5625
|
-
|
5626
|
-
|
5627
|
-
|
5628
|
-
|
5629
|
-
|
5630
|
-
|
5631
|
-
|
5632
|
-
|
5633
|
-
|
5634
|
-
|
5635
|
-
|
5539
|
+
let matcher = fsDenyGlobCache.get(config);
|
5540
|
+
if (!matcher) {
|
5541
|
+
matcher = picomatch$1(
|
5542
|
+
// matchBase: true does not work as it's documented
|
5543
|
+
// https://github.com/micromatch/picomatch/issues/89
|
5544
|
+
// convert patterns without `/` on our side for now
|
5545
|
+
config.server.fs.deny.map(
|
5546
|
+
(pattern) => pattern.includes("/") ? pattern : `**/${pattern}`
|
5547
|
+
),
|
5548
|
+
{
|
5549
|
+
matchBase: false,
|
5550
|
+
nocase: true,
|
5551
|
+
dot: true
|
5552
|
+
}
|
5553
|
+
), fsDenyGlobCache.set(config, matcher);
|
5554
|
+
}
|
5555
|
+
return matcher(filePath);
|
5636
5556
|
}
|
5637
|
-
/**
|
5638
|
-
* Check if the url is allowed to be served, via the `server.fs` config.
|
5639
|
-
* @deprecated use isFileLoadingAllowed
|
5640
|
-
*/
|
5641
5557
|
function isFileServingAllowed(url, server) {
|
5642
|
-
|
5643
|
-
|
5644
|
-
|
5645
|
-
|
5646
|
-
return isFileLoadingAllowed(config, filePath);
|
5558
|
+
const { config } = server;
|
5559
|
+
if (!config.server.fs.strict) return true;
|
5560
|
+
const filePath = fsPathFromUrl(url);
|
5561
|
+
return isFileLoadingAllowed(config, filePath);
|
5647
5562
|
}
|
5648
5563
|
function isUriInFilePath(uri, filePath) {
|
5649
|
-
|
5564
|
+
return isSameFileUri(uri, filePath) || isParentDirectory(uri, filePath);
|
5650
5565
|
}
|
5651
5566
|
function isFileLoadingAllowed(config, filePath) {
|
5652
|
-
|
5653
|
-
|
5654
|
-
|
5655
|
-
|
5656
|
-
|
5657
|
-
|
5658
|
-
return true;
|
5659
|
-
if (fs.allow.some((uri) => isUriInFilePath(uri, filePath)))
|
5660
|
-
return true;
|
5661
|
-
return false;
|
5567
|
+
const { fs } = config.server;
|
5568
|
+
if (!fs.strict) return true;
|
5569
|
+
if (fsDenyGlob(config, filePath)) return false;
|
5570
|
+
if (isSafeModulePath(config, filePath)) return true;
|
5571
|
+
if (fs.allow.some((uri) => isUriInFilePath(uri, filePath))) return true;
|
5572
|
+
return false;
|
5662
5573
|
}
|
5663
5574
|
|
5664
5575
|
var main$1 = {exports: {}};
|
@@ -6194,68 +6105,70 @@ function expand (options) {
|
|
6194
6105
|
var expand_1 = expand;
|
6195
6106
|
|
6196
6107
|
function getEnvFilesForMode(mode, envDir) {
|
6197
|
-
|
6198
|
-
|
6199
|
-
|
6200
|
-
|
6201
|
-
|
6202
|
-
|
6108
|
+
return [
|
6109
|
+
/** default file */
|
6110
|
+
`.env`,
|
6111
|
+
/** local file */
|
6112
|
+
`.env.local`,
|
6113
|
+
/** mode file */
|
6114
|
+
`.env.${mode}`,
|
6115
|
+
/** mode local file */
|
6116
|
+
`.env.${mode}.local`
|
6117
|
+
].map((file) => normalizePath(path$3.join(envDir, file)));
|
6203
6118
|
}
|
6204
|
-
function loadEnv(mode, envDir, prefixes =
|
6205
|
-
|
6206
|
-
|
6207
|
-
|
6208
|
-
|
6209
|
-
|
6210
|
-
|
6211
|
-
|
6212
|
-
|
6213
|
-
|
6214
|
-
|
6215
|
-
|
6216
|
-
|
6217
|
-
|
6218
|
-
|
6219
|
-
|
6220
|
-
|
6221
|
-
|
6222
|
-
|
6223
|
-
|
6224
|
-
|
6225
|
-
|
6226
|
-
|
6227
|
-
|
6228
|
-
|
6229
|
-
|
6230
|
-
|
6231
|
-
|
6232
|
-
|
6233
|
-
for (const [key, value] of Object.entries(parsed)) {
|
6234
|
-
if (prefixes.some((prefix) => key.startsWith(prefix))) {
|
6235
|
-
env[key] = value;
|
6236
|
-
}
|
6119
|
+
function loadEnv(mode, envDir, prefixes = "VITE_") {
|
6120
|
+
if (mode === "local") {
|
6121
|
+
throw new Error(
|
6122
|
+
`"local" cannot be used as a mode name because it conflicts with the .local postfix for .env files.`
|
6123
|
+
);
|
6124
|
+
}
|
6125
|
+
prefixes = arraify(prefixes);
|
6126
|
+
const env = {};
|
6127
|
+
const envFiles = getEnvFilesForMode(mode, envDir);
|
6128
|
+
const parsed = Object.fromEntries(
|
6129
|
+
envFiles.flatMap((filePath) => {
|
6130
|
+
if (!tryStatSync(filePath)?.isFile()) return [];
|
6131
|
+
return Object.entries(parse_1(fs$1.readFileSync(filePath)));
|
6132
|
+
})
|
6133
|
+
);
|
6134
|
+
if (parsed.NODE_ENV && process.env.VITE_USER_NODE_ENV === void 0) {
|
6135
|
+
process.env.VITE_USER_NODE_ENV = parsed.NODE_ENV;
|
6136
|
+
}
|
6137
|
+
if (parsed.BROWSER && process.env.BROWSER === void 0) {
|
6138
|
+
process.env.BROWSER = parsed.BROWSER;
|
6139
|
+
}
|
6140
|
+
if (parsed.BROWSER_ARGS && process.env.BROWSER_ARGS === void 0) {
|
6141
|
+
process.env.BROWSER_ARGS = parsed.BROWSER_ARGS;
|
6142
|
+
}
|
6143
|
+
const processEnv = { ...process.env };
|
6144
|
+
expand_1({ parsed, processEnv });
|
6145
|
+
for (const [key, value] of Object.entries(parsed)) {
|
6146
|
+
if (prefixes.some((prefix) => key.startsWith(prefix))) {
|
6147
|
+
env[key] = value;
|
6237
6148
|
}
|
6238
|
-
|
6239
|
-
|
6240
|
-
|
6241
|
-
|
6242
|
-
env[key] = process.env[key];
|
6243
|
-
}
|
6149
|
+
}
|
6150
|
+
for (const key in process.env) {
|
6151
|
+
if (prefixes.some((prefix) => key.startsWith(prefix))) {
|
6152
|
+
env[key] = process.env[key];
|
6244
6153
|
}
|
6245
|
-
|
6154
|
+
}
|
6155
|
+
return env;
|
6246
6156
|
}
|
6247
|
-
function resolveEnvPrefix({
|
6248
|
-
|
6249
|
-
|
6250
|
-
|
6251
|
-
|
6252
|
-
|
6157
|
+
function resolveEnvPrefix({
|
6158
|
+
envPrefix = "VITE_"
|
6159
|
+
}) {
|
6160
|
+
envPrefix = arraify(envPrefix);
|
6161
|
+
if (envPrefix.includes("")) {
|
6162
|
+
throw new Error(
|
6163
|
+
`envPrefix option contains value '', which could lead unexpected exposure of sensitive information.`
|
6164
|
+
);
|
6165
|
+
}
|
6166
|
+
return envPrefix;
|
6253
6167
|
}
|
6254
6168
|
|
6255
6169
|
exports.esbuildVersion = esbuild.version;
|
6256
6170
|
exports.createFilter = createFilter;
|
6257
6171
|
exports.createLogger = createLogger;
|
6258
|
-
exports.createWeakData = createWeakData;
|
6259
6172
|
exports.isCSSRequest = isCSSRequest;
|
6260
6173
|
exports.isFileLoadingAllowed = isFileLoadingAllowed;
|
6261
6174
|
exports.isFileServingAllowed = isFileServingAllowed;
|