vite 5.3.0-beta.0 → 5.3.0-beta.2
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 +111 -144
- package/dist/client/client.mjs +608 -606
- package/dist/client/env.mjs +18 -24
- package/dist/node/chunks/{dep-CTAUzmEN.js → dep-CkqaOKeN.js} +1 -1
- package/dist/node/chunks/{dep-BBErwUJM.js → dep-DxsHXWQ1.js} +23862 -20690
- package/dist/node/chunks/{dep-BPjeYeh_.js → dep-E0jGEM7W.js} +1 -1
- package/dist/node/cli.js +235 -244
- package/dist/node/constants.js +79 -83
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +186 -198
- package/dist/node/runtime.js +139 -99
- package/dist/node-cjs/publicUtils.cjs +514 -575
- package/package.json +11 -12
- 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,364 +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
3457
|
const splitRE = /\r?\n/g;
|
3478
3458
|
function isFileReadable(filename) {
|
3479
|
-
|
3480
|
-
|
3481
|
-
|
3482
|
-
|
3483
|
-
|
3484
|
-
|
3485
|
-
|
3486
|
-
|
3487
|
-
|
3488
|
-
return false;
|
3489
|
-
}
|
3459
|
+
if (!tryStatSync(filename)) {
|
3460
|
+
return false;
|
3461
|
+
}
|
3462
|
+
try {
|
3463
|
+
fs$1.accessSync(filename, fs$1.constants.R_OK);
|
3464
|
+
return true;
|
3465
|
+
} catch {
|
3466
|
+
return false;
|
3467
|
+
}
|
3490
3468
|
}
|
3491
3469
|
function arraify(target) {
|
3492
|
-
|
3470
|
+
return Array.isArray(target) ? target : [target];
|
3493
3471
|
}
|
3494
3472
|
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
3473
|
function backwardCompatibleWorkerPlugins(plugins) {
|
3496
|
-
|
3497
|
-
|
3498
|
-
|
3499
|
-
|
3500
|
-
|
3501
|
-
|
3502
|
-
|
3474
|
+
if (Array.isArray(plugins)) {
|
3475
|
+
return plugins;
|
3476
|
+
}
|
3477
|
+
if (typeof plugins === "function") {
|
3478
|
+
return plugins();
|
3479
|
+
}
|
3480
|
+
return [];
|
3503
3481
|
}
|
3504
3482
|
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' &&
|
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;
|
3483
|
+
const merged = { ...defaults };
|
3484
|
+
for (const key in overrides) {
|
3485
|
+
const value = overrides[key];
|
3486
|
+
if (value == null) {
|
3487
|
+
continue;
|
3488
|
+
}
|
3489
|
+
const existing = merged[key];
|
3490
|
+
if (existing == null) {
|
3491
|
+
merged[key] = value;
|
3492
|
+
continue;
|
3547
3493
|
}
|
3548
|
-
|
3494
|
+
if (key === "alias" && (rootPath === "resolve" || rootPath === "")) {
|
3495
|
+
merged[key] = mergeAlias(existing, value);
|
3496
|
+
continue;
|
3497
|
+
} else if (key === "assetsInclude" && rootPath === "") {
|
3498
|
+
merged[key] = [].concat(existing, value);
|
3499
|
+
continue;
|
3500
|
+
} else if (key === "noExternal" && 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
|
-
|
3541
|
+
return Array.isArray(o) ? o.map(normalizeSingleAlias) : Object.keys(o).map(
|
3542
|
+
(find) => normalizeSingleAlias({
|
3543
|
+
find,
|
3544
|
+
replacement: o[find]
|
3545
|
+
})
|
3546
|
+
);
|
3575
3547
|
}
|
3576
|
-
|
3577
|
-
|
3578
|
-
|
3579
|
-
|
3580
|
-
|
3581
|
-
|
3582
|
-
|
3583
|
-
|
3584
|
-
|
3585
|
-
|
3586
|
-
|
3587
|
-
|
3588
|
-
|
3589
|
-
|
3590
|
-
|
3591
|
-
|
3592
|
-
|
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;
|
3593
3565
|
}
|
3594
3566
|
|
3595
|
-
|
3596
|
-
//
|
3597
|
-
|
3598
|
-
|
3599
|
-
/\.(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
|
+
);
|
3600
3571
|
const isCSSRequest = (request) => CSS_LANGS_RE.test(request);
|
3601
|
-
// Use splitVendorChunkPlugin() to get the same manualChunks strategy as Vite 2.7
|
3602
|
-
// We don't recommend using this strategy as a general solution moving forward
|
3603
|
-
// splitVendorChunk is a simple index/vendor strategy that was used in Vite
|
3604
|
-
// until v2.8. It is exposed to let people continue to use it in case it was
|
3605
|
-
// working well for their setups.
|
3606
|
-
// The cache needs to be reset on buildStart for watch mode to work correctly
|
3607
|
-
// Don't use this manualChunks strategy for ssr, lib mode, and 'umd' or 'iife'
|
3608
|
-
/**
|
3609
|
-
* @deprecated use build.rollupOptions.output.manualChunks or framework specific configuration
|
3610
|
-
*/
|
3611
3572
|
class SplitVendorChunkCache {
|
3612
|
-
|
3613
|
-
|
3614
|
-
|
3615
|
-
|
3616
|
-
|
3617
|
-
|
3618
|
-
|
3573
|
+
cache;
|
3574
|
+
constructor() {
|
3575
|
+
this.cache = /* @__PURE__ */ new Map();
|
3576
|
+
}
|
3577
|
+
reset() {
|
3578
|
+
this.cache = /* @__PURE__ */ new Map();
|
3579
|
+
}
|
3619
3580
|
}
|
3620
|
-
/**
|
3621
|
-
* @deprecated use build.rollupOptions.output.manualChunks or framework specific configuration
|
3622
|
-
*/
|
3623
3581
|
function splitVendorChunk(options = {}) {
|
3624
|
-
|
3625
|
-
|
3626
|
-
|
3627
|
-
|
3628
|
-
|
3629
|
-
|
3630
|
-
}
|
3631
|
-
};
|
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
|
+
};
|
3632
3588
|
}
|
3633
3589
|
function staticImportedByEntry(id, getModuleInfo, cache, importStack = []) {
|
3634
|
-
|
3635
|
-
|
3636
|
-
|
3637
|
-
|
3638
|
-
|
3639
|
-
|
3640
|
-
|
3641
|
-
|
3642
|
-
|
3643
|
-
|
3644
|
-
|
3645
|
-
|
3646
|
-
|
3647
|
-
|
3648
|
-
|
3649
|
-
|
3650
|
-
|
3651
|
-
|
3652
|
-
|
3653
|
-
|
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;
|
3654
3616
|
}
|
3655
|
-
/**
|
3656
|
-
* @deprecated use build.rollupOptions.output.manualChunks or framework specific configuration
|
3657
|
-
*/
|
3658
3617
|
function splitVendorChunkPlugin() {
|
3659
|
-
|
3660
|
-
|
3661
|
-
|
3662
|
-
|
3663
|
-
|
3664
|
-
|
3665
|
-
|
3666
|
-
|
3667
|
-
}
|
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 });
|
3668
3626
|
}
|
3669
|
-
|
3670
|
-
|
3671
|
-
|
3672
|
-
|
3673
|
-
|
3674
|
-
|
3675
|
-
|
3676
|
-
|
3677
|
-
|
3678
|
-
|
3679
|
-
|
3680
|
-
|
3681
|
-
|
3682
|
-
|
3683
|
-
|
3684
|
-
}
|
3685
|
-
else {
|
3686
|
-
// else, leave the object form of manualChunks untouched, as
|
3687
|
-
// we can't safely replicate rollup handling.
|
3688
|
-
// eslint-disable-next-line no-console
|
3689
|
-
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.");
|
3690
|
-
}
|
3691
|
-
}
|
3692
|
-
else {
|
3693
|
-
output.manualChunks = viteManualChunks;
|
3694
|
-
}
|
3695
|
-
}
|
3696
|
-
}
|
3697
|
-
}
|
3698
|
-
else {
|
3699
|
-
return {
|
3700
|
-
build: {
|
3701
|
-
rollupOptions: {
|
3702
|
-
output: {
|
3703
|
-
manualChunks: createSplitVendorChunk({}, config),
|
3704
|
-
},
|
3705
|
-
},
|
3706
|
-
},
|
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);
|
3707
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;
|
3708
3650
|
}
|
3709
|
-
|
3710
|
-
|
3711
|
-
|
3712
|
-
|
3713
|
-
|
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
|
+
};
|
3714
3669
|
}
|
3715
3670
|
|
3716
3671
|
var convertSourceMap$1 = {};
|
@@ -5330,280 +5285,261 @@ class MagicString {
|
|
5330
5285
|
}
|
5331
5286
|
}
|
5332
5287
|
|
5333
|
-
const debug$1 = createDebugger(
|
5334
|
-
|
5288
|
+
const debug$1 = createDebugger("vite:sourcemap", {
|
5289
|
+
onlyWhenFocused: true
|
5335
5290
|
});
|
5336
5291
|
function genSourceMapUrl(map) {
|
5337
|
-
|
5338
|
-
|
5339
|
-
|
5340
|
-
|
5292
|
+
if (typeof map !== "string") {
|
5293
|
+
map = JSON.stringify(map);
|
5294
|
+
}
|
5295
|
+
return `data:application/json;base64,${Buffer.from(map).toString("base64")}`;
|
5341
5296
|
}
|
5342
5297
|
function getCodeWithSourcemap(type, code, map) {
|
5343
|
-
|
5344
|
-
|
5345
|
-
|
5346
|
-
|
5347
|
-
|
5348
|
-
|
5349
|
-
|
5350
|
-
|
5351
|
-
|
5352
|
-
|
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;
|
5353
5311
|
}
|
5354
5312
|
|
5355
|
-
const debug = createDebugger(
|
5356
|
-
|
5313
|
+
const debug = createDebugger("vite:send", {
|
5314
|
+
onlyWhenFocused: true
|
5357
5315
|
});
|
5358
5316
|
const alias = {
|
5359
|
-
|
5360
|
-
|
5361
|
-
|
5362
|
-
|
5317
|
+
js: "text/javascript",
|
5318
|
+
css: "text/css",
|
5319
|
+
html: "text/html",
|
5320
|
+
json: "application/json"
|
5363
5321
|
};
|
5364
5322
|
function send(req, res, content, type, options) {
|
5365
|
-
|
5366
|
-
|
5367
|
-
|
5368
|
-
|
5369
|
-
|
5370
|
-
|
5371
|
-
|
5372
|
-
|
5373
|
-
|
5374
|
-
|
5375
|
-
res.
|
5376
|
-
res.
|
5377
|
-
|
5378
|
-
|
5379
|
-
|
5380
|
-
|
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]);
|
5381
5343
|
}
|
5382
|
-
|
5383
|
-
|
5384
|
-
|
5385
|
-
|
5386
|
-
}
|
5344
|
+
}
|
5345
|
+
if (map && "version" in map && map.mappings) {
|
5346
|
+
if (type === "js" || type === "css") {
|
5347
|
+
content = getCodeWithSourcemap(type, content.toString(), map);
|
5387
5348
|
}
|
5388
|
-
|
5389
|
-
|
5390
|
-
|
5391
|
-
|
5392
|
-
|
5393
|
-
|
5394
|
-
|
5395
|
-
|
5396
|
-
|
5397
|
-
|
5398
|
-
|
5399
|
-
|
5400
|
-
|
5401
|
-
|
5402
|
-
|
5403
|
-
|
5404
|
-
}
|
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
|
+
);
|
5405
5365
|
}
|
5406
|
-
|
5407
|
-
|
5408
|
-
|
5366
|
+
}
|
5367
|
+
res.statusCode = 200;
|
5368
|
+
res.end(content);
|
5369
|
+
return;
|
5409
5370
|
}
|
5410
5371
|
|
5411
|
-
/* eslint no-console: 0 */
|
5412
5372
|
const LogLevels = {
|
5413
|
-
|
5414
|
-
|
5415
|
-
|
5416
|
-
|
5373
|
+
silent: 0,
|
5374
|
+
error: 1,
|
5375
|
+
warn: 2,
|
5376
|
+
info: 3
|
5417
5377
|
};
|
5418
5378
|
let lastType;
|
5419
5379
|
let lastMsg;
|
5420
5380
|
let sameCount = 0;
|
5421
5381
|
function clearScreen() {
|
5422
|
-
|
5423
|
-
|
5424
|
-
|
5425
|
-
|
5426
|
-
|
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);
|
5427
5387
|
}
|
5428
|
-
// Only initialize the timeFormatter when the timestamp option is used, and
|
5429
|
-
// reuse it across all loggers
|
5430
5388
|
let timeFormatter;
|
5431
5389
|
function getTimeFormatter() {
|
5432
|
-
|
5433
|
-
|
5434
|
-
|
5435
|
-
|
5436
|
-
|
5437
|
-
|
5390
|
+
timeFormatter ??= new Intl.DateTimeFormat(void 0, {
|
5391
|
+
hour: "numeric",
|
5392
|
+
minute: "numeric",
|
5393
|
+
second: "numeric"
|
5394
|
+
});
|
5395
|
+
return timeFormatter;
|
5438
5396
|
}
|
5439
|
-
const MAX_LOG_CHAR =
|
5440
|
-
function createLogger(level =
|
5441
|
-
|
5442
|
-
|
5397
|
+
const MAX_LOG_CHAR = 5e3;
|
5398
|
+
function createLogger(level = "info", options = {}) {
|
5399
|
+
if (options.customLogger) {
|
5400
|
+
return options.customLogger;
|
5401
|
+
}
|
5402
|
+
const loggedErrors = /* @__PURE__ */ new WeakSet();
|
5403
|
+
const { prefix = "[vite]", allowClearScreen = true } = options;
|
5404
|
+
const thresh = LogLevels[level];
|
5405
|
+
const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
|
5406
|
+
const clear = canClearScreen ? clearScreen : () => {
|
5407
|
+
};
|
5408
|
+
function preventOverflow(msg) {
|
5409
|
+
if (msg.length > MAX_LOG_CHAR) {
|
5410
|
+
const shorten = msg.slice(0, MAX_LOG_CHAR);
|
5411
|
+
const lines = msg.slice(MAX_LOG_CHAR).match(splitRE)?.length || 0;
|
5412
|
+
return `${shorten}
|
5413
|
+
... and ${lines} lines more`;
|
5443
5414
|
}
|
5444
|
-
|
5445
|
-
|
5446
|
-
|
5447
|
-
const
|
5448
|
-
|
5449
|
-
|
5450
|
-
|
5451
|
-
|
5452
|
-
|
5453
|
-
|
5454
|
-
|
5455
|
-
return msg;
|
5415
|
+
return msg;
|
5416
|
+
}
|
5417
|
+
function format(type, rawMsg, options2 = {}) {
|
5418
|
+
const msg = preventOverflow(rawMsg);
|
5419
|
+
if (options2.timestamp) {
|
5420
|
+
const tag = type === "info" ? colors.cyan(colors.bold(prefix)) : type === "warn" ? colors.yellow(colors.bold(prefix)) : colors.red(colors.bold(prefix));
|
5421
|
+
return `${colors.dim(
|
5422
|
+
getTimeFormatter().format(/* @__PURE__ */ new Date())
|
5423
|
+
)} ${tag} ${msg}`;
|
5424
|
+
} else {
|
5425
|
+
return msg;
|
5456
5426
|
}
|
5457
|
-
|
5458
|
-
|
5459
|
-
|
5460
|
-
|
5461
|
-
|
5462
|
-
|
5463
|
-
|
5464
|
-
|
5465
|
-
|
5466
|
-
|
5467
|
-
|
5468
|
-
|
5427
|
+
}
|
5428
|
+
function output(type, msg, options2 = {}) {
|
5429
|
+
if (thresh >= LogLevels[type]) {
|
5430
|
+
const method = type === "info" ? "log" : type;
|
5431
|
+
if (options2.error) {
|
5432
|
+
loggedErrors.add(options2.error);
|
5433
|
+
}
|
5434
|
+
if (canClearScreen) {
|
5435
|
+
if (type === lastType && msg === lastMsg) {
|
5436
|
+
sameCount++;
|
5437
|
+
clear();
|
5438
|
+
console[method](
|
5439
|
+
format(type, msg, options2),
|
5440
|
+
colors.yellow(`(x${sameCount + 1})`)
|
5441
|
+
);
|
5442
|
+
} else {
|
5443
|
+
sameCount = 0;
|
5444
|
+
lastMsg = msg;
|
5445
|
+
lastType = type;
|
5446
|
+
if (options2.clear) {
|
5447
|
+
clear();
|
5448
|
+
}
|
5449
|
+
console[method](format(type, msg, options2));
|
5469
5450
|
}
|
5451
|
+
} else {
|
5452
|
+
console[method](format(type, msg, options2));
|
5453
|
+
}
|
5470
5454
|
}
|
5471
|
-
|
5472
|
-
|
5473
|
-
|
5474
|
-
|
5475
|
-
|
5476
|
-
|
5477
|
-
|
5478
|
-
|
5479
|
-
|
5480
|
-
|
5481
|
-
|
5482
|
-
|
5483
|
-
|
5484
|
-
|
5485
|
-
|
5486
|
-
|
5487
|
-
|
5488
|
-
|
5489
|
-
|
5490
|
-
|
5491
|
-
|
5492
|
-
|
5493
|
-
|
5494
|
-
|
5495
|
-
|
5496
|
-
|
5455
|
+
}
|
5456
|
+
const warnedMessages = /* @__PURE__ */ new Set();
|
5457
|
+
const logger = {
|
5458
|
+
hasWarned: false,
|
5459
|
+
info(msg, opts) {
|
5460
|
+
output("info", msg, opts);
|
5461
|
+
},
|
5462
|
+
warn(msg, opts) {
|
5463
|
+
logger.hasWarned = true;
|
5464
|
+
output("warn", msg, opts);
|
5465
|
+
},
|
5466
|
+
warnOnce(msg, opts) {
|
5467
|
+
if (warnedMessages.has(msg)) return;
|
5468
|
+
logger.hasWarned = true;
|
5469
|
+
output("warn", msg, opts);
|
5470
|
+
warnedMessages.add(msg);
|
5471
|
+
},
|
5472
|
+
error(msg, opts) {
|
5473
|
+
logger.hasWarned = true;
|
5474
|
+
output("error", msg, opts);
|
5475
|
+
},
|
5476
|
+
clearScreen(type) {
|
5477
|
+
if (thresh >= LogLevels[type]) {
|
5478
|
+
clear();
|
5479
|
+
}
|
5480
|
+
},
|
5481
|
+
hasErrorLogged(error) {
|
5482
|
+
return loggedErrors.has(error);
|
5497
5483
|
}
|
5498
|
-
|
5499
|
-
|
5500
|
-
hasWarned: false,
|
5501
|
-
info(msg, opts) {
|
5502
|
-
output('info', msg, opts);
|
5503
|
-
},
|
5504
|
-
warn(msg, opts) {
|
5505
|
-
logger.hasWarned = true;
|
5506
|
-
output('warn', msg, opts);
|
5507
|
-
},
|
5508
|
-
warnOnce(msg, opts) {
|
5509
|
-
if (warnedMessages.has(msg))
|
5510
|
-
return;
|
5511
|
-
logger.hasWarned = true;
|
5512
|
-
output('warn', msg, opts);
|
5513
|
-
warnedMessages.add(msg);
|
5514
|
-
},
|
5515
|
-
error(msg, opts) {
|
5516
|
-
logger.hasWarned = true;
|
5517
|
-
output('error', msg, opts);
|
5518
|
-
},
|
5519
|
-
clearScreen(type) {
|
5520
|
-
if (thresh >= LogLevels[type]) {
|
5521
|
-
clear();
|
5522
|
-
}
|
5523
|
-
},
|
5524
|
-
hasErrorLogged(error) {
|
5525
|
-
return loggedErrors.has(error);
|
5526
|
-
},
|
5527
|
-
};
|
5528
|
-
return logger;
|
5484
|
+
};
|
5485
|
+
return logger;
|
5529
5486
|
}
|
5530
5487
|
|
5531
|
-
// https://github.com/vitejs/vite/issues/2820#issuecomment-812495079
|
5532
5488
|
const ROOT_FILES = [
|
5533
|
-
|
5534
|
-
|
5535
|
-
|
5536
|
-
|
5537
|
-
|
5538
|
-
|
5539
|
-
|
5540
|
-
|
5541
|
-
|
5542
|
-
|
5489
|
+
// '.git',
|
5490
|
+
// https://pnpm.io/workspaces/
|
5491
|
+
"pnpm-workspace.yaml",
|
5492
|
+
// https://rushjs.io/pages/advanced/config_files/
|
5493
|
+
// 'rush.json',
|
5494
|
+
// https://nx.dev/latest/react/getting-started/nx-setup
|
5495
|
+
// 'workspace.json',
|
5496
|
+
// 'nx.json',
|
5497
|
+
// https://github.com/lerna/lerna#lernajson
|
5498
|
+
"lerna.json"
|
5543
5499
|
];
|
5544
|
-
// npm: https://docs.npmjs.com/cli/v7/using-npm/workspaces#installing-workspaces
|
5545
|
-
// yarn: https://classic.yarnpkg.com/en/docs/workspaces/#toc-how-to-use-it
|
5546
5500
|
function hasWorkspacePackageJSON(root) {
|
5547
|
-
|
5548
|
-
|
5549
|
-
|
5550
|
-
|
5551
|
-
|
5552
|
-
|
5553
|
-
|
5554
|
-
|
5555
|
-
|
5556
|
-
|
5557
|
-
}
|
5501
|
+
const path = path$3.join(root, "package.json");
|
5502
|
+
if (!isFileReadable(path)) {
|
5503
|
+
return false;
|
5504
|
+
}
|
5505
|
+
try {
|
5506
|
+
const content = JSON.parse(fs$1.readFileSync(path, "utf-8")) || {};
|
5507
|
+
return !!content.workspaces;
|
5508
|
+
} catch {
|
5509
|
+
return false;
|
5510
|
+
}
|
5558
5511
|
}
|
5559
5512
|
function hasRootFile(root) {
|
5560
|
-
|
5513
|
+
return ROOT_FILES.some((file) => fs$1.existsSync(path$3.join(root, file)));
|
5561
5514
|
}
|
5562
5515
|
function hasPackageJSON(root) {
|
5563
|
-
|
5564
|
-
|
5516
|
+
const path = path$3.join(root, "package.json");
|
5517
|
+
return fs$1.existsSync(path);
|
5565
5518
|
}
|
5566
|
-
/**
|
5567
|
-
* Search up for the nearest `package.json`
|
5568
|
-
*/
|
5569
5519
|
function searchForPackageRoot(current, root = current) {
|
5570
|
-
|
5571
|
-
|
5572
|
-
|
5573
|
-
|
5574
|
-
if (!dir || dir === current)
|
5575
|
-
return root;
|
5576
|
-
return searchForPackageRoot(dir, root);
|
5520
|
+
if (hasPackageJSON(current)) return current;
|
5521
|
+
const dir = path$3.dirname(current);
|
5522
|
+
if (!dir || dir === current) return root;
|
5523
|
+
return searchForPackageRoot(dir, root);
|
5577
5524
|
}
|
5578
|
-
/**
|
5579
|
-
* Search up for the nearest workspace root
|
5580
|
-
*/
|
5581
5525
|
function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
|
5582
|
-
|
5583
|
-
|
5584
|
-
|
5585
|
-
|
5586
|
-
|
5587
|
-
// reach the fs root
|
5588
|
-
if (!dir || dir === current)
|
5589
|
-
return root;
|
5590
|
-
return searchForWorkspaceRoot(dir, root);
|
5526
|
+
if (hasRootFile(current)) return current;
|
5527
|
+
if (hasWorkspacePackageJSON(current)) return current;
|
5528
|
+
const dir = path$3.dirname(current);
|
5529
|
+
if (!dir || dir === current) return root;
|
5530
|
+
return searchForWorkspaceRoot(dir, root);
|
5591
5531
|
}
|
5592
5532
|
|
5593
|
-
/**
|
5594
|
-
* Check if the url is allowed to be served, via the `server.fs` config.
|
5595
|
-
*/
|
5596
5533
|
function isFileServingAllowed(url, server) {
|
5597
|
-
|
5598
|
-
|
5599
|
-
|
5600
|
-
|
5601
|
-
|
5602
|
-
|
5603
|
-
|
5604
|
-
|
5605
|
-
|
5606
|
-
return false;
|
5534
|
+
if (!server.config.server.fs.strict) return true;
|
5535
|
+
const file = fsPathFromUrl(url);
|
5536
|
+
if (server._fsDenyGlob(file)) return false;
|
5537
|
+
if (server.moduleGraph.safeModulesPath.has(file)) return true;
|
5538
|
+
if (server.config.server.fs.allow.some(
|
5539
|
+
(uri) => isSameFileUri(uri, file) || isParentDirectory(uri, file)
|
5540
|
+
))
|
5541
|
+
return true;
|
5542
|
+
return false;
|
5607
5543
|
}
|
5608
5544
|
|
5609
5545
|
var main$1 = {exports: {}};
|
@@ -6139,62 +6075,65 @@ function expand (options) {
|
|
6139
6075
|
var expand_1 = expand;
|
6140
6076
|
|
6141
6077
|
function getEnvFilesForMode(mode, envDir) {
|
6142
|
-
|
6143
|
-
|
6144
|
-
|
6145
|
-
|
6146
|
-
|
6147
|
-
|
6078
|
+
return [
|
6079
|
+
/** default file */
|
6080
|
+
`.env`,
|
6081
|
+
/** local file */
|
6082
|
+
`.env.local`,
|
6083
|
+
/** mode file */
|
6084
|
+
`.env.${mode}`,
|
6085
|
+
/** mode local file */
|
6086
|
+
`.env.${mode}.local`
|
6087
|
+
].map((file) => normalizePath(path$3.join(envDir, file)));
|
6148
6088
|
}
|
6149
|
-
function loadEnv(mode, envDir, prefixes =
|
6150
|
-
|
6151
|
-
|
6152
|
-
|
6153
|
-
|
6154
|
-
|
6155
|
-
|
6156
|
-
|
6157
|
-
|
6158
|
-
|
6159
|
-
|
6160
|
-
|
6161
|
-
|
6162
|
-
|
6163
|
-
|
6164
|
-
|
6165
|
-
|
6166
|
-
|
6167
|
-
|
6168
|
-
|
6169
|
-
|
6170
|
-
|
6171
|
-
|
6172
|
-
|
6173
|
-
|
6174
|
-
|
6175
|
-
|
6176
|
-
|
6177
|
-
|
6178
|
-
for (const [key, value] of Object.entries(parsed)) {
|
6179
|
-
if (prefixes.some((prefix) => key.startsWith(prefix))) {
|
6180
|
-
env[key] = value;
|
6181
|
-
}
|
6089
|
+
function loadEnv(mode, envDir, prefixes = "VITE_") {
|
6090
|
+
if (mode === "local") {
|
6091
|
+
throw new Error(
|
6092
|
+
`"local" cannot be used as a mode name because it conflicts with the .local postfix for .env files.`
|
6093
|
+
);
|
6094
|
+
}
|
6095
|
+
prefixes = arraify(prefixes);
|
6096
|
+
const env = {};
|
6097
|
+
const envFiles = getEnvFilesForMode(mode, envDir);
|
6098
|
+
const parsed = Object.fromEntries(
|
6099
|
+
envFiles.flatMap((filePath) => {
|
6100
|
+
if (!tryStatSync(filePath)?.isFile()) return [];
|
6101
|
+
return Object.entries(parse_1(fs$1.readFileSync(filePath)));
|
6102
|
+
})
|
6103
|
+
);
|
6104
|
+
if (parsed.NODE_ENV && process.env.VITE_USER_NODE_ENV === void 0) {
|
6105
|
+
process.env.VITE_USER_NODE_ENV = parsed.NODE_ENV;
|
6106
|
+
}
|
6107
|
+
if (parsed.BROWSER && process.env.BROWSER === void 0) {
|
6108
|
+
process.env.BROWSER = parsed.BROWSER;
|
6109
|
+
}
|
6110
|
+
if (parsed.BROWSER_ARGS && process.env.BROWSER_ARGS === void 0) {
|
6111
|
+
process.env.BROWSER_ARGS = parsed.BROWSER_ARGS;
|
6112
|
+
}
|
6113
|
+
const processEnv = { ...process.env };
|
6114
|
+
expand_1({ parsed, processEnv });
|
6115
|
+
for (const [key, value] of Object.entries(parsed)) {
|
6116
|
+
if (prefixes.some((prefix) => key.startsWith(prefix))) {
|
6117
|
+
env[key] = value;
|
6182
6118
|
}
|
6183
|
-
|
6184
|
-
|
6185
|
-
|
6186
|
-
|
6187
|
-
env[key] = process.env[key];
|
6188
|
-
}
|
6119
|
+
}
|
6120
|
+
for (const key in process.env) {
|
6121
|
+
if (prefixes.some((prefix) => key.startsWith(prefix))) {
|
6122
|
+
env[key] = process.env[key];
|
6189
6123
|
}
|
6190
|
-
|
6124
|
+
}
|
6125
|
+
return env;
|
6191
6126
|
}
|
6192
|
-
function resolveEnvPrefix({
|
6193
|
-
|
6194
|
-
|
6195
|
-
|
6196
|
-
|
6197
|
-
|
6127
|
+
function resolveEnvPrefix({
|
6128
|
+
envPrefix = "VITE_"
|
6129
|
+
}) {
|
6130
|
+
envPrefix = arraify(envPrefix);
|
6131
|
+
if (envPrefix.includes("")) {
|
6132
|
+
throw new Error(
|
6133
|
+
`envPrefix option contains value '', which could lead unexpected exposure of sensitive information.`
|
6134
|
+
);
|
6135
|
+
}
|
6136
|
+
return envPrefix;
|
6198
6137
|
}
|
6199
6138
|
|
6200
6139
|
exports.esbuildVersion = esbuild.version;
|