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.
@@ -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(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());
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
- const CLIENT_ENTRY = path$3.resolve(VITE_PACKAGE_DIR, 'dist/client/client.mjs');
27
- path$3.resolve(VITE_PACKAGE_DIR, 'dist/client/env.mjs');
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.format()` with the specified arguments and writes to stderr.
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.format(...args) + '\n');
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 !== 'undefined' && process.platform === 'win32';
3357
+ const isWindows = typeof process !== "undefined" && process.platform === "win32";
3357
3358
  const windowsSlashRE = /\\/g;
3358
3359
  function slash(p) {
3359
- return p.replace(windowsSlashRE, '/');
3360
+ return p.replace(windowsSlashRE, "/");
3360
3361
  }
3361
3362
  const postfixRE = /[?#].*$/;
3362
3363
  function cleanUrl(url) {
3363
- return url.replace(postfixRE, '');
3364
+ return url.replace(postfixRE, "");
3364
3365
  }
3365
3366
  function withTrailingSlash(path) {
3366
- if (path[path.length - 1] !== '/') {
3367
- return `${path}/`;
3368
- }
3369
- return path;
3367
+ if (path[path.length - 1] !== "/") {
3368
+ return `${path}/`;
3369
+ }
3370
+ return path;
3370
3371
  }
3371
3372
 
3372
3373
  if (process.versions.pnp) {
3373
- try {
3374
- 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');
3375
- }
3376
- catch { }
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
- // Some runtimes like Bun injects namespaced modules here, which is not a node builtin
3381
- node_module.builtinModules.filter((id) => !id.includes(':'));
3381
+ node_module.builtinModules.filter((id) => !id.includes(":"));
3382
3382
  function isInNodeModules(id) {
3383
- return id.includes('node_modules');
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 = '../../package.json') {
3388
- const pkgPath = path$3.resolve(_require.resolve(dep), pkgRelativePath);
3389
- return JSON.parse(fs$1.readFileSync(pkgPath, 'utf-8')).version;
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('rollup');
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
- const log = debug$2(namespace);
3397
- const { onlyWhenFocused } = options;
3398
- let enabled = log.enabled;
3399
- if (enabled && onlyWhenFocused) {
3400
- const ns = typeof onlyWhenFocused === 'string' ? onlyWhenFocused : namespace;
3401
- enabled = !!DEBUG?.includes(ns);
3402
- }
3403
- if (enabled) {
3404
- return (...args) => {
3405
- if (!filter || args.some((a) => a?.includes?.(filter))) {
3406
- log(...args);
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
- if (!CLIENT_ENTRY.endsWith('client.mjs')) {
3413
- throw new Error(`cannot test case insensitive FS, CLIENT_ENTRY const doesn't contain client.mjs`);
3414
- }
3415
- if (!fs$1.existsSync(CLIENT_ENTRY)) {
3416
- throw new Error('cannot test case insensitive FS, CLIENT_ENTRY does not point to an existing file: ' +
3417
- CLIENT_ENTRY);
3418
- }
3419
- return fs$1.existsSync(CLIENT_ENTRY.replace('client.mjs', 'cLiEnT.mjs'));
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
- return path$3.posix.normalize(isWindows ? slash(id) : id);
3425
+ return path$3.posix.normalize(isWindows ? slash(id) : id);
3425
3426
  }
3426
3427
  function fsPathFromId(id) {
3427
- const fsPath = normalizePath(id.startsWith(FS_PREFIX) ? id.slice(FS_PREFIX.length) : id);
3428
- return fsPath[0] === '/' || VOLUME_RE.test(fsPath) ? fsPath : `/${fsPath}`;
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
- return fsPathFromId(cleanUrl(url));
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
- dir = withTrailingSlash(dir);
3444
- return (file.startsWith(dir) ||
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
- return (file1 === file2 ||
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
- return url.replace(timestampRE, '').replace(trailingSeparatorRE, '');
3446
+ return url.replace(timestampRE, "").replace(trailingSeparatorRE, "");
3464
3447
  }
3465
3448
  function isObject$1(value) {
3466
- return Object.prototype.toString.call(value) === '[object Object]';
3449
+ return Object.prototype.toString.call(value) === "[object Object]";
3467
3450
  }
3468
3451
  function tryStatSync(file) {
3469
- try {
3470
- // The "throwIfNoEntry" is a performance optimization for cases where the file does not exist
3471
- return fs$1.statSync(file, { throwIfNoEntry: false });
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
- if (!tryStatSync(filename)) {
3480
- return false;
3481
- }
3482
- try {
3483
- // Check if current process has read permission to the file
3484
- fs$1.accessSync(filename, fs$1.constants.R_OK);
3485
- return true;
3486
- }
3487
- catch {
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
- return Array.isArray(target) ? target : [target];
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
- if (Array.isArray(plugins)) {
3497
- return plugins;
3498
- }
3499
- if (typeof plugins === 'function') {
3500
- return plugins();
3501
- }
3502
- return [];
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
- const merged = { ...defaults };
3506
- for (const key in overrides) {
3507
- const value = overrides[key];
3508
- if (value == null) {
3509
- continue;
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;
3487
+ }
3488
+ const existing = merged[key];
3489
+ if (existing == null) {
3490
+ merged[key] = value;
3491
+ continue;
3547
3492
  }
3548
- return merged;
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
- if (typeof defaults === 'function' || typeof overrides === 'function') {
3552
- throw new Error(`Cannot merge config in form of callback`);
3553
- }
3554
- return mergeConfigRecursively(defaults, overrides, isRoot ? '' : '.');
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
- if (!a)
3558
- return b;
3559
- if (!b)
3560
- return a;
3561
- if (isObject$1(a) && isObject$1(b)) {
3562
- return { ...a, ...b };
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
- return Array.isArray(o)
3570
- ? o.map(normalizeSingleAlias)
3571
- : Object.keys(o).map((find) => normalizeSingleAlias({
3572
- find,
3573
- replacement: o[find],
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
- * Creates a function that hides the complexities of a WeakMap with an initial value
3596
- * to implement object metadata. Used by plugins to implement cross hooks per
3597
- * environment metadata
3598
- */
3599
- function createWeakData(initial) {
3600
- const cache = new WeakMap();
3601
- return function (key) {
3602
- let data = cache.get(key);
3603
- if (!data) {
3604
- data = initial(key);
3605
- cache.set(key, data);
3606
- }
3607
- return data;
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
- // This file will be built for both ESM and CJS. Avoid relying on other modules as possible.
3612
- // copy from constants.ts
3613
- const CSS_LANGS_RE =
3614
- // eslint-disable-next-line regexp/no-unused-capturing-group
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
- cache;
3629
- constructor() {
3630
- this.cache = new Map();
3631
- }
3632
- reset() {
3633
- this.cache = new Map();
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
- const cache = options.cache ?? new SplitVendorChunkCache();
3641
- return (id, { getModuleInfo }) => {
3642
- if (isInNodeModules(id) &&
3643
- !isCSSRequest(id) &&
3644
- staticImportedByEntry(id, getModuleInfo, cache.cache)) {
3645
- return 'vendor';
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
- if (cache.has(id)) {
3651
- return cache.get(id);
3652
- }
3653
- if (importStack.includes(id)) {
3654
- // circular deps!
3655
- cache.set(id, false);
3656
- return false;
3657
- }
3658
- const mod = getModuleInfo(id);
3659
- if (!mod) {
3660
- cache.set(id, false);
3661
- return false;
3662
- }
3663
- if (mod.isEntry) {
3664
- cache.set(id, true);
3665
- return true;
3666
- }
3667
- const someImporterIs = mod.importers.some((importer) => staticImportedByEntry(importer, getModuleInfo, cache, importStack.concat(id)));
3668
- cache.set(id, someImporterIs);
3669
- return someImporterIs;
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
- const caches = [];
3676
- function createSplitVendorChunk(output, config) {
3677
- const cache = new SplitVendorChunkCache();
3678
- caches.push(cache);
3679
- const build = config.build ?? {};
3680
- const format = output?.format;
3681
- if (!build.ssr && !build.lib && format !== 'umd' && format !== 'iife') {
3682
- return splitVendorChunk({ cache });
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
- return {
3686
- name: 'vite:split-vendor-chunk',
3687
- config(config) {
3688
- let outputs = config?.build?.rollupOptions?.output;
3689
- if (outputs) {
3690
- outputs = arraify(outputs);
3691
- for (const output of outputs) {
3692
- const viteManualChunks = createSplitVendorChunk(output, config);
3693
- if (viteManualChunks) {
3694
- if (output.manualChunks) {
3695
- if (typeof output.manualChunks === 'function') {
3696
- const userManualChunks = output.manualChunks;
3697
- output.manualChunks = (id, api) => {
3698
- return userManualChunks(id, api) ?? viteManualChunks(id, api);
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
- buildStart() {
3727
- caches.forEach((cache) => cache.reset());
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('vite:sourcemap', {
5350
- onlyWhenFocused: true,
5288
+ const debug$1 = createDebugger("vite:sourcemap", {
5289
+ onlyWhenFocused: true
5351
5290
  });
5352
5291
  function genSourceMapUrl(map) {
5353
- if (typeof map !== 'string') {
5354
- map = JSON.stringify(map);
5355
- }
5356
- return `data:application/json;base64,${Buffer.from(map).toString('base64')}`;
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
- if (debug$1) {
5360
- code += `\n/*${JSON.stringify(map, null, 2).replace(/\*\//g, '*\\/')}*/\n`;
5361
- }
5362
- if (type === 'js') {
5363
- code += `\n//# sourceMappingURL=${genSourceMapUrl(map)}`;
5364
- }
5365
- else if (type === 'css') {
5366
- code += `\n/*# sourceMappingURL=${genSourceMapUrl(map)} */`;
5367
- }
5368
- return code;
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('vite:send', {
5372
- onlyWhenFocused: true,
5313
+ const debug = createDebugger("vite:send", {
5314
+ onlyWhenFocused: true
5373
5315
  });
5374
5316
  const alias = {
5375
- js: 'text/javascript',
5376
- css: 'text/css',
5377
- html: 'text/html',
5378
- json: 'application/json',
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
- const { etag = getEtag(content, { weak: true }), cacheControl = 'no-cache', headers, map, } = options;
5382
- if (res.writableEnded) {
5383
- return;
5384
- }
5385
- if (req.headers['if-none-match'] === etag) {
5386
- res.statusCode = 304;
5387
- res.end();
5388
- return;
5389
- }
5390
- res.setHeader('Content-Type', alias[type] || type);
5391
- res.setHeader('Cache-Control', cacheControl);
5392
- res.setHeader('Etag', etag);
5393
- if (headers) {
5394
- for (const name in headers) {
5395
- res.setHeader(name, headers[name]);
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
- // inject source map reference
5399
- if (map && 'version' in map && map.mappings) {
5400
- if (type === 'js' || type === 'css') {
5401
- content = getCodeWithSourcemap(type, content.toString(), map);
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
- // inject fallback sourcemap for js for improved debugging
5405
- // https://github.com/vitejs/vite/pull/13514#issuecomment-1592431496
5406
- else if (type === 'js' && (!map || map.mappings !== '')) {
5407
- const code = content.toString();
5408
- // if the code has existing inline sourcemap, assume it's correct and skip
5409
- if (convertSourceMap.mapFileCommentRegex.test(code)) {
5410
- debug?.(`Skipped injecting fallback sourcemap for ${req.url}`);
5411
- }
5412
- else {
5413
- const urlWithoutTimestamp = removeTimestampQuery(req.url);
5414
- const ms = new MagicString(code);
5415
- content = getCodeWithSourcemap(type, code, ms.generateMap({
5416
- source: path$3.basename(urlWithoutTimestamp),
5417
- hires: 'boundary',
5418
- includeContent: true,
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
- res.statusCode = 200;
5423
- res.end(content);
5424
- return;
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
- silent: 0,
5430
- error: 1,
5431
- warn: 2,
5432
- info: 3,
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
- const repeatCount = process.stdout.rows - 2;
5439
- const blank = repeatCount > 0 ? '\n'.repeat(repeatCount) : '';
5440
- console.log(blank);
5441
- readline.cursorTo(process.stdout, 0, 0);
5442
- readline.clearScreenDown(process.stdout);
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
- timeFormatter ??= new Intl.DateTimeFormat(undefined, {
5449
- hour: 'numeric',
5450
- minute: 'numeric',
5451
- second: 'numeric',
5452
- });
5453
- return timeFormatter;
5390
+ timeFormatter ??= new Intl.DateTimeFormat(void 0, {
5391
+ hour: "numeric",
5392
+ minute: "numeric",
5393
+ second: "numeric"
5394
+ });
5395
+ return timeFormatter;
5454
5396
  }
5455
- const MAX_LOG_CHAR = 5000;
5456
- function createLogger(level = 'info', options = {}) {
5457
- if (options.customLogger) {
5458
- return options.customLogger;
5459
- }
5460
- const loggedErrors = new WeakSet();
5461
- const { prefix = '[vite]', allowClearScreen = true } = options;
5462
- const thresh = LogLevels[level];
5463
- const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
5464
- const clear = canClearScreen ? clearScreen : () => { };
5465
- function preventOverflow(msg) {
5466
- if (msg.length > MAX_LOG_CHAR) {
5467
- const shorten = msg.slice(0, MAX_LOG_CHAR);
5468
- const lines = msg.slice(MAX_LOG_CHAR).match(splitRE)?.length || 0;
5469
- return `${shorten}\n... and ${lines} lines more`;
5470
- }
5471
- return msg;
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
- function format(type, rawMsg, options = {}) {
5474
- const msg = preventOverflow(rawMsg);
5475
- if (options.timestamp) {
5476
- const color = type === 'info'
5477
- ? colors.cyan
5478
- : type === 'warn'
5479
- ? colors.yellow
5480
- : colors.red;
5481
- const tag = color(colors.bold(prefix));
5482
- const environment = options.environment ? options.environment + ' ' : '';
5483
- return `${colors.dim(getTimeFormatter().format(new Date()))} ${tag} ${environment}${msg}`;
5484
- }
5485
- else {
5486
- return msg;
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
- function output(type, msg, options = {}) {
5490
- if (thresh >= LogLevels[type]) {
5491
- const method = type === 'info' ? 'log' : type;
5492
- if (options.error) {
5493
- loggedErrors.add(options.error);
5494
- }
5495
- if (canClearScreen) {
5496
- if (type === lastType && msg === lastMsg) {
5497
- sameCount++;
5498
- clear();
5499
- console[method](format(type, msg, options), colors.yellow(`(x${sameCount + 1})`));
5500
- }
5501
- else {
5502
- sameCount = 0;
5503
- lastMsg = msg;
5504
- lastType = type;
5505
- if (options.clear) {
5506
- clear();
5507
- }
5508
- console[method](format(type, msg, options));
5509
- }
5510
- }
5511
- else {
5512
- console[method](format(type, msg, options));
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
- const warnedMessages = new Set();
5517
- const logger = {
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
- // '.git',
5552
- // https://pnpm.io/workspaces/
5553
- 'pnpm-workspace.yaml',
5554
- // https://rushjs.io/pages/advanced/config_files/
5555
- // 'rush.json',
5556
- // https://nx.dev/latest/react/getting-started/nx-setup
5557
- // 'workspace.json',
5558
- // 'nx.json',
5559
- // https://github.com/lerna/lerna#lernajson
5560
- 'lerna.json',
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
- const path = path$3.join(root, 'package.json');
5566
- if (!isFileReadable(path)) {
5567
- return false;
5568
- }
5569
- try {
5570
- const content = JSON.parse(fs$1.readFileSync(path, 'utf-8')) || {};
5571
- return !!content.workspaces;
5572
- }
5573
- catch {
5574
- return false;
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
- return ROOT_FILES.some((file) => fs$1.existsSync(path$3.join(root, file)));
5508
+ return ROOT_FILES.some((file) => fs$1.existsSync(path$3.join(root, file)));
5579
5509
  }
5580
5510
  function hasPackageJSON(root) {
5581
- const path = path$3.join(root, 'package.json');
5582
- return fs$1.existsSync(path);
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
- if (hasPackageJSON(current))
5589
- return current;
5590
- const dir = path$3.dirname(current);
5591
- // reach the fs root
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
- if (hasRootFile(current))
5601
- return current;
5602
- if (hasWorkspacePackageJSON(current))
5603
- return current;
5604
- const dir = path$3.dirname(current);
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
- let safeModulePaths = safeModulePathsCache.get(config);
5614
- if (!safeModulePaths) {
5615
- safeModulePaths = new Set();
5616
- safeModulePathsCache.set(config, safeModulePaths);
5617
- }
5618
- return safeModulePaths.has(filePath);
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
- let matcher = fsDenyGlobCache.get(config);
5623
- if (!matcher) {
5624
- (matcher = picomatch$1(
5625
- // matchBase: true does not work as it's documented
5626
- // https://github.com/micromatch/picomatch/issues/89
5627
- // convert patterns without `/` on our side for now
5628
- config.server.fs.deny.map((pattern) => pattern.includes('/') ? pattern : `**/${pattern}`), {
5629
- matchBase: false,
5630
- nocase: true,
5631
- dot: true,
5632
- })),
5633
- fsDenyGlobCache.set(config, matcher);
5634
- }
5635
- return matcher(filePath);
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
- const { config } = server;
5643
- if (!config.server.fs.strict)
5644
- return true;
5645
- const filePath = fsPathFromUrl(url);
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
- return isSameFileUri(uri, filePath) || isParentDirectory(uri, filePath);
5564
+ return isSameFileUri(uri, filePath) || isParentDirectory(uri, filePath);
5650
5565
  }
5651
5566
  function isFileLoadingAllowed(config, filePath) {
5652
- const { fs } = config.server;
5653
- if (!fs.strict)
5654
- return true;
5655
- if (fsDenyGlob(config, filePath))
5656
- return false;
5657
- if (isSafeModulePath(config, filePath))
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
- return [
6198
- /** default file */ `.env`,
6199
- /** local file */ `.env.local`,
6200
- /** mode file */ `.env.${mode}`,
6201
- /** mode local file */ `.env.${mode}.local`,
6202
- ].map((file) => normalizePath(path$3.join(envDir, file)));
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 = 'VITE_') {
6205
- if (mode === 'local') {
6206
- throw new Error(`"local" cannot be used as a mode name because it conflicts with ` +
6207
- `the .local postfix for .env files.`);
6208
- }
6209
- prefixes = arraify(prefixes);
6210
- const env = {};
6211
- const envFiles = getEnvFilesForMode(mode, envDir);
6212
- const parsed = Object.fromEntries(envFiles.flatMap((filePath) => {
6213
- if (!tryStatSync(filePath)?.isFile())
6214
- return [];
6215
- return Object.entries(parse_1(fs$1.readFileSync(filePath)));
6216
- }));
6217
- // test NODE_ENV override before expand as otherwise process.env.NODE_ENV would override this
6218
- if (parsed.NODE_ENV && process.env.VITE_USER_NODE_ENV === undefined) {
6219
- process.env.VITE_USER_NODE_ENV = parsed.NODE_ENV;
6220
- }
6221
- // support BROWSER and BROWSER_ARGS env variables
6222
- if (parsed.BROWSER && process.env.BROWSER === undefined) {
6223
- process.env.BROWSER = parsed.BROWSER;
6224
- }
6225
- if (parsed.BROWSER_ARGS && process.env.BROWSER_ARGS === undefined) {
6226
- process.env.BROWSER_ARGS = parsed.BROWSER_ARGS;
6227
- }
6228
- // let environment variables use each other. make a copy of `process.env` so that `dotenv-expand`
6229
- // doesn't re-assign the expanded values to the global `process.env`.
6230
- const processEnv = { ...process.env };
6231
- expand_1({ parsed, processEnv });
6232
- // only keys that start with prefix are exposed to client
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
- // check if there are actual env variables starting with VITE_*
6239
- // these are typically provided inline and should be prioritized
6240
- for (const key in process.env) {
6241
- if (prefixes.some((prefix) => key.startsWith(prefix))) {
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
- return env;
6154
+ }
6155
+ return env;
6246
6156
  }
6247
- function resolveEnvPrefix({ envPrefix = 'VITE_', }) {
6248
- envPrefix = arraify(envPrefix);
6249
- if (envPrefix.includes('')) {
6250
- throw new Error(`envPrefix option contains value '', which could lead unexpected exposure of sensitive information.`);
6251
- }
6252
- return envPrefix;
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;