vite 4.3.0-beta.0 → 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/chunks/{dep-be7bf3d1.js → dep-afd6d5c5.js} +1 -1
- package/dist/node/chunks/{dep-7f82b32e.js → dep-f365bad6.js} +798 -749
- package/dist/node/cli.js +8 -8
- package/dist/node/index.d.ts +23 -8
- package/dist/node/index.js +6 -5
- package/dist/node-cjs/publicUtils.cjs +118 -197
- package/package.json +1 -1
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 {
|
|
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:
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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,
|
package/dist/node/index.d.ts
CHANGED
|
@@ -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 }
|
|
@@ -1493,8 +1497,9 @@ declare interface Plugin_2 extends Plugin_3 {
|
|
|
1493
1497
|
*/
|
|
1494
1498
|
configureServer?: ObjectHook<ServerHook>;
|
|
1495
1499
|
/**
|
|
1496
|
-
* Configure the preview server. The hook receives the
|
|
1497
|
-
*
|
|
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.
|
|
1498
1503
|
*
|
|
1499
1504
|
* The hooks are called before other middlewares are applied. A hook can
|
|
1500
1505
|
* return a post hook that will be called after other middlewares are
|
|
@@ -1601,11 +1606,24 @@ export declare function preview(inlineConfig?: InlineConfig): Promise<PreviewSer
|
|
|
1601
1606
|
export declare interface PreviewOptions extends CommonServerOptions {
|
|
1602
1607
|
}
|
|
1603
1608
|
|
|
1604
|
-
export declare interface PreviewServer {
|
|
1609
|
+
export declare interface PreviewServer extends PreviewServerForHook {
|
|
1610
|
+
resolvedUrls: ResolvedServerUrls;
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
export declare interface PreviewServerForHook {
|
|
1605
1614
|
/**
|
|
1606
1615
|
* The resolved vite config object
|
|
1607
1616
|
*/
|
|
1608
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;
|
|
1609
1627
|
/**
|
|
1610
1628
|
* native Node http server instance
|
|
1611
1629
|
*/
|
|
@@ -1613,17 +1631,14 @@ export declare interface PreviewServer {
|
|
|
1613
1631
|
/**
|
|
1614
1632
|
* The resolved urls Vite prints on the CLI
|
|
1615
1633
|
*/
|
|
1616
|
-
resolvedUrls: ResolvedServerUrls;
|
|
1634
|
+
resolvedUrls: ResolvedServerUrls | null;
|
|
1617
1635
|
/**
|
|
1618
1636
|
* Print server urls
|
|
1619
1637
|
*/
|
|
1620
1638
|
printUrls(): void;
|
|
1621
1639
|
}
|
|
1622
1640
|
|
|
1623
|
-
export declare type PreviewServerHook = (this: void, server:
|
|
1624
|
-
middlewares: Connect.Server;
|
|
1625
|
-
httpServer: http.Server;
|
|
1626
|
-
}) => (() => void) | void | Promise<(() => void) | void>;
|
|
1641
|
+
export declare type PreviewServerHook = (this: void, server: PreviewServerForHook) => (() => void) | void | Promise<(() => void) | void>;
|
|
1627
1642
|
|
|
1628
1643
|
export declare interface ProxyOptions extends HttpProxy.ServerOptions {
|
|
1629
1644
|
/**
|
package/dist/node/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
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:
|
|
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
|
|
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
|
|
@@ -3408,6 +3300,9 @@ const windowsSlashRE = /\\/g;
|
|
|
3408
3300
|
function slash(p) {
|
|
3409
3301
|
return p.replace(windowsSlashRE, '/');
|
|
3410
3302
|
}
|
|
3303
|
+
function isInNodeModules(id) {
|
|
3304
|
+
return id.includes('node_modules');
|
|
3305
|
+
}
|
|
3411
3306
|
// TODO: use import()
|
|
3412
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)));
|
|
3413
3308
|
// set in bin/vite.js
|
|
@@ -3445,22 +3340,12 @@ function normalizePath(id) {
|
|
|
3445
3340
|
function isObject(value) {
|
|
3446
3341
|
return Object.prototype.toString.call(value) === '[object Object]';
|
|
3447
3342
|
}
|
|
3448
|
-
function
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
if (fs$1.existsSync(fullPath) && fs$1.statSync(fullPath).isFile()) {
|
|
3452
|
-
const result = options?.pathOnly
|
|
3453
|
-
? fullPath
|
|
3454
|
-
: fs$1.readFileSync(fullPath, 'utf-8');
|
|
3455
|
-
if (!options?.predicate || options.predicate(result)) {
|
|
3456
|
-
return result;
|
|
3457
|
-
}
|
|
3458
|
-
}
|
|
3343
|
+
function tryStatSync(file) {
|
|
3344
|
+
try {
|
|
3345
|
+
return fs$1.statSync(file, { throwIfNoEntry: false });
|
|
3459
3346
|
}
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
(!options?.rootDir || parentDir.startsWith(options?.rootDir))) {
|
|
3463
|
-
return lookupFile(parentDir, formats, options);
|
|
3347
|
+
catch {
|
|
3348
|
+
// Ignore errors
|
|
3464
3349
|
}
|
|
3465
3350
|
}
|
|
3466
3351
|
function isFileReadable(filename) {
|
|
@@ -3472,17 +3357,6 @@ function isFileReadable(filename) {
|
|
|
3472
3357
|
return false;
|
|
3473
3358
|
}
|
|
3474
3359
|
}
|
|
3475
|
-
isWindows
|
|
3476
|
-
? node_util.promisify(gracefulRemoveDir)
|
|
3477
|
-
: function removeDirSync(dir) {
|
|
3478
|
-
// when removing `.vite/deps`, if it doesn't exist, nodejs may also remove
|
|
3479
|
-
// other directories within `.vite/`, including `.vite/deps_temp` (bug).
|
|
3480
|
-
// workaround by checking for directory existence before removing for now.
|
|
3481
|
-
if (fs$1.existsSync(dir)) {
|
|
3482
|
-
fs$1.rmSync(dir, { recursive: true, force: true });
|
|
3483
|
-
}
|
|
3484
|
-
};
|
|
3485
|
-
isWindows ? node_util.promisify(gracefulRename) : fs$1.renameSync;
|
|
3486
3360
|
function arraify(target) {
|
|
3487
3361
|
return Array.isArray(target) ? target : [target];
|
|
3488
3362
|
}
|
|
@@ -3500,63 +3374,6 @@ const usingDynamicImport = typeof jest === 'undefined';
|
|
|
3500
3374
|
usingDynamicImport
|
|
3501
3375
|
? new Function('file', 'return import(file)')
|
|
3502
3376
|
: _require;
|
|
3503
|
-
// Based on node-graceful-fs
|
|
3504
|
-
// The ISC License
|
|
3505
|
-
// Copyright (c) 2011-2022 Isaac Z. Schlueter, Ben Noordhuis, and Contributors
|
|
3506
|
-
// https://github.com/isaacs/node-graceful-fs/blob/main/LICENSE
|
|
3507
|
-
// On Windows, A/V software can lock the directory, causing this
|
|
3508
|
-
// to fail with an EACCES or EPERM if the directory contains newly
|
|
3509
|
-
// created files. The original tried for up to 60 seconds, we only
|
|
3510
|
-
// wait for 5 seconds, as a longer time would be seen as an error
|
|
3511
|
-
const GRACEFUL_RENAME_TIMEOUT = 5000;
|
|
3512
|
-
function gracefulRename(from, to, cb) {
|
|
3513
|
-
const start = Date.now();
|
|
3514
|
-
let backoff = 0;
|
|
3515
|
-
fs$1.rename(from, to, function CB(er) {
|
|
3516
|
-
if (er &&
|
|
3517
|
-
(er.code === 'EACCES' || er.code === 'EPERM') &&
|
|
3518
|
-
Date.now() - start < GRACEFUL_RENAME_TIMEOUT) {
|
|
3519
|
-
setTimeout(function () {
|
|
3520
|
-
fs$1.stat(to, function (stater, st) {
|
|
3521
|
-
if (stater && stater.code === 'ENOENT')
|
|
3522
|
-
fs$1.rename(from, to, CB);
|
|
3523
|
-
else
|
|
3524
|
-
CB(er);
|
|
3525
|
-
});
|
|
3526
|
-
}, backoff);
|
|
3527
|
-
if (backoff < 100)
|
|
3528
|
-
backoff += 10;
|
|
3529
|
-
return;
|
|
3530
|
-
}
|
|
3531
|
-
if (cb)
|
|
3532
|
-
cb(er);
|
|
3533
|
-
});
|
|
3534
|
-
}
|
|
3535
|
-
const GRACEFUL_REMOVE_DIR_TIMEOUT = 5000;
|
|
3536
|
-
function gracefulRemoveDir(dir, cb) {
|
|
3537
|
-
const start = Date.now();
|
|
3538
|
-
let backoff = 0;
|
|
3539
|
-
fs$1.rm(dir, { recursive: true }, function CB(er) {
|
|
3540
|
-
if (er) {
|
|
3541
|
-
if ((er.code === 'ENOTEMPTY' ||
|
|
3542
|
-
er.code === 'EACCES' ||
|
|
3543
|
-
er.code === 'EPERM') &&
|
|
3544
|
-
Date.now() - start < GRACEFUL_REMOVE_DIR_TIMEOUT) {
|
|
3545
|
-
setTimeout(function () {
|
|
3546
|
-
fs$1.rm(dir, { recursive: true }, CB);
|
|
3547
|
-
}, backoff);
|
|
3548
|
-
if (backoff < 100)
|
|
3549
|
-
backoff += 10;
|
|
3550
|
-
return;
|
|
3551
|
-
}
|
|
3552
|
-
if (er.code === 'ENOENT') {
|
|
3553
|
-
er = null;
|
|
3554
|
-
}
|
|
3555
|
-
}
|
|
3556
|
-
if (cb)
|
|
3557
|
-
cb(er);
|
|
3558
|
-
});
|
|
3559
|
-
}
|
|
3560
3377
|
function mergeConfigRecursively(defaults, overrides, rootPath) {
|
|
3561
3378
|
const merged = { ...defaults };
|
|
3562
3379
|
for (const key in overrides) {
|
|
@@ -3638,6 +3455,113 @@ function normalizeSingleAlias({ find, replacement, customResolver, }) {
|
|
|
3638
3455
|
return alias;
|
|
3639
3456
|
}
|
|
3640
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
|
+
|
|
3641
3565
|
/*!
|
|
3642
3566
|
* etag
|
|
3643
3567
|
* Copyright(c) 2014-2016 Douglas Christopher Wilson
|
|
@@ -4253,13 +4177,10 @@ function loadEnv(mode, envDir, prefixes = 'VITE_') {
|
|
|
4253
4177
|
/** mode local file */ `.env.${mode}.local`,
|
|
4254
4178
|
];
|
|
4255
4179
|
const parsed = Object.fromEntries(envFiles.flatMap((file) => {
|
|
4256
|
-
const
|
|
4257
|
-
|
|
4258
|
-
rootDir: envDir,
|
|
4259
|
-
});
|
|
4260
|
-
if (!path)
|
|
4180
|
+
const filePath = path$3.join(envDir, file);
|
|
4181
|
+
if (!tryStatSync(filePath)?.isFile())
|
|
4261
4182
|
return [];
|
|
4262
|
-
return Object.entries(parse_1(fs$1.readFileSync(
|
|
4183
|
+
return Object.entries(parse_1(fs$1.readFileSync(filePath)));
|
|
4263
4184
|
}));
|
|
4264
4185
|
// test NODE_ENV override before expand as otherwise process.env.NODE_ENV would override this
|
|
4265
4186
|
if (parsed.NODE_ENV && process.env.VITE_USER_NODE_ENV === undefined) {
|