vite 4.2.1 → 4.3.0-beta.1

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.

Potentially problematic release.


This version of vite might be problematic. Click here for more details.

package/dist/node/cli.js CHANGED
@@ -2,8 +2,9 @@ import path from 'node:path';
2
2
  import fs from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { A as picocolorsExports, B as bindShortcuts, w as createLogger, h as resolveConfig } from './chunks/dep-79892de8.js';
5
+ import { B as picocolorsExports, C as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-f365bad6.js';
6
6
  import { VERSION } from './constants.js';
7
+ import 'node:fs/promises';
7
8
  import 'node:url';
8
9
  import 'node:module';
9
10
  import 'tty';
@@ -19,13 +20,13 @@ import 'stream';
19
20
  import 'os';
20
21
  import 'child_process';
21
22
  import 'node:os';
23
+ import 'node:child_process';
22
24
  import 'node:crypto';
23
- import 'node:util';
24
25
  import 'node:dns';
25
26
  import 'resolve';
26
27
  import 'crypto';
27
28
  import 'node:buffer';
28
- import 'node:fs/promises';
29
+ import 'node:util';
29
30
  import 'module';
30
31
  import 'node:assert';
31
32
  import 'node:process';
@@ -40,7 +41,6 @@ import 'node:https';
40
41
  import 'rollup';
41
42
  import 'querystring';
42
43
  import 'node:readline';
43
- import 'node:child_process';
44
44
  import 'node:zlib';
45
45
 
46
46
  function toArr(any) {
@@ -729,7 +729,7 @@ cli
729
729
  filterDuplicateOptions(options);
730
730
  // output structure is preserved even after bundling so require()
731
731
  // is ok here
732
- const { createServer } = await import('./chunks/dep-79892de8.js').then(function (n) { return n.F; });
732
+ const { createServer } = await import('./chunks/dep-f365bad6.js').then(function (n) { return n.G; });
733
733
  try {
734
734
  const server = await createServer({
735
735
  root,
@@ -807,7 +807,7 @@ cli
807
807
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
808
808
  .action(async (root, options) => {
809
809
  filterDuplicateOptions(options);
810
- const { build } = await import('./chunks/dep-79892de8.js').then(function (n) { return n.E; });
810
+ const { build } = await import('./chunks/dep-f365bad6.js').then(function (n) { return n.F; });
811
811
  const buildOptions = cleanOptions(options);
812
812
  try {
813
813
  await build({
@@ -835,7 +835,7 @@ cli
835
835
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
836
836
  .action(async (root, options) => {
837
837
  filterDuplicateOptions(options);
838
- const { optimizeDeps } = await import('./chunks/dep-79892de8.js').then(function (n) { return n.D; });
838
+ const { optimizeDeps } = await import('./chunks/dep-f365bad6.js').then(function (n) { return n.E; });
839
839
  try {
840
840
  const config = await resolveConfig({
841
841
  root,
@@ -860,7 +860,7 @@ cli
860
860
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
861
861
  .action(async (root, options) => {
862
862
  filterDuplicateOptions(options);
863
- const { preview } = await import('./chunks/dep-79892de8.js').then(function (n) { return n.G; });
863
+ const { preview } = await import('./chunks/dep-f365bad6.js').then(function (n) { return n.H; });
864
864
  try {
865
865
  const server = await preview({
866
866
  root,
@@ -94,6 +94,7 @@ const KNOWN_ASSET_TYPES = [
94
94
  'wav',
95
95
  'flac',
96
96
  'aac',
97
+ 'opus',
97
98
  // fonts
98
99
  'woff2?',
99
100
  'eot',
@@ -663,6 +663,9 @@ export declare interface DepOptimizationResult {
663
663
  * to be able to discard the result
664
664
  */
665
665
  commit: () => Promise<void>;
666
+ /**
667
+ * @deprecated noop
668
+ */
666
669
  cancel: () => void;
667
670
  }
668
671
 
@@ -680,6 +683,7 @@ export declare interface DepsOptimizer {
680
683
  ensureFirstRun: () => void;
681
684
  close: () => Promise<void>;
682
685
  options: DepOptimizationOptions;
686
+ server?: ViteDevServer;
683
687
  }
684
688
 
685
689
  export { ErrorPayload }
@@ -1184,7 +1188,6 @@ export declare interface InternalResolveOptions extends Required<ResolveOptions>
1184
1188
  asSrc?: boolean;
1185
1189
  tryIndex?: boolean;
1186
1190
  tryPrefix?: string;
1187
- skipPackageJson?: boolean;
1188
1191
  preferRelative?: boolean;
1189
1192
  isRequire?: boolean;
1190
1193
  isFromTsImporter?: boolean;
@@ -1494,8 +1497,9 @@ declare interface Plugin_2 extends Plugin_3 {
1494
1497
  */
1495
1498
  configureServer?: ObjectHook<ServerHook>;
1496
1499
  /**
1497
- * Configure the preview server. The hook receives the connect server and
1498
- * its underlying http server.
1500
+ * Configure the preview server. The hook receives the {@link PreviewServerForHook}
1501
+ * instance. This can also be used to store a reference to the server
1502
+ * for use in other hooks.
1499
1503
  *
1500
1504
  * The hooks are called before other middlewares are applied. A hook can
1501
1505
  * return a post hook that will be called after other middlewares are
@@ -1602,11 +1606,24 @@ export declare function preview(inlineConfig?: InlineConfig): Promise<PreviewSer
1602
1606
  export declare interface PreviewOptions extends CommonServerOptions {
1603
1607
  }
1604
1608
 
1605
- export declare interface PreviewServer {
1609
+ export declare interface PreviewServer extends PreviewServerForHook {
1610
+ resolvedUrls: ResolvedServerUrls;
1611
+ }
1612
+
1613
+ export declare interface PreviewServerForHook {
1606
1614
  /**
1607
1615
  * The resolved vite config object
1608
1616
  */
1609
1617
  config: ResolvedConfig;
1618
+ /**
1619
+ * A connect app instance.
1620
+ * - Can be used to attach custom middlewares to the preview server.
1621
+ * - Can also be used as the handler function of a custom http server
1622
+ * or as a middleware in any connect-style Node.js frameworks
1623
+ *
1624
+ * https://github.com/senchalabs/connect#use-middleware
1625
+ */
1626
+ middlewares: Connect.Server;
1610
1627
  /**
1611
1628
  * native Node http server instance
1612
1629
  */
@@ -1614,17 +1631,14 @@ export declare interface PreviewServer {
1614
1631
  /**
1615
1632
  * The resolved urls Vite prints on the CLI
1616
1633
  */
1617
- resolvedUrls: ResolvedServerUrls;
1634
+ resolvedUrls: ResolvedServerUrls | null;
1618
1635
  /**
1619
1636
  * Print server urls
1620
1637
  */
1621
1638
  printUrls(): void;
1622
1639
  }
1623
1640
 
1624
- export declare type PreviewServerHook = (this: void, server: {
1625
- middlewares: Connect.Server;
1626
- httpServer: http.Server;
1627
- }) => (() => void) | void | Promise<(() => void) | void>;
1641
+ export declare type PreviewServerHook = (this: void, server: PreviewServerForHook) => (() => void) | void | Promise<(() => void) | void>;
1628
1642
 
1629
1643
  export declare interface ProxyOptions extends HttpProxy.ServerOptions {
1630
1644
  /**
@@ -1762,7 +1776,7 @@ export declare interface ResolveOptions {
1762
1776
  preserveSymlinks?: boolean;
1763
1777
  }
1764
1778
 
1765
- export declare function resolvePackageData(id: string, basedir: string, preserveSymlinks?: boolean, packageCache?: PackageCache): PackageData | null;
1779
+ export declare function resolvePackageData(pkgName: string, basedir: string, preserveSymlinks?: boolean, packageCache?: PackageCache): PackageData | null;
1766
1780
 
1767
1781
  export declare function resolvePackageEntry(id: string, { dir, data, setResolvedCache, getResolvedCache }: PackageData, targetWeb: boolean, options: InternalResolveOptions): string | undefined;
1768
1782
 
@@ -1,8 +1,10 @@
1
- export { b as build, e as buildErrorMessage, u as createFilter, w as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, j as getDepOptimizationConfig, k as isDepsOptimizerEnabled, l as loadConfigFromFile, y as loadEnv, q as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, i as resolveBaseUrl, h as resolveConfig, z as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, x as searchForWorkspaceRoot, v as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-79892de8.js';
1
+ import { i as isInNodeModules } from './chunks/dep-f365bad6.js';
2
+ export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, l as loadConfigFromFile, z as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, A as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-f365bad6.js';
2
3
  export { VERSION as version } from './constants.js';
3
4
  export { version as esbuildVersion } from 'esbuild';
4
5
  export { VERSION as rollupVersion } from 'rollup';
5
6
  import 'node:fs';
7
+ import 'node:fs/promises';
6
8
  import 'node:path';
7
9
  import 'node:url';
8
10
  import 'node:perf_hooks';
@@ -20,13 +22,13 @@ import 'stream';
20
22
  import 'os';
21
23
  import 'child_process';
22
24
  import 'node:os';
25
+ import 'node:child_process';
23
26
  import 'node:crypto';
24
- import 'node:util';
25
27
  import 'node:dns';
26
28
  import 'resolve';
27
29
  import 'crypto';
28
30
  import 'node:buffer';
29
- import 'node:fs/promises';
31
+ import 'node:util';
30
32
  import 'module';
31
33
  import 'node:assert';
32
34
  import 'node:process';
@@ -40,7 +42,6 @@ import 'node:http';
40
42
  import 'node:https';
41
43
  import 'querystring';
42
44
  import 'node:readline';
43
- import 'node:child_process';
44
45
  import 'node:zlib';
45
46
 
46
47
  // This file will be built for both ESM and CJS. Avoid relying on other modules as possible.
@@ -67,7 +68,7 @@ class SplitVendorChunkCache {
67
68
  function splitVendorChunk(options = {}) {
68
69
  const cache = options.cache ?? new SplitVendorChunkCache();
69
70
  return (id, { getModuleInfo }) => {
70
- if (id.includes('node_modules') &&
71
+ if (isInNodeModules(id) &&
71
72
  !isCSSRequest(id) &&
72
73
  staticImportedByEntry(id, getModuleInfo, cache.cache)) {
73
74
  return 'vendor';
@@ -6,7 +6,6 @@ var fs$1 = require('node:fs');
6
6
  var esbuild = require('esbuild');
7
7
  var rollup = require('rollup');
8
8
  var os$1 = require('node:os');
9
- var node_util = require('node:util');
10
9
  var node_module = require('node:module');
11
10
  var require$$0 = require('tty');
12
11
  var require$$1 = require('util');
@@ -25,113 +24,6 @@ const CLIENT_ENTRY = path$3.resolve(VITE_PACKAGE_DIR, 'dist/client/client.mjs');
25
24
  path$3.resolve(VITE_PACKAGE_DIR, 'dist/client/env.mjs');
26
25
  path$3.dirname(CLIENT_ENTRY);
27
26
 
28
- // This file will be built for both ESM and CJS. Avoid relying on other modules as possible.
29
- // copy from constants.ts
30
- const CSS_LANGS_RE =
31
- // eslint-disable-next-line regexp/no-unused-capturing-group
32
- /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
33
- const isCSSRequest = (request) => CSS_LANGS_RE.test(request);
34
- // Use splitVendorChunkPlugin() to get the same manualChunks strategy as Vite 2.7
35
- // We don't recommend using this strategy as a general solution moving forward
36
- // splitVendorChunk is a simple index/vendor strategy that was used in Vite
37
- // until v2.8. It is exposed to let people continue to use it in case it was
38
- // working well for their setups.
39
- // The cache needs to be reset on buildStart for watch mode to work correctly
40
- // Don't use this manualChunks strategy for ssr, lib mode, and 'umd' or 'iife'
41
- class SplitVendorChunkCache {
42
- constructor() {
43
- this.cache = new Map();
44
- }
45
- reset() {
46
- this.cache = new Map();
47
- }
48
- }
49
- function splitVendorChunk(options = {}) {
50
- const cache = options.cache ?? new SplitVendorChunkCache();
51
- return (id, { getModuleInfo }) => {
52
- if (id.includes('node_modules') &&
53
- !isCSSRequest(id) &&
54
- staticImportedByEntry(id, getModuleInfo, cache.cache)) {
55
- return 'vendor';
56
- }
57
- };
58
- }
59
- function staticImportedByEntry(id, getModuleInfo, cache, importStack = []) {
60
- if (cache.has(id)) {
61
- return cache.get(id);
62
- }
63
- if (importStack.includes(id)) {
64
- // circular deps!
65
- cache.set(id, false);
66
- return false;
67
- }
68
- const mod = getModuleInfo(id);
69
- if (!mod) {
70
- cache.set(id, false);
71
- return false;
72
- }
73
- if (mod.isEntry) {
74
- cache.set(id, true);
75
- return true;
76
- }
77
- const someImporterIs = mod.importers.some((importer) => staticImportedByEntry(importer, getModuleInfo, cache, importStack.concat(id)));
78
- cache.set(id, someImporterIs);
79
- return someImporterIs;
80
- }
81
- function splitVendorChunkPlugin() {
82
- const caches = [];
83
- function createSplitVendorChunk(output, config) {
84
- const cache = new SplitVendorChunkCache();
85
- caches.push(cache);
86
- const build = config.build ?? {};
87
- const format = output?.format;
88
- if (!build.ssr && !build.lib && format !== 'umd' && format !== 'iife') {
89
- return splitVendorChunk({ cache });
90
- }
91
- }
92
- return {
93
- name: 'vite:split-vendor-chunk',
94
- config(config) {
95
- let outputs = config?.build?.rollupOptions?.output;
96
- if (outputs) {
97
- outputs = Array.isArray(outputs) ? outputs : [outputs];
98
- for (const output of outputs) {
99
- const viteManualChunks = createSplitVendorChunk(output, config);
100
- if (viteManualChunks) {
101
- if (output.manualChunks) {
102
- if (typeof output.manualChunks === 'function') {
103
- const userManualChunks = output.manualChunks;
104
- output.manualChunks = (id, api) => {
105
- return userManualChunks(id, api) ?? viteManualChunks(id, api);
106
- };
107
- }
108
- // else, leave the object form of manualChunks untouched, as
109
- // we can't safely replicate rollup handling.
110
- }
111
- else {
112
- output.manualChunks = viteManualChunks;
113
- }
114
- }
115
- }
116
- }
117
- else {
118
- return {
119
- build: {
120
- rollupOptions: {
121
- output: {
122
- manualChunks: createSplitVendorChunk({}, config),
123
- },
124
- },
125
- },
126
- };
127
- }
128
- },
129
- buildStart() {
130
- caches.forEach((cache) => cache.reset());
131
- },
132
- };
133
- }
134
-
135
27
  const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
136
28
  const intToChar = new Uint8Array(64); // 64 possible chars.
137
29
  const charToInt = new Uint8Array(128); // z is 122 in ASCII
@@ -3404,15 +3296,15 @@ const forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(' '));
3404
3296
  forbiddenIdentifiers.add('');
3405
3297
 
3406
3298
  const createFilter = createFilter$1;
3299
+ const windowsSlashRE = /\\/g;
3407
3300
  function slash(p) {
3408
- return p.replace(/\\/g, '/');
3301
+ return p.replace(windowsSlashRE, '/');
3302
+ }
3303
+ function isInNodeModules(id) {
3304
+ return id.includes('node_modules');
3409
3305
  }
3410
3306
  // TODO: use import()
3411
3307
  const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)));
3412
- try {
3413
- Boolean(_require('pnpapi'));
3414
- }
3415
- catch { }
3416
3308
  // set in bin/vite.js
3417
3309
  const filter = process.env.VITE_DEBUG_FILTER;
3418
3310
  const DEBUG = process.env.DEBUG;
@@ -3448,22 +3340,12 @@ function normalizePath(id) {
3448
3340
  function isObject(value) {
3449
3341
  return Object.prototype.toString.call(value) === '[object Object]';
3450
3342
  }
3451
- function lookupFile(dir, formats, options) {
3452
- for (const format of formats) {
3453
- const fullPath = path$3.join(dir, format);
3454
- if (fs$1.existsSync(fullPath) && fs$1.statSync(fullPath).isFile()) {
3455
- const result = options?.pathOnly
3456
- ? fullPath
3457
- : fs$1.readFileSync(fullPath, 'utf-8');
3458
- if (!options?.predicate || options.predicate(result)) {
3459
- return result;
3460
- }
3461
- }
3343
+ function tryStatSync(file) {
3344
+ try {
3345
+ return fs$1.statSync(file, { throwIfNoEntry: false });
3462
3346
  }
3463
- const parentDir = path$3.dirname(dir);
3464
- if (parentDir !== dir &&
3465
- (!options?.rootDir || parentDir.startsWith(options?.rootDir))) {
3466
- return lookupFile(parentDir, formats, options);
3347
+ catch {
3348
+ // Ignore errors
3467
3349
  }
3468
3350
  }
3469
3351
  function isFileReadable(filename) {
@@ -3475,17 +3357,6 @@ function isFileReadable(filename) {
3475
3357
  return false;
3476
3358
  }
3477
3359
  }
3478
- isWindows
3479
- ? node_util.promisify(gracefulRemoveDir)
3480
- : function removeDirSync(dir) {
3481
- // when removing `.vite/deps`, if it doesn't exist, nodejs may also remove
3482
- // other directories within `.vite/`, including `.vite/deps_temp` (bug).
3483
- // workaround by checking for directory existence before removing for now.
3484
- if (fs$1.existsSync(dir)) {
3485
- fs$1.rmSync(dir, { recursive: true, force: true });
3486
- }
3487
- };
3488
- isWindows ? node_util.promisify(gracefulRename) : fs$1.renameSync;
3489
3360
  function arraify(target) {
3490
3361
  return Array.isArray(target) ? target : [target];
3491
3362
  }
@@ -3503,63 +3374,6 @@ const usingDynamicImport = typeof jest === 'undefined';
3503
3374
  usingDynamicImport
3504
3375
  ? new Function('file', 'return import(file)')
3505
3376
  : _require;
3506
- // Based on node-graceful-fs
3507
- // The ISC License
3508
- // Copyright (c) 2011-2022 Isaac Z. Schlueter, Ben Noordhuis, and Contributors
3509
- // https://github.com/isaacs/node-graceful-fs/blob/main/LICENSE
3510
- // On Windows, A/V software can lock the directory, causing this
3511
- // to fail with an EACCES or EPERM if the directory contains newly
3512
- // created files. The original tried for up to 60 seconds, we only
3513
- // wait for 5 seconds, as a longer time would be seen as an error
3514
- const GRACEFUL_RENAME_TIMEOUT = 5000;
3515
- function gracefulRename(from, to, cb) {
3516
- const start = Date.now();
3517
- let backoff = 0;
3518
- fs$1.rename(from, to, function CB(er) {
3519
- if (er &&
3520
- (er.code === 'EACCES' || er.code === 'EPERM') &&
3521
- Date.now() - start < GRACEFUL_RENAME_TIMEOUT) {
3522
- setTimeout(function () {
3523
- fs$1.stat(to, function (stater, st) {
3524
- if (stater && stater.code === 'ENOENT')
3525
- fs$1.rename(from, to, CB);
3526
- else
3527
- CB(er);
3528
- });
3529
- }, backoff);
3530
- if (backoff < 100)
3531
- backoff += 10;
3532
- return;
3533
- }
3534
- if (cb)
3535
- cb(er);
3536
- });
3537
- }
3538
- const GRACEFUL_REMOVE_DIR_TIMEOUT = 5000;
3539
- function gracefulRemoveDir(dir, cb) {
3540
- const start = Date.now();
3541
- let backoff = 0;
3542
- fs$1.rm(dir, { recursive: true }, function CB(er) {
3543
- if (er) {
3544
- if ((er.code === 'ENOTEMPTY' ||
3545
- er.code === 'EACCES' ||
3546
- er.code === 'EPERM') &&
3547
- Date.now() - start < GRACEFUL_REMOVE_DIR_TIMEOUT) {
3548
- setTimeout(function () {
3549
- fs$1.rm(dir, { recursive: true }, CB);
3550
- }, backoff);
3551
- if (backoff < 100)
3552
- backoff += 10;
3553
- return;
3554
- }
3555
- if (er.code === 'ENOENT') {
3556
- er = null;
3557
- }
3558
- }
3559
- if (cb)
3560
- cb(er);
3561
- });
3562
- }
3563
3377
  function mergeConfigRecursively(defaults, overrides, rootPath) {
3564
3378
  const merged = { ...defaults };
3565
3379
  for (const key in overrides) {
@@ -3626,8 +3440,8 @@ function normalizeAlias(o = []) {
3626
3440
  // work around https://github.com/rollup/plugins/issues/759
3627
3441
  function normalizeSingleAlias({ find, replacement, customResolver, }) {
3628
3442
  if (typeof find === 'string' &&
3629
- find.endsWith('/') &&
3630
- replacement.endsWith('/')) {
3443
+ find[find.length - 1] === '/' &&
3444
+ replacement[replacement.length - 1] === '/') {
3631
3445
  find = find.slice(0, find.length - 1);
3632
3446
  replacement = replacement.slice(0, replacement.length - 1);
3633
3447
  }
@@ -3641,6 +3455,113 @@ function normalizeSingleAlias({ find, replacement, customResolver, }) {
3641
3455
  return alias;
3642
3456
  }
3643
3457
 
3458
+ // This file will be built for both ESM and CJS. Avoid relying on other modules as possible.
3459
+ // copy from constants.ts
3460
+ const CSS_LANGS_RE =
3461
+ // eslint-disable-next-line regexp/no-unused-capturing-group
3462
+ /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
3463
+ const isCSSRequest = (request) => CSS_LANGS_RE.test(request);
3464
+ // Use splitVendorChunkPlugin() to get the same manualChunks strategy as Vite 2.7
3465
+ // We don't recommend using this strategy as a general solution moving forward
3466
+ // splitVendorChunk is a simple index/vendor strategy that was used in Vite
3467
+ // until v2.8. It is exposed to let people continue to use it in case it was
3468
+ // working well for their setups.
3469
+ // The cache needs to be reset on buildStart for watch mode to work correctly
3470
+ // Don't use this manualChunks strategy for ssr, lib mode, and 'umd' or 'iife'
3471
+ class SplitVendorChunkCache {
3472
+ constructor() {
3473
+ this.cache = new Map();
3474
+ }
3475
+ reset() {
3476
+ this.cache = new Map();
3477
+ }
3478
+ }
3479
+ function splitVendorChunk(options = {}) {
3480
+ const cache = options.cache ?? new SplitVendorChunkCache();
3481
+ return (id, { getModuleInfo }) => {
3482
+ if (isInNodeModules(id) &&
3483
+ !isCSSRequest(id) &&
3484
+ staticImportedByEntry(id, getModuleInfo, cache.cache)) {
3485
+ return 'vendor';
3486
+ }
3487
+ };
3488
+ }
3489
+ function staticImportedByEntry(id, getModuleInfo, cache, importStack = []) {
3490
+ if (cache.has(id)) {
3491
+ return cache.get(id);
3492
+ }
3493
+ if (importStack.includes(id)) {
3494
+ // circular deps!
3495
+ cache.set(id, false);
3496
+ return false;
3497
+ }
3498
+ const mod = getModuleInfo(id);
3499
+ if (!mod) {
3500
+ cache.set(id, false);
3501
+ return false;
3502
+ }
3503
+ if (mod.isEntry) {
3504
+ cache.set(id, true);
3505
+ return true;
3506
+ }
3507
+ const someImporterIs = mod.importers.some((importer) => staticImportedByEntry(importer, getModuleInfo, cache, importStack.concat(id)));
3508
+ cache.set(id, someImporterIs);
3509
+ return someImporterIs;
3510
+ }
3511
+ function splitVendorChunkPlugin() {
3512
+ const caches = [];
3513
+ function createSplitVendorChunk(output, config) {
3514
+ const cache = new SplitVendorChunkCache();
3515
+ caches.push(cache);
3516
+ const build = config.build ?? {};
3517
+ const format = output?.format;
3518
+ if (!build.ssr && !build.lib && format !== 'umd' && format !== 'iife') {
3519
+ return splitVendorChunk({ cache });
3520
+ }
3521
+ }
3522
+ return {
3523
+ name: 'vite:split-vendor-chunk',
3524
+ config(config) {
3525
+ let outputs = config?.build?.rollupOptions?.output;
3526
+ if (outputs) {
3527
+ outputs = Array.isArray(outputs) ? outputs : [outputs];
3528
+ for (const output of outputs) {
3529
+ const viteManualChunks = createSplitVendorChunk(output, config);
3530
+ if (viteManualChunks) {
3531
+ if (output.manualChunks) {
3532
+ if (typeof output.manualChunks === 'function') {
3533
+ const userManualChunks = output.manualChunks;
3534
+ output.manualChunks = (id, api) => {
3535
+ return userManualChunks(id, api) ?? viteManualChunks(id, api);
3536
+ };
3537
+ }
3538
+ // else, leave the object form of manualChunks untouched, as
3539
+ // we can't safely replicate rollup handling.
3540
+ }
3541
+ else {
3542
+ output.manualChunks = viteManualChunks;
3543
+ }
3544
+ }
3545
+ }
3546
+ }
3547
+ else {
3548
+ return {
3549
+ build: {
3550
+ rollupOptions: {
3551
+ output: {
3552
+ manualChunks: createSplitVendorChunk({}, config),
3553
+ },
3554
+ },
3555
+ },
3556
+ };
3557
+ }
3558
+ },
3559
+ buildStart() {
3560
+ caches.forEach((cache) => cache.reset());
3561
+ },
3562
+ };
3563
+ }
3564
+
3644
3565
  /*!
3645
3566
  * etag
3646
3567
  * Copyright(c) 2014-2016 Douglas Christopher Wilson
@@ -4256,13 +4177,10 @@ function loadEnv(mode, envDir, prefixes = 'VITE_') {
4256
4177
  /** mode local file */ `.env.${mode}.local`,
4257
4178
  ];
4258
4179
  const parsed = Object.fromEntries(envFiles.flatMap((file) => {
4259
- const path = lookupFile(envDir, [file], {
4260
- pathOnly: true,
4261
- rootDir: envDir,
4262
- });
4263
- if (!path)
4180
+ const filePath = path$3.join(envDir, file);
4181
+ if (!tryStatSync(filePath)?.isFile())
4264
4182
  return [];
4265
- return Object.entries(parse_1(fs$1.readFileSync(path)));
4183
+ return Object.entries(parse_1(fs$1.readFileSync(filePath)));
4266
4184
  }));
4267
4185
  // test NODE_ENV override before expand as otherwise process.env.NODE_ENV would override this
4268
4186
  if (parsed.NODE_ENV && process.env.VITE_USER_NODE_ENV === undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "4.2.1",
3
+ "version": "4.3.0-beta.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -69,15 +69,15 @@
69
69
  "esbuild": "^0.17.5",
70
70
  "postcss": "^8.4.21",
71
71
  "resolve": "^1.22.1",
72
- "rollup": "^3.18.0"
72
+ "rollup": "^3.20.0"
73
73
  },
74
74
  "optionalDependencies": {
75
75
  "fsevents": "~2.3.2"
76
76
  },
77
77
  "devDependencies": {
78
78
  "@ampproject/remapping": "^2.2.0",
79
- "@babel/parser": "^7.21.2",
80
- "@babel/types": "^7.21.2",
79
+ "@babel/parser": "^7.21.3",
80
+ "@babel/types": "^7.21.3",
81
81
  "@jridgewell/trace-mapping": "^0.3.17",
82
82
  "@rollup/plugin-alias": "^4.0.3",
83
83
  "@rollup/plugin-commonjs": "^24.0.1",
@@ -86,6 +86,7 @@
86
86
  "@rollup/plugin-node-resolve": "15.0.1",
87
87
  "@rollup/plugin-typescript": "^11.0.0",
88
88
  "@rollup/pluginutils": "^5.0.2",
89
+ "@types/pnpapi": "^0.0.2",
89
90
  "acorn": "^8.8.2",
90
91
  "acorn-walk": "^8.2.0",
91
92
  "cac": "^6.7.14",
@@ -108,7 +109,7 @@
108
109
  "launch-editor-middleware": "^2.6.0",
109
110
  "magic-string": "^0.30.0",
110
111
  "micromatch": "^4.0.5",
111
- "mlly": "^1.1.1",
112
+ "mlly": "^1.2.0",
112
113
  "mrmime": "^1.0.1",
113
114
  "okie": "^1.0.1",
114
115
  "open": "^8.4.2",
@@ -126,11 +127,11 @@
126
127
  "source-map-support": "^0.5.21",
127
128
  "strip-ansi": "^7.0.1",
128
129
  "strip-literal": "^1.0.1",
129
- "tsconfck": "^2.1.0",
130
+ "tsconfck": "^2.1.1",
130
131
  "tslib": "^2.5.0",
131
132
  "types": "link:./types",
132
133
  "ufo": "^1.1.1",
133
- "ws": "^8.12.1"
134
+ "ws": "^8.13.0"
134
135
  },
135
136
  "peerDependencies": {
136
137
  "@types/node": ">= 14",