vite 6.0.0-alpha.18 → 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 +111 -144
- 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-DXWVQosX.js → dep-BWEMV5Th.js} +49165 -46447
- package/dist/node/chunks/{dep-CrWVpuYf.js → dep-D-7KCb9p.js} +32 -2
- package/dist/node/chunks/{dep-70g8Z1cd.js → dep-MbEgMyUv.js} +10 -14
- package/dist/node/chunks/{dep-DlhHXrzk.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 +75 -74
- package/dist/node/index.js +125 -143
- package/dist/node/module-runner.d.ts +3 -0
- package/dist/node/module-runner.js +173 -108
- package/dist/node-cjs/publicUtils.cjs +536 -606
- package/package.json +16 -17
- 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);
|
@@ -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
|
-
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
|
-
const existing = merged[key];
|
3512
|
-
if (existing == null) {
|
3513
|
-
merged[key] = value;
|
3514
|
-
continue;
|
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;
|
3547
3487
|
}
|
3548
|
-
|
3488
|
+
const existing = merged[key];
|
3489
|
+
if (existing == null) {
|
3490
|
+
merged[key] = value;
|
3491
|
+
continue;
|
3492
|
+
}
|
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
|
-
|
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,319 +5285,291 @@ 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
|
-
|
5440
|
-
|
5441
|
-
|
5442
|
-
|
5443
|
-
|
5444
|
-
|
5445
|
-
|
5446
|
-
|
5447
|
-
|
5448
|
-
|
5449
|
-
|
5450
|
-
|
5451
|
-
|
5452
|
-
|
5453
|
-
|
5454
|
-
|
5455
|
-
|
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;
|
5456
5421
|
}
|
5457
|
-
|
5458
|
-
|
5459
|
-
|
5460
|
-
|
5461
|
-
|
5462
|
-
|
5463
|
-
|
5464
|
-
|
5465
|
-
|
5466
|
-
|
5467
|
-
|
5468
|
-
|
5469
|
-
|
5470
|
-
|
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));
|
5471
5445
|
}
|
5446
|
+
} else {
|
5447
|
+
console[method](format(type, msg, options2));
|
5448
|
+
}
|
5472
5449
|
}
|
5473
|
-
|
5474
|
-
|
5475
|
-
|
5476
|
-
|
5477
|
-
|
5478
|
-
|
5479
|
-
|
5480
|
-
|
5481
|
-
|
5482
|
-
|
5483
|
-
|
5484
|
-
|
5485
|
-
|
5486
|
-
|
5487
|
-
|
5488
|
-
|
5489
|
-
|
5490
|
-
|
5491
|
-
|
5492
|
-
|
5493
|
-
|
5494
|
-
|
5495
|
-
|
5496
|
-
|
5497
|
-
|
5498
|
-
|
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);
|
5499
5478
|
}
|
5500
|
-
|
5501
|
-
|
5502
|
-
hasWarned: false,
|
5503
|
-
info(msg, opts) {
|
5504
|
-
output('info', msg, opts);
|
5505
|
-
},
|
5506
|
-
warn(msg, opts) {
|
5507
|
-
logger.hasWarned = true;
|
5508
|
-
output('warn', msg, opts);
|
5509
|
-
},
|
5510
|
-
warnOnce(msg, opts) {
|
5511
|
-
if (warnedMessages.has(msg))
|
5512
|
-
return;
|
5513
|
-
logger.hasWarned = true;
|
5514
|
-
output('warn', msg, opts);
|
5515
|
-
warnedMessages.add(msg);
|
5516
|
-
},
|
5517
|
-
error(msg, opts) {
|
5518
|
-
logger.hasWarned = true;
|
5519
|
-
output('error', msg, opts);
|
5520
|
-
},
|
5521
|
-
clearScreen(type) {
|
5522
|
-
if (thresh >= LogLevels[type]) {
|
5523
|
-
clear();
|
5524
|
-
}
|
5525
|
-
},
|
5526
|
-
hasErrorLogged(error) {
|
5527
|
-
return loggedErrors.has(error);
|
5528
|
-
},
|
5529
|
-
};
|
5530
|
-
return logger;
|
5479
|
+
};
|
5480
|
+
return logger;
|
5531
5481
|
}
|
5532
5482
|
|
5533
|
-
// https://github.com/vitejs/vite/issues/2820#issuecomment-812495079
|
5534
5483
|
const ROOT_FILES = [
|
5535
|
-
|
5536
|
-
|
5537
|
-
|
5538
|
-
|
5539
|
-
|
5540
|
-
|
5541
|
-
|
5542
|
-
|
5543
|
-
|
5544
|
-
|
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"
|
5545
5494
|
];
|
5546
|
-
// npm: https://docs.npmjs.com/cli/v7/using-npm/workspaces#installing-workspaces
|
5547
|
-
// yarn: https://classic.yarnpkg.com/en/docs/workspaces/#toc-how-to-use-it
|
5548
5495
|
function hasWorkspacePackageJSON(root) {
|
5549
|
-
|
5550
|
-
|
5551
|
-
|
5552
|
-
|
5553
|
-
|
5554
|
-
|
5555
|
-
|
5556
|
-
|
5557
|
-
|
5558
|
-
|
5559
|
-
}
|
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
|
+
}
|
5560
5506
|
}
|
5561
5507
|
function hasRootFile(root) {
|
5562
|
-
|
5508
|
+
return ROOT_FILES.some((file) => fs$1.existsSync(path$3.join(root, file)));
|
5563
5509
|
}
|
5564
5510
|
function hasPackageJSON(root) {
|
5565
|
-
|
5566
|
-
|
5511
|
+
const path = path$3.join(root, "package.json");
|
5512
|
+
return fs$1.existsSync(path);
|
5567
5513
|
}
|
5568
|
-
/**
|
5569
|
-
* Search up for the nearest `package.json`
|
5570
|
-
*/
|
5571
5514
|
function searchForPackageRoot(current, root = current) {
|
5572
|
-
|
5573
|
-
|
5574
|
-
|
5575
|
-
|
5576
|
-
if (!dir || dir === current)
|
5577
|
-
return root;
|
5578
|
-
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);
|
5579
5519
|
}
|
5580
|
-
/**
|
5581
|
-
* Search up for the nearest workspace root
|
5582
|
-
*/
|
5583
5520
|
function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
|
5584
|
-
|
5585
|
-
|
5586
|
-
|
5587
|
-
|
5588
|
-
|
5589
|
-
// reach the fs root
|
5590
|
-
if (!dir || dir === current)
|
5591
|
-
return root;
|
5592
|
-
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);
|
5593
5526
|
}
|
5594
5527
|
|
5595
|
-
const safeModulePathsCache = new WeakMap();
|
5528
|
+
const safeModulePathsCache = /* @__PURE__ */ new WeakMap();
|
5596
5529
|
function isSafeModulePath(config, filePath) {
|
5597
|
-
|
5598
|
-
|
5599
|
-
|
5600
|
-
|
5601
|
-
|
5602
|
-
|
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);
|
5603
5536
|
}
|
5604
|
-
const fsDenyGlobCache = new WeakMap();
|
5537
|
+
const fsDenyGlobCache = /* @__PURE__ */ new WeakMap();
|
5605
5538
|
function fsDenyGlob(config, filePath) {
|
5606
|
-
|
5607
|
-
|
5608
|
-
|
5609
|
-
|
5610
|
-
|
5611
|
-
|
5612
|
-
|
5613
|
-
|
5614
|
-
|
5615
|
-
|
5616
|
-
|
5617
|
-
|
5618
|
-
|
5619
|
-
|
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);
|
5620
5556
|
}
|
5621
|
-
/**
|
5622
|
-
* Check if the url is allowed to be served, via the `server.fs` config.
|
5623
|
-
* @deprecated use isFileLoadingAllowed
|
5624
|
-
*/
|
5625
5557
|
function isFileServingAllowed(url, server) {
|
5626
|
-
|
5627
|
-
|
5628
|
-
|
5629
|
-
|
5630
|
-
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);
|
5631
5562
|
}
|
5632
5563
|
function isUriInFilePath(uri, filePath) {
|
5633
|
-
|
5564
|
+
return isSameFileUri(uri, filePath) || isParentDirectory(uri, filePath);
|
5634
5565
|
}
|
5635
5566
|
function isFileLoadingAllowed(config, filePath) {
|
5636
|
-
|
5637
|
-
|
5638
|
-
|
5639
|
-
|
5640
|
-
|
5641
|
-
|
5642
|
-
return true;
|
5643
|
-
if (fs.allow.some((uri) => isUriInFilePath(uri, filePath)))
|
5644
|
-
return true;
|
5645
|
-
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;
|
5646
5573
|
}
|
5647
5574
|
|
5648
5575
|
var main$1 = {exports: {}};
|
@@ -6178,62 +6105,65 @@ function expand (options) {
|
|
6178
6105
|
var expand_1 = expand;
|
6179
6106
|
|
6180
6107
|
function getEnvFilesForMode(mode, envDir) {
|
6181
|
-
|
6182
|
-
|
6183
|
-
|
6184
|
-
|
6185
|
-
|
6186
|
-
|
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)));
|
6187
6118
|
}
|
6188
|
-
function loadEnv(mode, envDir, prefixes =
|
6189
|
-
|
6190
|
-
|
6191
|
-
|
6192
|
-
|
6193
|
-
|
6194
|
-
|
6195
|
-
|
6196
|
-
|
6197
|
-
|
6198
|
-
|
6199
|
-
|
6200
|
-
|
6201
|
-
|
6202
|
-
|
6203
|
-
|
6204
|
-
|
6205
|
-
|
6206
|
-
|
6207
|
-
|
6208
|
-
|
6209
|
-
|
6210
|
-
|
6211
|
-
|
6212
|
-
|
6213
|
-
|
6214
|
-
|
6215
|
-
|
6216
|
-
|
6217
|
-
for (const [key, value] of Object.entries(parsed)) {
|
6218
|
-
if (prefixes.some((prefix) => key.startsWith(prefix))) {
|
6219
|
-
env[key] = value;
|
6220
|
-
}
|
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;
|
6221
6148
|
}
|
6222
|
-
|
6223
|
-
|
6224
|
-
|
6225
|
-
|
6226
|
-
env[key] = process.env[key];
|
6227
|
-
}
|
6149
|
+
}
|
6150
|
+
for (const key in process.env) {
|
6151
|
+
if (prefixes.some((prefix) => key.startsWith(prefix))) {
|
6152
|
+
env[key] = process.env[key];
|
6228
6153
|
}
|
6229
|
-
|
6154
|
+
}
|
6155
|
+
return env;
|
6230
6156
|
}
|
6231
|
-
function resolveEnvPrefix({
|
6232
|
-
|
6233
|
-
|
6234
|
-
|
6235
|
-
|
6236
|
-
|
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;
|
6237
6167
|
}
|
6238
6168
|
|
6239
6169
|
exports.esbuildVersion = esbuild.version;
|