vite 6.0.0-alpha.2 → 6.0.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +112 -203
- package/client.d.ts +12 -0
- package/dist/client/client.mjs +614 -611
- package/dist/client/env.mjs +18 -24
- package/dist/node/chunks/{dep-DK04Q0H9.js → dep-B35KR9PC.js} +1 -1
- package/dist/node/chunks/{dep-DKZVy3_n.js → dep-BAOcN7N1.js} +165 -968
- package/dist/node/chunks/{dep-CrWVpuYf.js → dep-D-7KCb9p.js} +32 -2
- package/dist/node/chunks/{dep-E4cF1RpV.js → dep-D2vSWyBt.js} +37449 -39030
- package/dist/node/cli.js +260 -265
- package/dist/node/constants.js +108 -84
- package/dist/node/index.d.ts +2167 -2017
- package/dist/node/index.js +128 -258
- package/dist/node/module-runner.d.ts +33 -18
- package/dist/node/module-runner.js +275 -206
- package/dist/node-cjs/publicUtils.cjs +637 -657
- package/index.cjs +0 -2
- package/package.json +32 -29
- package/types/customEvent.d.ts +1 -0
- package/types/hmrPayload.d.ts +3 -1
- package/dist/client/client.mjs.map +0 -1
- package/dist/client/env.mjs.map +0 -1
@@ -14,17 +14,18 @@ var readline = require('node:readline');
|
|
14
14
|
var require$$2 = require('os');
|
15
15
|
|
16
16
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
17
|
-
const { version: version$2 } = JSON.parse(
|
17
|
+
const { version: version$2 } = JSON.parse(
|
18
|
+
fs$1.readFileSync(new URL("../../package.json", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)))).toString()
|
19
|
+
);
|
18
20
|
const VERSION = version$2;
|
19
|
-
/**
|
20
|
-
* Prefix for resolved fs paths, since windows paths may not be valid as URLs.
|
21
|
-
*/
|
22
21
|
const FS_PREFIX = `/@fs/`;
|
23
22
|
const VITE_PACKAGE_DIR = path$3.resolve(
|
24
|
-
// import.meta.url is `dist/node/constants.js` after bundle
|
25
|
-
node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href))),
|
26
|
-
|
27
|
-
|
23
|
+
// import.meta.url is `dist/node/constants.js` after bundle
|
24
|
+
node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href))),
|
25
|
+
"../../.."
|
26
|
+
);
|
27
|
+
const CLIENT_ENTRY = path$3.resolve(VITE_PACKAGE_DIR, "dist/client/client.mjs");
|
28
|
+
path$3.resolve(VITE_PACKAGE_DIR, "dist/client/env.mjs");
|
28
29
|
path$3.dirname(CLIENT_ENTRY);
|
29
30
|
|
30
31
|
const comma = ','.charCodeAt(0);
|
@@ -37,6 +38,20 @@ for (let i = 0; i < chars.length; i++) {
|
|
37
38
|
intToChar[i] = c;
|
38
39
|
charToInt[c] = i;
|
39
40
|
}
|
41
|
+
function encodeInteger(builder, num, relative) {
|
42
|
+
let delta = num - relative;
|
43
|
+
delta = delta < 0 ? (-delta << 1) | 1 : delta << 1;
|
44
|
+
do {
|
45
|
+
let clamped = delta & 0b011111;
|
46
|
+
delta >>>= 5;
|
47
|
+
if (delta > 0)
|
48
|
+
clamped |= 0b100000;
|
49
|
+
builder.write(intToChar[clamped]);
|
50
|
+
} while (delta > 0);
|
51
|
+
return num;
|
52
|
+
}
|
53
|
+
|
54
|
+
const bufLength = 1024 * 16;
|
40
55
|
// Provide a fallback for older environments.
|
41
56
|
const td = typeof TextDecoder !== 'undefined'
|
42
57
|
? /* #__PURE__ */ new TextDecoder()
|
@@ -56,80 +71,75 @@ const td = typeof TextDecoder !== 'undefined'
|
|
56
71
|
return out;
|
57
72
|
},
|
58
73
|
};
|
74
|
+
class StringWriter {
|
75
|
+
constructor() {
|
76
|
+
this.pos = 0;
|
77
|
+
this.out = '';
|
78
|
+
this.buffer = new Uint8Array(bufLength);
|
79
|
+
}
|
80
|
+
write(v) {
|
81
|
+
const { buffer } = this;
|
82
|
+
buffer[this.pos++] = v;
|
83
|
+
if (this.pos === bufLength) {
|
84
|
+
this.out += td.decode(buffer);
|
85
|
+
this.pos = 0;
|
86
|
+
}
|
87
|
+
}
|
88
|
+
flush() {
|
89
|
+
const { buffer, out, pos } = this;
|
90
|
+
return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
|
91
|
+
}
|
92
|
+
}
|
59
93
|
function encode(decoded) {
|
60
|
-
const
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
let pos = 0;
|
66
|
-
let out = '';
|
94
|
+
const writer = new StringWriter();
|
95
|
+
let sourcesIndex = 0;
|
96
|
+
let sourceLine = 0;
|
97
|
+
let sourceColumn = 0;
|
98
|
+
let namesIndex = 0;
|
67
99
|
for (let i = 0; i < decoded.length; i++) {
|
68
100
|
const line = decoded[i];
|
69
|
-
if (i > 0)
|
70
|
-
|
71
|
-
out += td.decode(buf);
|
72
|
-
pos = 0;
|
73
|
-
}
|
74
|
-
buf[pos++] = semicolon;
|
75
|
-
}
|
101
|
+
if (i > 0)
|
102
|
+
writer.write(semicolon);
|
76
103
|
if (line.length === 0)
|
77
104
|
continue;
|
78
|
-
|
105
|
+
let genColumn = 0;
|
79
106
|
for (let j = 0; j < line.length; j++) {
|
80
107
|
const segment = line[j];
|
81
|
-
// We can push up to 5 ints, each int can take at most 7 chars, and we
|
82
|
-
// may push a comma.
|
83
|
-
if (pos > subLength) {
|
84
|
-
out += td.decode(sub);
|
85
|
-
buf.copyWithin(0, subLength, pos);
|
86
|
-
pos -= subLength;
|
87
|
-
}
|
88
108
|
if (j > 0)
|
89
|
-
|
90
|
-
|
109
|
+
writer.write(comma);
|
110
|
+
genColumn = encodeInteger(writer, segment[0], genColumn);
|
91
111
|
if (segment.length === 1)
|
92
112
|
continue;
|
93
|
-
|
94
|
-
|
95
|
-
|
113
|
+
sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
|
114
|
+
sourceLine = encodeInteger(writer, segment[2], sourceLine);
|
115
|
+
sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
|
96
116
|
if (segment.length === 4)
|
97
117
|
continue;
|
98
|
-
|
118
|
+
namesIndex = encodeInteger(writer, segment[4], namesIndex);
|
99
119
|
}
|
100
120
|
}
|
101
|
-
return
|
102
|
-
}
|
103
|
-
function encodeInteger(buf, pos, state, segment, j) {
|
104
|
-
const next = segment[j];
|
105
|
-
let num = next - state[j];
|
106
|
-
state[j] = next;
|
107
|
-
num = num < 0 ? (-num << 1) | 1 : num << 1;
|
108
|
-
do {
|
109
|
-
let clamped = num & 0b011111;
|
110
|
-
num >>>= 5;
|
111
|
-
if (num > 0)
|
112
|
-
clamped |= 0b100000;
|
113
|
-
buf[pos++] = intToChar[clamped];
|
114
|
-
} while (num > 0);
|
115
|
-
return pos;
|
121
|
+
return writer.flush();
|
116
122
|
}
|
117
123
|
|
118
124
|
function getDefaultExportFromCjs (x) {
|
119
125
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
120
126
|
}
|
121
127
|
|
122
|
-
|
128
|
+
function commonjsRequire(path) {
|
129
|
+
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
130
|
+
}
|
123
131
|
|
124
|
-
|
132
|
+
var picocolors = {exports: {}};
|
125
133
|
|
134
|
+
let argv = process.argv || [],
|
135
|
+
env = process.env;
|
126
136
|
let isColorSupported =
|
127
|
-
!("NO_COLOR" in
|
128
|
-
("FORCE_COLOR" in
|
129
|
-
|
137
|
+
!("NO_COLOR" in env || argv.includes("--no-color")) &&
|
138
|
+
("FORCE_COLOR" in env ||
|
139
|
+
argv.includes("--color") ||
|
130
140
|
process.platform === "win32" ||
|
131
|
-
(
|
132
|
-
"CI" in
|
141
|
+
(commonjsRequire != null && require$$0.isatty(1) && env.TERM !== "dumb") ||
|
142
|
+
"CI" in env);
|
133
143
|
|
134
144
|
let formatter =
|
135
145
|
(open, close, replace = open) =>
|
@@ -142,40 +152,47 @@ let formatter =
|
|
142
152
|
};
|
143
153
|
|
144
154
|
let replaceClose = (string, close, replace, index) => {
|
145
|
-
let
|
146
|
-
let
|
147
|
-
|
148
|
-
|
155
|
+
let result = "";
|
156
|
+
let cursor = 0;
|
157
|
+
do {
|
158
|
+
result += string.substring(cursor, index) + replace;
|
159
|
+
cursor = index + close.length;
|
160
|
+
index = string.indexOf(close, cursor);
|
161
|
+
} while (~index)
|
162
|
+
return result + string.substring(cursor)
|
149
163
|
};
|
150
164
|
|
151
|
-
let createColors = (enabled = isColorSupported) =>
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
165
|
+
let createColors = (enabled = isColorSupported) => {
|
166
|
+
let init = enabled ? formatter : () => String;
|
167
|
+
return {
|
168
|
+
isColorSupported: enabled,
|
169
|
+
reset: init("\x1b[0m", "\x1b[0m"),
|
170
|
+
bold: init("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
|
171
|
+
dim: init("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
|
172
|
+
italic: init("\x1b[3m", "\x1b[23m"),
|
173
|
+
underline: init("\x1b[4m", "\x1b[24m"),
|
174
|
+
inverse: init("\x1b[7m", "\x1b[27m"),
|
175
|
+
hidden: init("\x1b[8m", "\x1b[28m"),
|
176
|
+
strikethrough: init("\x1b[9m", "\x1b[29m"),
|
177
|
+
black: init("\x1b[30m", "\x1b[39m"),
|
178
|
+
red: init("\x1b[31m", "\x1b[39m"),
|
179
|
+
green: init("\x1b[32m", "\x1b[39m"),
|
180
|
+
yellow: init("\x1b[33m", "\x1b[39m"),
|
181
|
+
blue: init("\x1b[34m", "\x1b[39m"),
|
182
|
+
magenta: init("\x1b[35m", "\x1b[39m"),
|
183
|
+
cyan: init("\x1b[36m", "\x1b[39m"),
|
184
|
+
white: init("\x1b[37m", "\x1b[39m"),
|
185
|
+
gray: init("\x1b[90m", "\x1b[39m"),
|
186
|
+
bgBlack: init("\x1b[40m", "\x1b[49m"),
|
187
|
+
bgRed: init("\x1b[41m", "\x1b[49m"),
|
188
|
+
bgGreen: init("\x1b[42m", "\x1b[49m"),
|
189
|
+
bgYellow: init("\x1b[43m", "\x1b[49m"),
|
190
|
+
bgBlue: init("\x1b[44m", "\x1b[49m"),
|
191
|
+
bgMagenta: init("\x1b[45m", "\x1b[49m"),
|
192
|
+
bgCyan: init("\x1b[46m", "\x1b[49m"),
|
193
|
+
bgWhite: init("\x1b[47m", "\x1b[49m"),
|
194
|
+
}
|
195
|
+
};
|
179
196
|
|
180
197
|
picocolors.exports = createColors();
|
181
198
|
picocolors.exports.createColors = createColors;
|
@@ -773,6 +790,8 @@ function requireBrowser () {
|
|
773
790
|
return false;
|
774
791
|
}
|
775
792
|
|
793
|
+
let m;
|
794
|
+
|
776
795
|
// Is webkit? http://stackoverflow.com/a/16459606/376773
|
777
796
|
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
778
797
|
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
@@ -780,7 +799,7 @@ function requireBrowser () {
|
|
780
799
|
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
781
800
|
// Is firefox >= v31?
|
782
801
|
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
783
|
-
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(
|
802
|
+
(typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
|
784
803
|
// Double check webkit in userAgent just in case we are in a worker
|
785
804
|
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
786
805
|
}
|
@@ -1116,11 +1135,11 @@ function requireNode () {
|
|
1116
1135
|
}
|
1117
1136
|
|
1118
1137
|
/**
|
1119
|
-
* Invokes `util.
|
1138
|
+
* Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
|
1120
1139
|
*/
|
1121
1140
|
|
1122
1141
|
function log(...args) {
|
1123
|
-
return process.stderr.write(util.
|
1142
|
+
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
|
1124
1143
|
}
|
1125
1144
|
|
1126
1145
|
/**
|
@@ -3342,363 +3361,320 @@ const builtins = 'arguments Infinity NaN undefined null true false eval uneval i
|
|
3342
3361
|
const forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(' '));
|
3343
3362
|
forbiddenIdentifiers.add('');
|
3344
3363
|
|
3345
|
-
const isWindows = typeof process !==
|
3364
|
+
const isWindows = typeof process !== "undefined" && process.platform === "win32";
|
3346
3365
|
const windowsSlashRE = /\\/g;
|
3347
3366
|
function slash(p) {
|
3348
|
-
|
3367
|
+
return p.replace(windowsSlashRE, "/");
|
3349
3368
|
}
|
3350
3369
|
const postfixRE = /[?#].*$/;
|
3351
3370
|
function cleanUrl(url) {
|
3352
|
-
|
3371
|
+
return url.replace(postfixRE, "");
|
3353
3372
|
}
|
3354
3373
|
function withTrailingSlash(path) {
|
3355
|
-
|
3356
|
-
|
3357
|
-
|
3358
|
-
|
3374
|
+
if (path[path.length - 1] !== "/") {
|
3375
|
+
return `${path}/`;
|
3376
|
+
}
|
3377
|
+
return path;
|
3359
3378
|
}
|
3360
3379
|
|
3361
3380
|
if (process.versions.pnp) {
|
3362
|
-
|
3363
|
-
|
3364
|
-
|
3365
|
-
|
3381
|
+
try {
|
3382
|
+
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");
|
3383
|
+
} catch {
|
3384
|
+
}
|
3366
3385
|
}
|
3367
3386
|
|
3368
3387
|
const createFilter = createFilter$1;
|
3369
|
-
|
3370
|
-
node_module.builtinModules.filter((id) => !id.includes(':'));
|
3388
|
+
node_module.builtinModules.filter((id) => !id.includes(":"));
|
3371
3389
|
function isInNodeModules(id) {
|
3372
|
-
|
3390
|
+
return id.includes("node_modules");
|
3373
3391
|
}
|
3374
|
-
// TODO: use import()
|
3375
3392
|
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)));
|
3376
|
-
function resolveDependencyVersion(dep, pkgRelativePath =
|
3377
|
-
|
3378
|
-
|
3393
|
+
function resolveDependencyVersion(dep, pkgRelativePath = "../../package.json") {
|
3394
|
+
const pkgPath = path$3.resolve(_require.resolve(dep), pkgRelativePath);
|
3395
|
+
return JSON.parse(fs$1.readFileSync(pkgPath, "utf-8")).version;
|
3379
3396
|
}
|
3380
|
-
const rollupVersion = resolveDependencyVersion(
|
3381
|
-
// set in bin/vite.js
|
3397
|
+
const rollupVersion = resolveDependencyVersion("rollup");
|
3382
3398
|
const filter = process.env.VITE_DEBUG_FILTER;
|
3383
3399
|
const DEBUG = process.env.DEBUG;
|
3384
3400
|
function createDebugger(namespace, options = {}) {
|
3385
|
-
|
3386
|
-
|
3387
|
-
|
3388
|
-
|
3389
|
-
|
3390
|
-
|
3391
|
-
|
3392
|
-
|
3393
|
-
|
3394
|
-
|
3395
|
-
|
3396
|
-
|
3397
|
-
|
3398
|
-
|
3401
|
+
const log = debug$2(namespace);
|
3402
|
+
const { onlyWhenFocused } = options;
|
3403
|
+
let enabled = log.enabled;
|
3404
|
+
if (enabled && onlyWhenFocused) {
|
3405
|
+
const ns = typeof onlyWhenFocused === "string" ? onlyWhenFocused : namespace;
|
3406
|
+
enabled = !!DEBUG?.includes(ns);
|
3407
|
+
}
|
3408
|
+
if (enabled) {
|
3409
|
+
return (...args) => {
|
3410
|
+
if (!filter || args.some((a) => a?.includes?.(filter))) {
|
3411
|
+
log(...args);
|
3412
|
+
}
|
3413
|
+
};
|
3414
|
+
}
|
3399
3415
|
}
|
3400
3416
|
function testCaseInsensitiveFS() {
|
3401
|
-
|
3402
|
-
|
3403
|
-
|
3404
|
-
|
3405
|
-
|
3406
|
-
|
3407
|
-
|
3408
|
-
|
3417
|
+
if (!CLIENT_ENTRY.endsWith("client.mjs")) {
|
3418
|
+
throw new Error(
|
3419
|
+
`cannot test case insensitive FS, CLIENT_ENTRY const doesn't contain client.mjs`
|
3420
|
+
);
|
3421
|
+
}
|
3422
|
+
if (!fs$1.existsSync(CLIENT_ENTRY)) {
|
3423
|
+
throw new Error(
|
3424
|
+
"cannot test case insensitive FS, CLIENT_ENTRY does not point to an existing file: " + CLIENT_ENTRY
|
3425
|
+
);
|
3426
|
+
}
|
3427
|
+
return fs$1.existsSync(CLIENT_ENTRY.replace("client.mjs", "cLiEnT.mjs"));
|
3409
3428
|
}
|
3410
3429
|
const isCaseInsensitiveFS = testCaseInsensitiveFS();
|
3411
3430
|
const VOLUME_RE = /^[A-Z]:/i;
|
3412
3431
|
function normalizePath(id) {
|
3413
|
-
|
3432
|
+
return path$3.posix.normalize(isWindows ? slash(id) : id);
|
3414
3433
|
}
|
3415
3434
|
function fsPathFromId(id) {
|
3416
|
-
|
3417
|
-
|
3435
|
+
const fsPath = normalizePath(
|
3436
|
+
id.startsWith(FS_PREFIX) ? id.slice(FS_PREFIX.length) : id
|
3437
|
+
);
|
3438
|
+
return fsPath[0] === "/" || VOLUME_RE.test(fsPath) ? fsPath : `/${fsPath}`;
|
3418
3439
|
}
|
3419
3440
|
function fsPathFromUrl(url) {
|
3420
|
-
|
3441
|
+
return fsPathFromId(cleanUrl(url));
|
3421
3442
|
}
|
3422
|
-
/**
|
3423
|
-
* Check if dir is a parent of file
|
3424
|
-
*
|
3425
|
-
* Warning: parameters are not validated, only works with normalized absolute paths
|
3426
|
-
*
|
3427
|
-
* @param dir - normalized absolute path
|
3428
|
-
* @param file - normalized absolute path
|
3429
|
-
* @returns true if dir is a parent of file
|
3430
|
-
*/
|
3431
3443
|
function isParentDirectory(dir, file) {
|
3432
|
-
|
3433
|
-
|
3434
|
-
(isCaseInsensitiveFS && file.toLowerCase().startsWith(dir.toLowerCase())));
|
3444
|
+
dir = withTrailingSlash(dir);
|
3445
|
+
return file.startsWith(dir) || isCaseInsensitiveFS && file.toLowerCase().startsWith(dir.toLowerCase());
|
3435
3446
|
}
|
3436
|
-
/**
|
3437
|
-
* Check if 2 file name are identical
|
3438
|
-
*
|
3439
|
-
* Warning: parameters are not validated, only works with normalized absolute paths
|
3440
|
-
*
|
3441
|
-
* @param file1 - normalized absolute path
|
3442
|
-
* @param file2 - normalized absolute path
|
3443
|
-
* @returns true if both files url are identical
|
3444
|
-
*/
|
3445
3447
|
function isSameFileUri(file1, file2) {
|
3446
|
-
|
3447
|
-
(isCaseInsensitiveFS && file1.toLowerCase() === file2.toLowerCase()));
|
3448
|
+
return file1 === file2 || isCaseInsensitiveFS && file1.toLowerCase() === file2.toLowerCase();
|
3448
3449
|
}
|
3449
3450
|
const trailingSeparatorRE = /[?&]$/;
|
3450
3451
|
const timestampRE = /\bt=\d{13}&?\b/;
|
3451
3452
|
function removeTimestampQuery(url) {
|
3452
|
-
|
3453
|
+
return url.replace(timestampRE, "").replace(trailingSeparatorRE, "");
|
3453
3454
|
}
|
3454
3455
|
function isObject$1(value) {
|
3455
|
-
|
3456
|
+
return Object.prototype.toString.call(value) === "[object Object]";
|
3456
3457
|
}
|
3457
3458
|
function tryStatSync(file) {
|
3458
|
-
|
3459
|
-
|
3460
|
-
|
3461
|
-
|
3462
|
-
catch {
|
3463
|
-
// Ignore errors
|
3464
|
-
}
|
3459
|
+
try {
|
3460
|
+
return fs$1.statSync(file, { throwIfNoEntry: false });
|
3461
|
+
} catch {
|
3462
|
+
}
|
3465
3463
|
}
|
3466
3464
|
function isFileReadable(filename) {
|
3467
|
-
|
3468
|
-
|
3469
|
-
|
3470
|
-
|
3471
|
-
|
3472
|
-
|
3473
|
-
|
3474
|
-
|
3475
|
-
|
3476
|
-
return false;
|
3477
|
-
}
|
3465
|
+
if (!tryStatSync(filename)) {
|
3466
|
+
return false;
|
3467
|
+
}
|
3468
|
+
try {
|
3469
|
+
fs$1.accessSync(filename, fs$1.constants.R_OK);
|
3470
|
+
return true;
|
3471
|
+
} catch {
|
3472
|
+
return false;
|
3473
|
+
}
|
3478
3474
|
}
|
3479
3475
|
function arraify(target) {
|
3480
|
-
|
3476
|
+
return Array.isArray(target) ? target : [target];
|
3481
3477
|
}
|
3482
3478
|
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))));
|
3483
3479
|
function backwardCompatibleWorkerPlugins(plugins) {
|
3484
|
-
|
3485
|
-
|
3486
|
-
|
3487
|
-
|
3488
|
-
|
3489
|
-
|
3490
|
-
|
3480
|
+
if (Array.isArray(plugins)) {
|
3481
|
+
return plugins;
|
3482
|
+
}
|
3483
|
+
if (typeof plugins === "function") {
|
3484
|
+
return plugins();
|
3485
|
+
}
|
3486
|
+
return [];
|
3491
3487
|
}
|
3492
3488
|
function mergeConfigRecursively(defaults, overrides, rootPath) {
|
3493
|
-
|
3494
|
-
|
3495
|
-
|
3496
|
-
|
3497
|
-
|
3498
|
-
|
3499
|
-
|
3500
|
-
|
3501
|
-
|
3502
|
-
|
3503
|
-
}
|
3504
|
-
// fields that require special handling
|
3505
|
-
if (key === 'alias' && (rootPath === 'resolve' || rootPath === '')) {
|
3506
|
-
merged[key] = mergeAlias(existing, value);
|
3507
|
-
continue;
|
3508
|
-
}
|
3509
|
-
else if (key === 'assetsInclude' && rootPath === '') {
|
3510
|
-
merged[key] = [].concat(existing, value);
|
3511
|
-
continue;
|
3512
|
-
}
|
3513
|
-
else if (key === 'noExternal' && // TODO: environments
|
3514
|
-
rootPath === 'ssr' &&
|
3515
|
-
(existing === true || value === true)) {
|
3516
|
-
merged[key] = true;
|
3517
|
-
continue;
|
3518
|
-
}
|
3519
|
-
else if (key === 'plugins' && rootPath === 'worker') {
|
3520
|
-
merged[key] = () => [
|
3521
|
-
...backwardCompatibleWorkerPlugins(existing),
|
3522
|
-
...backwardCompatibleWorkerPlugins(value),
|
3523
|
-
];
|
3524
|
-
continue;
|
3525
|
-
}
|
3526
|
-
if (Array.isArray(existing) || Array.isArray(value)) {
|
3527
|
-
merged[key] = [...arraify(existing), ...arraify(value)];
|
3528
|
-
continue;
|
3529
|
-
}
|
3530
|
-
if (isObject$1(existing) && isObject$1(value)) {
|
3531
|
-
merged[key] = mergeConfigRecursively(existing, value, rootPath ? `${rootPath}.${key}` : key);
|
3532
|
-
continue;
|
3533
|
-
}
|
3534
|
-
merged[key] = value;
|
3489
|
+
const merged = { ...defaults };
|
3490
|
+
for (const key in overrides) {
|
3491
|
+
const value = overrides[key];
|
3492
|
+
if (value == null) {
|
3493
|
+
continue;
|
3494
|
+
}
|
3495
|
+
const existing = merged[key];
|
3496
|
+
if (existing == null) {
|
3497
|
+
merged[key] = value;
|
3498
|
+
continue;
|
3535
3499
|
}
|
3536
|
-
|
3500
|
+
if (key === "alias" && (rootPath === "resolve" || rootPath === "")) {
|
3501
|
+
merged[key] = mergeAlias(existing, value);
|
3502
|
+
continue;
|
3503
|
+
} else if (key === "assetsInclude" && rootPath === "") {
|
3504
|
+
merged[key] = [].concat(existing, value);
|
3505
|
+
continue;
|
3506
|
+
} else if (key === "noExternal" && (rootPath === "ssr" || rootPath === "resolve") && (existing === true || value === true)) {
|
3507
|
+
merged[key] = true;
|
3508
|
+
continue;
|
3509
|
+
} else if (key === "plugins" && rootPath === "worker") {
|
3510
|
+
merged[key] = () => [
|
3511
|
+
...backwardCompatibleWorkerPlugins(existing),
|
3512
|
+
...backwardCompatibleWorkerPlugins(value)
|
3513
|
+
];
|
3514
|
+
continue;
|
3515
|
+
} else if (key === "server" && rootPath === "server.hmr") {
|
3516
|
+
merged[key] = value;
|
3517
|
+
continue;
|
3518
|
+
}
|
3519
|
+
if (Array.isArray(existing) || Array.isArray(value)) {
|
3520
|
+
merged[key] = [...arraify(existing), ...arraify(value)];
|
3521
|
+
continue;
|
3522
|
+
}
|
3523
|
+
if (isObject$1(existing) && isObject$1(value)) {
|
3524
|
+
merged[key] = mergeConfigRecursively(
|
3525
|
+
existing,
|
3526
|
+
value,
|
3527
|
+
rootPath ? `${rootPath}.${key}` : key
|
3528
|
+
);
|
3529
|
+
continue;
|
3530
|
+
}
|
3531
|
+
merged[key] = value;
|
3532
|
+
}
|
3533
|
+
return merged;
|
3537
3534
|
}
|
3538
3535
|
function mergeConfig(defaults, overrides, isRoot = true) {
|
3539
|
-
|
3540
|
-
|
3541
|
-
|
3542
|
-
|
3536
|
+
if (typeof defaults === "function" || typeof overrides === "function") {
|
3537
|
+
throw new Error(`Cannot merge config in form of callback`);
|
3538
|
+
}
|
3539
|
+
return mergeConfigRecursively(defaults, overrides, isRoot ? "" : ".");
|
3543
3540
|
}
|
3544
3541
|
function mergeAlias(a, b) {
|
3545
|
-
|
3546
|
-
|
3547
|
-
|
3548
|
-
|
3549
|
-
|
3550
|
-
|
3551
|
-
}
|
3552
|
-
// the order is flipped because the alias is resolved from top-down,
|
3553
|
-
// where the later should have higher priority
|
3554
|
-
return [...normalizeAlias(b), ...normalizeAlias(a)];
|
3542
|
+
if (!a) return b;
|
3543
|
+
if (!b) return a;
|
3544
|
+
if (isObject$1(a) && isObject$1(b)) {
|
3545
|
+
return { ...a, ...b };
|
3546
|
+
}
|
3547
|
+
return [...normalizeAlias(b), ...normalizeAlias(a)];
|
3555
3548
|
}
|
3556
3549
|
function normalizeAlias(o = []) {
|
3557
|
-
|
3558
|
-
|
3559
|
-
|
3560
|
-
|
3561
|
-
|
3562
|
-
|
3550
|
+
return Array.isArray(o) ? o.map(normalizeSingleAlias) : Object.keys(o).map(
|
3551
|
+
(find) => normalizeSingleAlias({
|
3552
|
+
find,
|
3553
|
+
replacement: o[find]
|
3554
|
+
})
|
3555
|
+
);
|
3563
3556
|
}
|
3564
|
-
|
3565
|
-
|
3566
|
-
|
3567
|
-
|
3568
|
-
|
3569
|
-
|
3570
|
-
|
3571
|
-
|
3572
|
-
|
3573
|
-
|
3574
|
-
|
3575
|
-
|
3576
|
-
|
3577
|
-
|
3578
|
-
|
3579
|
-
|
3580
|
-
|
3557
|
+
function normalizeSingleAlias({
|
3558
|
+
find,
|
3559
|
+
replacement,
|
3560
|
+
customResolver
|
3561
|
+
}) {
|
3562
|
+
if (typeof find === "string" && find[find.length - 1] === "/" && replacement[replacement.length - 1] === "/") {
|
3563
|
+
find = find.slice(0, find.length - 1);
|
3564
|
+
replacement = replacement.slice(0, replacement.length - 1);
|
3565
|
+
}
|
3566
|
+
const alias = {
|
3567
|
+
find,
|
3568
|
+
replacement
|
3569
|
+
};
|
3570
|
+
if (customResolver) {
|
3571
|
+
alias.customResolver = customResolver;
|
3572
|
+
}
|
3573
|
+
return alias;
|
3581
3574
|
}
|
3582
3575
|
|
3583
|
-
|
3584
|
-
//
|
3585
|
-
|
3586
|
-
|
3587
|
-
/\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
3576
|
+
const CSS_LANGS_RE = (
|
3577
|
+
// eslint-disable-next-line regexp/no-unused-capturing-group
|
3578
|
+
/\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/
|
3579
|
+
);
|
3588
3580
|
const isCSSRequest = (request) => CSS_LANGS_RE.test(request);
|
3589
|
-
// Use splitVendorChunkPlugin() to get the same manualChunks strategy as Vite 2.7
|
3590
|
-
// We don't recommend using this strategy as a general solution moving forward
|
3591
|
-
// splitVendorChunk is a simple index/vendor strategy that was used in Vite
|
3592
|
-
// until v2.8. It is exposed to let people continue to use it in case it was
|
3593
|
-
// working well for their setups.
|
3594
|
-
// The cache needs to be reset on buildStart for watch mode to work correctly
|
3595
|
-
// Don't use this manualChunks strategy for ssr, lib mode, and 'umd' or 'iife'
|
3596
|
-
/**
|
3597
|
-
* @deprecated use build.rollupOutput.manualChunks or framework specific configuration
|
3598
|
-
*/
|
3599
3581
|
class SplitVendorChunkCache {
|
3600
|
-
|
3601
|
-
|
3602
|
-
|
3603
|
-
|
3604
|
-
|
3605
|
-
|
3606
|
-
|
3582
|
+
cache;
|
3583
|
+
constructor() {
|
3584
|
+
this.cache = /* @__PURE__ */ new Map();
|
3585
|
+
}
|
3586
|
+
reset() {
|
3587
|
+
this.cache = /* @__PURE__ */ new Map();
|
3588
|
+
}
|
3607
3589
|
}
|
3608
|
-
/**
|
3609
|
-
* @deprecated use build.rollupOutput.manualChunks or framework specific configuration
|
3610
|
-
*/
|
3611
3590
|
function splitVendorChunk(options = {}) {
|
3612
|
-
|
3613
|
-
|
3614
|
-
|
3615
|
-
|
3616
|
-
|
3617
|
-
|
3618
|
-
}
|
3619
|
-
};
|
3591
|
+
const cache = options.cache ?? new SplitVendorChunkCache();
|
3592
|
+
return (id, { getModuleInfo }) => {
|
3593
|
+
if (isInNodeModules(id) && !isCSSRequest(id) && staticImportedByEntry(id, getModuleInfo, cache.cache)) {
|
3594
|
+
return "vendor";
|
3595
|
+
}
|
3596
|
+
};
|
3620
3597
|
}
|
3621
3598
|
function staticImportedByEntry(id, getModuleInfo, cache, importStack = []) {
|
3622
|
-
|
3623
|
-
|
3624
|
-
|
3625
|
-
|
3626
|
-
|
3627
|
-
|
3628
|
-
|
3629
|
-
|
3630
|
-
|
3631
|
-
|
3632
|
-
|
3633
|
-
|
3634
|
-
|
3635
|
-
|
3636
|
-
|
3637
|
-
|
3638
|
-
|
3639
|
-
|
3640
|
-
|
3641
|
-
|
3599
|
+
if (cache.has(id)) {
|
3600
|
+
return cache.get(id);
|
3601
|
+
}
|
3602
|
+
if (importStack.includes(id)) {
|
3603
|
+
cache.set(id, false);
|
3604
|
+
return false;
|
3605
|
+
}
|
3606
|
+
const mod = getModuleInfo(id);
|
3607
|
+
if (!mod) {
|
3608
|
+
cache.set(id, false);
|
3609
|
+
return false;
|
3610
|
+
}
|
3611
|
+
if (mod.isEntry) {
|
3612
|
+
cache.set(id, true);
|
3613
|
+
return true;
|
3614
|
+
}
|
3615
|
+
const someImporterIs = mod.importers.some(
|
3616
|
+
(importer) => staticImportedByEntry(
|
3617
|
+
importer,
|
3618
|
+
getModuleInfo,
|
3619
|
+
cache,
|
3620
|
+
importStack.concat(id)
|
3621
|
+
)
|
3622
|
+
);
|
3623
|
+
cache.set(id, someImporterIs);
|
3624
|
+
return someImporterIs;
|
3642
3625
|
}
|
3643
|
-
/**
|
3644
|
-
* @deprecated use build.rollupOutput.manualChunks or framework specific configuration
|
3645
|
-
*/
|
3646
3626
|
function splitVendorChunkPlugin() {
|
3647
|
-
|
3648
|
-
|
3649
|
-
|
3650
|
-
|
3651
|
-
|
3652
|
-
|
3653
|
-
|
3654
|
-
|
3655
|
-
}
|
3627
|
+
const caches = [];
|
3628
|
+
function createSplitVendorChunk(output, config) {
|
3629
|
+
const cache = new SplitVendorChunkCache();
|
3630
|
+
caches.push(cache);
|
3631
|
+
const build = config.build ?? {};
|
3632
|
+
const format = output?.format;
|
3633
|
+
if (!build.ssr && !build.lib && format !== "umd" && format !== "iife") {
|
3634
|
+
return splitVendorChunk({ cache });
|
3656
3635
|
}
|
3657
|
-
|
3658
|
-
|
3659
|
-
|
3660
|
-
|
3661
|
-
|
3662
|
-
|
3663
|
-
|
3664
|
-
|
3665
|
-
|
3666
|
-
|
3667
|
-
|
3668
|
-
|
3669
|
-
|
3670
|
-
|
3671
|
-
|
3672
|
-
}
|
3673
|
-
else {
|
3674
|
-
// else, leave the object form of manualChunks untouched, as
|
3675
|
-
// we can't safely replicate rollup handling.
|
3676
|
-
// eslint-disable-next-line no-console
|
3677
|
-
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.");
|
3678
|
-
}
|
3679
|
-
}
|
3680
|
-
else {
|
3681
|
-
output.manualChunks = viteManualChunks;
|
3682
|
-
}
|
3683
|
-
}
|
3684
|
-
}
|
3685
|
-
}
|
3686
|
-
else {
|
3687
|
-
return {
|
3688
|
-
build: {
|
3689
|
-
rollupOptions: {
|
3690
|
-
output: {
|
3691
|
-
manualChunks: createSplitVendorChunk({}, config),
|
3692
|
-
},
|
3693
|
-
},
|
3694
|
-
},
|
3636
|
+
}
|
3637
|
+
return {
|
3638
|
+
name: "vite:split-vendor-chunk",
|
3639
|
+
config(config) {
|
3640
|
+
let outputs = config?.build?.rollupOptions?.output;
|
3641
|
+
if (outputs) {
|
3642
|
+
outputs = arraify(outputs);
|
3643
|
+
for (const output of outputs) {
|
3644
|
+
const viteManualChunks = createSplitVendorChunk(output, config);
|
3645
|
+
if (viteManualChunks) {
|
3646
|
+
if (output.manualChunks) {
|
3647
|
+
if (typeof output.manualChunks === "function") {
|
3648
|
+
const userManualChunks = output.manualChunks;
|
3649
|
+
output.manualChunks = (id, api) => {
|
3650
|
+
return userManualChunks(id, api) ?? viteManualChunks(id, api);
|
3695
3651
|
};
|
3652
|
+
} else {
|
3653
|
+
console.warn(
|
3654
|
+
"(!) the `splitVendorChunk` plugin doesn't have any effect when using the object form of `build.rollupOptions.output.manualChunks`. Consider using the function form instead."
|
3655
|
+
);
|
3656
|
+
}
|
3657
|
+
} else {
|
3658
|
+
output.manualChunks = viteManualChunks;
|
3696
3659
|
}
|
3697
|
-
|
3698
|
-
|
3699
|
-
|
3700
|
-
|
3701
|
-
|
3660
|
+
}
|
3661
|
+
}
|
3662
|
+
} else {
|
3663
|
+
return {
|
3664
|
+
build: {
|
3665
|
+
rollupOptions: {
|
3666
|
+
output: {
|
3667
|
+
manualChunks: createSplitVendorChunk({}, config)
|
3668
|
+
}
|
3669
|
+
}
|
3670
|
+
}
|
3671
|
+
};
|
3672
|
+
}
|
3673
|
+
},
|
3674
|
+
buildStart() {
|
3675
|
+
caches.forEach((cache) => cache.reset());
|
3676
|
+
}
|
3677
|
+
};
|
3702
3678
|
}
|
3703
3679
|
|
3704
3680
|
var convertSourceMap$1 = {};
|
@@ -4827,8 +4803,10 @@ class MagicString {
|
|
4827
4803
|
update(start, end, content, options) {
|
4828
4804
|
if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
|
4829
4805
|
|
4830
|
-
|
4831
|
-
|
4806
|
+
if (this.original.length !== 0) {
|
4807
|
+
while (start < 0) start += this.original.length;
|
4808
|
+
while (end < 0) end += this.original.length;
|
4809
|
+
}
|
4832
4810
|
|
4833
4811
|
if (end > this.original.length) throw new Error('end is out of bounds');
|
4834
4812
|
if (start === end)
|
@@ -4924,8 +4902,10 @@ class MagicString {
|
|
4924
4902
|
}
|
4925
4903
|
|
4926
4904
|
remove(start, end) {
|
4927
|
-
|
4928
|
-
|
4905
|
+
if (this.original.length !== 0) {
|
4906
|
+
while (start < 0) start += this.original.length;
|
4907
|
+
while (end < 0) end += this.original.length;
|
4908
|
+
}
|
4929
4909
|
|
4930
4910
|
if (start === end) return this;
|
4931
4911
|
|
@@ -4948,8 +4928,10 @@ class MagicString {
|
|
4948
4928
|
}
|
4949
4929
|
|
4950
4930
|
reset(start, end) {
|
4951
|
-
|
4952
|
-
|
4931
|
+
if (this.original.length !== 0) {
|
4932
|
+
while (start < 0) start += this.original.length;
|
4933
|
+
while (end < 0) end += this.original.length;
|
4934
|
+
}
|
4953
4935
|
|
4954
4936
|
if (start === end) return this;
|
4955
4937
|
|
@@ -5011,8 +4993,10 @@ class MagicString {
|
|
5011
4993
|
}
|
5012
4994
|
|
5013
4995
|
slice(start = 0, end = this.original.length) {
|
5014
|
-
|
5015
|
-
|
4996
|
+
if (this.original.length !== 0) {
|
4997
|
+
while (start < 0) start += this.original.length;
|
4998
|
+
while (end < 0) end += this.original.length;
|
4999
|
+
}
|
5016
5000
|
|
5017
5001
|
let result = '';
|
5018
5002
|
|
@@ -5318,270 +5302,262 @@ class MagicString {
|
|
5318
5302
|
}
|
5319
5303
|
}
|
5320
5304
|
|
5321
|
-
const debug$1 = createDebugger(
|
5322
|
-
|
5305
|
+
const debug$1 = createDebugger("vite:sourcemap", {
|
5306
|
+
onlyWhenFocused: true
|
5323
5307
|
});
|
5324
5308
|
function genSourceMapUrl(map) {
|
5325
|
-
|
5326
|
-
|
5327
|
-
|
5328
|
-
|
5309
|
+
if (typeof map !== "string") {
|
5310
|
+
map = JSON.stringify(map);
|
5311
|
+
}
|
5312
|
+
return `data:application/json;base64,${Buffer.from(map).toString("base64")}`;
|
5329
5313
|
}
|
5330
5314
|
function getCodeWithSourcemap(type, code, map) {
|
5331
|
-
|
5332
|
-
|
5333
|
-
|
5334
|
-
|
5335
|
-
|
5336
|
-
|
5337
|
-
|
5338
|
-
|
5339
|
-
|
5340
|
-
|
5315
|
+
if (debug$1) {
|
5316
|
+
code += `
|
5317
|
+
/*${JSON.stringify(map, null, 2).replace(/\*\//g, "*\\/")}*/
|
5318
|
+
`;
|
5319
|
+
}
|
5320
|
+
if (type === "js") {
|
5321
|
+
code += `
|
5322
|
+
//# sourceMappingURL=${genSourceMapUrl(map)}`;
|
5323
|
+
} else if (type === "css") {
|
5324
|
+
code += `
|
5325
|
+
/*# sourceMappingURL=${genSourceMapUrl(map)} */`;
|
5326
|
+
}
|
5327
|
+
return code;
|
5341
5328
|
}
|
5342
5329
|
|
5343
|
-
const debug = createDebugger(
|
5344
|
-
|
5330
|
+
const debug = createDebugger("vite:send", {
|
5331
|
+
onlyWhenFocused: true
|
5345
5332
|
});
|
5346
5333
|
const alias = {
|
5347
|
-
|
5348
|
-
|
5349
|
-
|
5350
|
-
|
5334
|
+
js: "text/javascript",
|
5335
|
+
css: "text/css",
|
5336
|
+
html: "text/html",
|
5337
|
+
json: "application/json"
|
5351
5338
|
};
|
5352
5339
|
function send(req, res, content, type, options) {
|
5353
|
-
|
5354
|
-
|
5355
|
-
|
5356
|
-
|
5357
|
-
|
5358
|
-
|
5359
|
-
|
5360
|
-
|
5361
|
-
|
5362
|
-
|
5363
|
-
res.
|
5364
|
-
res.
|
5365
|
-
|
5366
|
-
|
5367
|
-
|
5368
|
-
|
5340
|
+
const {
|
5341
|
+
etag = getEtag(content, { weak: true }),
|
5342
|
+
cacheControl = "no-cache",
|
5343
|
+
headers,
|
5344
|
+
map
|
5345
|
+
} = options;
|
5346
|
+
if (res.writableEnded) {
|
5347
|
+
return;
|
5348
|
+
}
|
5349
|
+
if (req.headers["if-none-match"] === etag) {
|
5350
|
+
res.statusCode = 304;
|
5351
|
+
res.end();
|
5352
|
+
return;
|
5353
|
+
}
|
5354
|
+
res.setHeader("Content-Type", alias[type] || type);
|
5355
|
+
res.setHeader("Cache-Control", cacheControl);
|
5356
|
+
res.setHeader("Etag", etag);
|
5357
|
+
if (headers) {
|
5358
|
+
for (const name in headers) {
|
5359
|
+
res.setHeader(name, headers[name]);
|
5369
5360
|
}
|
5370
|
-
|
5371
|
-
|
5372
|
-
|
5373
|
-
|
5374
|
-
}
|
5361
|
+
}
|
5362
|
+
if (map && "version" in map && map.mappings) {
|
5363
|
+
if (type === "js" || type === "css") {
|
5364
|
+
content = getCodeWithSourcemap(type, content.toString(), map);
|
5375
5365
|
}
|
5376
|
-
|
5377
|
-
|
5378
|
-
|
5379
|
-
|
5380
|
-
|
5381
|
-
|
5382
|
-
|
5383
|
-
|
5384
|
-
|
5385
|
-
|
5386
|
-
|
5387
|
-
|
5388
|
-
|
5389
|
-
|
5390
|
-
|
5391
|
-
|
5392
|
-
}
|
5366
|
+
} else if (type === "js" && (!map || map.mappings !== "")) {
|
5367
|
+
const code = content.toString();
|
5368
|
+
if (convertSourceMap.mapFileCommentRegex.test(code)) {
|
5369
|
+
debug?.(`Skipped injecting fallback sourcemap for ${req.url}`);
|
5370
|
+
} else {
|
5371
|
+
const urlWithoutTimestamp = removeTimestampQuery(req.url);
|
5372
|
+
const ms = new MagicString(code);
|
5373
|
+
content = getCodeWithSourcemap(
|
5374
|
+
type,
|
5375
|
+
code,
|
5376
|
+
ms.generateMap({
|
5377
|
+
source: path$3.basename(urlWithoutTimestamp),
|
5378
|
+
hires: "boundary",
|
5379
|
+
includeContent: true
|
5380
|
+
})
|
5381
|
+
);
|
5393
5382
|
}
|
5394
|
-
|
5395
|
-
|
5396
|
-
|
5383
|
+
}
|
5384
|
+
res.statusCode = 200;
|
5385
|
+
res.end(content);
|
5386
|
+
return;
|
5397
5387
|
}
|
5398
5388
|
|
5399
|
-
/* eslint no-console: 0 */
|
5400
5389
|
const LogLevels = {
|
5401
|
-
|
5402
|
-
|
5403
|
-
|
5404
|
-
|
5390
|
+
silent: 0,
|
5391
|
+
error: 1,
|
5392
|
+
warn: 2,
|
5393
|
+
info: 3
|
5405
5394
|
};
|
5406
5395
|
let lastType;
|
5407
5396
|
let lastMsg;
|
5408
5397
|
let sameCount = 0;
|
5409
5398
|
function clearScreen() {
|
5410
|
-
|
5411
|
-
|
5412
|
-
|
5413
|
-
|
5414
|
-
|
5399
|
+
const repeatCount = process.stdout.rows - 2;
|
5400
|
+
const blank = repeatCount > 0 ? "\n".repeat(repeatCount) : "";
|
5401
|
+
console.log(blank);
|
5402
|
+
readline.cursorTo(process.stdout, 0, 0);
|
5403
|
+
readline.clearScreenDown(process.stdout);
|
5415
5404
|
}
|
5416
|
-
// Only initialize the timeFormatter when the timestamp option is used, and
|
5417
|
-
// reuse it across all loggers
|
5418
5405
|
let timeFormatter;
|
5419
5406
|
function getTimeFormatter() {
|
5420
|
-
|
5421
|
-
|
5422
|
-
|
5423
|
-
|
5424
|
-
|
5425
|
-
|
5407
|
+
timeFormatter ??= new Intl.DateTimeFormat(void 0, {
|
5408
|
+
hour: "numeric",
|
5409
|
+
minute: "numeric",
|
5410
|
+
second: "numeric"
|
5411
|
+
});
|
5412
|
+
return timeFormatter;
|
5426
5413
|
}
|
5427
|
-
function createLogger(level =
|
5428
|
-
|
5429
|
-
|
5414
|
+
function createLogger(level = "info", options = {}) {
|
5415
|
+
if (options.customLogger) {
|
5416
|
+
return options.customLogger;
|
5417
|
+
}
|
5418
|
+
const loggedErrors = /* @__PURE__ */ new WeakSet();
|
5419
|
+
const { prefix = "[vite]", allowClearScreen = true } = options;
|
5420
|
+
const thresh = LogLevels[level];
|
5421
|
+
const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
|
5422
|
+
const clear = canClearScreen ? clearScreen : () => {
|
5423
|
+
};
|
5424
|
+
function format(type, msg, options2 = {}) {
|
5425
|
+
if (options2.timestamp) {
|
5426
|
+
let tag = "";
|
5427
|
+
if (type === "info") {
|
5428
|
+
tag = colors.cyan(colors.bold(prefix));
|
5429
|
+
} else if (type === "warn") {
|
5430
|
+
tag = colors.yellow(colors.bold(prefix));
|
5431
|
+
} else {
|
5432
|
+
tag = colors.red(colors.bold(prefix));
|
5433
|
+
}
|
5434
|
+
const environment = options2.environment ? options2.environment + " " : "";
|
5435
|
+
return `${colors.dim(getTimeFormatter().format(/* @__PURE__ */ new Date()))} ${tag} ${environment}${msg}`;
|
5436
|
+
} else {
|
5437
|
+
return msg;
|
5430
5438
|
}
|
5431
|
-
|
5432
|
-
|
5433
|
-
|
5434
|
-
|
5435
|
-
|
5436
|
-
|
5437
|
-
|
5438
|
-
|
5439
|
-
|
5440
|
-
|
5441
|
-
|
5442
|
-
|
5443
|
-
|
5444
|
-
|
5445
|
-
|
5446
|
-
|
5439
|
+
}
|
5440
|
+
function output(type, msg, options2 = {}) {
|
5441
|
+
if (thresh >= LogLevels[type]) {
|
5442
|
+
const method = type === "info" ? "log" : type;
|
5443
|
+
if (options2.error) {
|
5444
|
+
loggedErrors.add(options2.error);
|
5445
|
+
}
|
5446
|
+
if (canClearScreen) {
|
5447
|
+
if (type === lastType && msg === lastMsg) {
|
5448
|
+
sameCount++;
|
5449
|
+
clear();
|
5450
|
+
console[method](
|
5451
|
+
format(type, msg, options2),
|
5452
|
+
colors.yellow(`(x${sameCount + 1})`)
|
5453
|
+
);
|
5454
|
+
} else {
|
5455
|
+
sameCount = 0;
|
5456
|
+
lastMsg = msg;
|
5457
|
+
lastType = type;
|
5458
|
+
if (options2.clear) {
|
5459
|
+
clear();
|
5460
|
+
}
|
5461
|
+
console[method](format(type, msg, options2));
|
5447
5462
|
}
|
5463
|
+
} else {
|
5464
|
+
console[method](format(type, msg, options2));
|
5465
|
+
}
|
5448
5466
|
}
|
5449
|
-
|
5450
|
-
|
5451
|
-
|
5452
|
-
|
5453
|
-
|
5454
|
-
|
5455
|
-
|
5456
|
-
|
5457
|
-
|
5458
|
-
|
5459
|
-
|
5460
|
-
|
5461
|
-
|
5462
|
-
|
5463
|
-
|
5464
|
-
|
5465
|
-
|
5466
|
-
|
5467
|
-
|
5468
|
-
|
5469
|
-
|
5470
|
-
|
5471
|
-
|
5472
|
-
|
5473
|
-
|
5474
|
-
|
5467
|
+
}
|
5468
|
+
const warnedMessages = /* @__PURE__ */ new Set();
|
5469
|
+
const logger = {
|
5470
|
+
hasWarned: false,
|
5471
|
+
info(msg, opts) {
|
5472
|
+
output("info", msg, opts);
|
5473
|
+
},
|
5474
|
+
warn(msg, opts) {
|
5475
|
+
logger.hasWarned = true;
|
5476
|
+
output("warn", msg, opts);
|
5477
|
+
},
|
5478
|
+
warnOnce(msg, opts) {
|
5479
|
+
if (warnedMessages.has(msg)) return;
|
5480
|
+
logger.hasWarned = true;
|
5481
|
+
output("warn", msg, opts);
|
5482
|
+
warnedMessages.add(msg);
|
5483
|
+
},
|
5484
|
+
error(msg, opts) {
|
5485
|
+
logger.hasWarned = true;
|
5486
|
+
output("error", msg, opts);
|
5487
|
+
},
|
5488
|
+
clearScreen(type) {
|
5489
|
+
if (thresh >= LogLevels[type]) {
|
5490
|
+
clear();
|
5491
|
+
}
|
5492
|
+
},
|
5493
|
+
hasErrorLogged(error) {
|
5494
|
+
return loggedErrors.has(error);
|
5475
5495
|
}
|
5476
|
-
|
5477
|
-
|
5478
|
-
hasWarned: false,
|
5479
|
-
info(msg, opts) {
|
5480
|
-
output('info', msg, opts);
|
5481
|
-
},
|
5482
|
-
warn(msg, opts) {
|
5483
|
-
logger.hasWarned = true;
|
5484
|
-
output('warn', msg, opts);
|
5485
|
-
},
|
5486
|
-
warnOnce(msg, opts) {
|
5487
|
-
if (warnedMessages.has(msg))
|
5488
|
-
return;
|
5489
|
-
logger.hasWarned = true;
|
5490
|
-
output('warn', msg, opts);
|
5491
|
-
warnedMessages.add(msg);
|
5492
|
-
},
|
5493
|
-
error(msg, opts) {
|
5494
|
-
logger.hasWarned = true;
|
5495
|
-
output('error', msg, opts);
|
5496
|
-
},
|
5497
|
-
clearScreen(type) {
|
5498
|
-
if (thresh >= LogLevels[type]) {
|
5499
|
-
clear();
|
5500
|
-
}
|
5501
|
-
},
|
5502
|
-
hasErrorLogged(error) {
|
5503
|
-
return loggedErrors.has(error);
|
5504
|
-
},
|
5505
|
-
};
|
5506
|
-
return logger;
|
5496
|
+
};
|
5497
|
+
return logger;
|
5507
5498
|
}
|
5508
5499
|
|
5509
|
-
// https://github.com/vitejs/vite/issues/2820#issuecomment-812495079
|
5510
5500
|
const ROOT_FILES = [
|
5511
|
-
|
5512
|
-
|
5513
|
-
|
5514
|
-
|
5515
|
-
|
5516
|
-
|
5517
|
-
|
5518
|
-
|
5519
|
-
|
5520
|
-
|
5501
|
+
// '.git',
|
5502
|
+
// https://pnpm.io/workspaces/
|
5503
|
+
"pnpm-workspace.yaml",
|
5504
|
+
// https://rushjs.io/pages/advanced/config_files/
|
5505
|
+
// 'rush.json',
|
5506
|
+
// https://nx.dev/latest/react/getting-started/nx-setup
|
5507
|
+
// 'workspace.json',
|
5508
|
+
// 'nx.json',
|
5509
|
+
// https://github.com/lerna/lerna#lernajson
|
5510
|
+
"lerna.json"
|
5521
5511
|
];
|
5522
|
-
// npm: https://docs.npmjs.com/cli/v7/using-npm/workspaces#installing-workspaces
|
5523
|
-
// yarn: https://classic.yarnpkg.com/en/docs/workspaces/#toc-how-to-use-it
|
5524
5512
|
function hasWorkspacePackageJSON(root) {
|
5525
|
-
|
5526
|
-
|
5527
|
-
|
5528
|
-
|
5529
|
-
|
5530
|
-
|
5531
|
-
|
5532
|
-
|
5533
|
-
|
5534
|
-
|
5535
|
-
}
|
5513
|
+
const path = path$3.join(root, "package.json");
|
5514
|
+
if (!isFileReadable(path)) {
|
5515
|
+
return false;
|
5516
|
+
}
|
5517
|
+
try {
|
5518
|
+
const content = JSON.parse(fs$1.readFileSync(path, "utf-8")) || {};
|
5519
|
+
return !!content.workspaces;
|
5520
|
+
} catch {
|
5521
|
+
return false;
|
5522
|
+
}
|
5536
5523
|
}
|
5537
5524
|
function hasRootFile(root) {
|
5538
|
-
|
5525
|
+
return ROOT_FILES.some((file) => fs$1.existsSync(path$3.join(root, file)));
|
5539
5526
|
}
|
5540
5527
|
function hasPackageJSON(root) {
|
5541
|
-
|
5542
|
-
|
5528
|
+
const path = path$3.join(root, "package.json");
|
5529
|
+
return fs$1.existsSync(path);
|
5543
5530
|
}
|
5544
|
-
/**
|
5545
|
-
* Search up for the nearest `package.json`
|
5546
|
-
*/
|
5547
5531
|
function searchForPackageRoot(current, root = current) {
|
5548
|
-
|
5549
|
-
|
5550
|
-
|
5551
|
-
|
5552
|
-
if (!dir || dir === current)
|
5553
|
-
return root;
|
5554
|
-
return searchForPackageRoot(dir, root);
|
5532
|
+
if (hasPackageJSON(current)) return current;
|
5533
|
+
const dir = path$3.dirname(current);
|
5534
|
+
if (!dir || dir === current) return root;
|
5535
|
+
return searchForPackageRoot(dir, root);
|
5555
5536
|
}
|
5556
|
-
/**
|
5557
|
-
* Search up for the nearest workspace root
|
5558
|
-
*/
|
5559
5537
|
function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
|
5560
|
-
|
5561
|
-
|
5562
|
-
|
5563
|
-
|
5564
|
-
|
5565
|
-
// reach the fs root
|
5566
|
-
if (!dir || dir === current)
|
5567
|
-
return root;
|
5568
|
-
return searchForWorkspaceRoot(dir, root);
|
5538
|
+
if (hasRootFile(current)) return current;
|
5539
|
+
if (hasWorkspacePackageJSON(current)) return current;
|
5540
|
+
const dir = path$3.dirname(current);
|
5541
|
+
if (!dir || dir === current) return root;
|
5542
|
+
return searchForWorkspaceRoot(dir, root);
|
5569
5543
|
}
|
5570
5544
|
|
5571
|
-
/**
|
5572
|
-
* Check if the url is allowed to be served, via the `server.fs` config.
|
5573
|
-
*/
|
5574
5545
|
function isFileServingAllowed(url, server) {
|
5575
|
-
|
5576
|
-
|
5577
|
-
|
5578
|
-
|
5579
|
-
|
5580
|
-
|
5581
|
-
|
5582
|
-
|
5583
|
-
|
5584
|
-
|
5546
|
+
const { config } = server;
|
5547
|
+
if (!config.server.fs.strict) return true;
|
5548
|
+
const filePath = fsPathFromUrl(url);
|
5549
|
+
return isFileLoadingAllowed(config, filePath);
|
5550
|
+
}
|
5551
|
+
function isUriInFilePath(uri, filePath) {
|
5552
|
+
return isSameFileUri(uri, filePath) || isParentDirectory(uri, filePath);
|
5553
|
+
}
|
5554
|
+
function isFileLoadingAllowed(config, filePath) {
|
5555
|
+
const { fs } = config.server;
|
5556
|
+
if (!fs.strict) return true;
|
5557
|
+
if (config.fsDenyGlob(filePath)) return false;
|
5558
|
+
if (config.safeModulePaths.has(filePath)) return true;
|
5559
|
+
if (fs.allow.some((uri) => isUriInFilePath(uri, filePath))) return true;
|
5560
|
+
return false;
|
5585
5561
|
}
|
5586
5562
|
|
5587
5563
|
var main$1 = {exports: {}};
|
@@ -6117,68 +6093,72 @@ function expand (options) {
|
|
6117
6093
|
var expand_1 = expand;
|
6118
6094
|
|
6119
6095
|
function getEnvFilesForMode(mode, envDir) {
|
6120
|
-
|
6121
|
-
|
6122
|
-
|
6123
|
-
|
6124
|
-
|
6125
|
-
|
6096
|
+
return [
|
6097
|
+
/** default file */
|
6098
|
+
`.env`,
|
6099
|
+
/** local file */
|
6100
|
+
`.env.local`,
|
6101
|
+
/** mode file */
|
6102
|
+
`.env.${mode}`,
|
6103
|
+
/** mode local file */
|
6104
|
+
`.env.${mode}.local`
|
6105
|
+
].map((file) => normalizePath(path$3.join(envDir, file)));
|
6126
6106
|
}
|
6127
|
-
function loadEnv(mode, envDir, prefixes =
|
6128
|
-
|
6129
|
-
|
6130
|
-
|
6131
|
-
|
6132
|
-
|
6133
|
-
|
6134
|
-
|
6135
|
-
|
6136
|
-
|
6137
|
-
|
6138
|
-
|
6139
|
-
|
6140
|
-
|
6141
|
-
|
6142
|
-
|
6143
|
-
|
6144
|
-
|
6145
|
-
|
6146
|
-
|
6147
|
-
|
6148
|
-
|
6149
|
-
|
6150
|
-
|
6151
|
-
|
6152
|
-
|
6153
|
-
|
6154
|
-
|
6155
|
-
|
6156
|
-
for (const [key, value] of Object.entries(parsed)) {
|
6157
|
-
if (prefixes.some((prefix) => key.startsWith(prefix))) {
|
6158
|
-
env[key] = value;
|
6159
|
-
}
|
6107
|
+
function loadEnv(mode, envDir, prefixes = "VITE_") {
|
6108
|
+
if (mode === "local") {
|
6109
|
+
throw new Error(
|
6110
|
+
`"local" cannot be used as a mode name because it conflicts with the .local postfix for .env files.`
|
6111
|
+
);
|
6112
|
+
}
|
6113
|
+
prefixes = arraify(prefixes);
|
6114
|
+
const env = {};
|
6115
|
+
const envFiles = getEnvFilesForMode(mode, envDir);
|
6116
|
+
const parsed = Object.fromEntries(
|
6117
|
+
envFiles.flatMap((filePath) => {
|
6118
|
+
if (!tryStatSync(filePath)?.isFile()) return [];
|
6119
|
+
return Object.entries(parse_1(fs$1.readFileSync(filePath)));
|
6120
|
+
})
|
6121
|
+
);
|
6122
|
+
if (parsed.NODE_ENV && process.env.VITE_USER_NODE_ENV === void 0) {
|
6123
|
+
process.env.VITE_USER_NODE_ENV = parsed.NODE_ENV;
|
6124
|
+
}
|
6125
|
+
if (parsed.BROWSER && process.env.BROWSER === void 0) {
|
6126
|
+
process.env.BROWSER = parsed.BROWSER;
|
6127
|
+
}
|
6128
|
+
if (parsed.BROWSER_ARGS && process.env.BROWSER_ARGS === void 0) {
|
6129
|
+
process.env.BROWSER_ARGS = parsed.BROWSER_ARGS;
|
6130
|
+
}
|
6131
|
+
const processEnv = { ...process.env };
|
6132
|
+
expand_1({ parsed, processEnv });
|
6133
|
+
for (const [key, value] of Object.entries(parsed)) {
|
6134
|
+
if (prefixes.some((prefix) => key.startsWith(prefix))) {
|
6135
|
+
env[key] = value;
|
6160
6136
|
}
|
6161
|
-
|
6162
|
-
|
6163
|
-
|
6164
|
-
|
6165
|
-
env[key] = process.env[key];
|
6166
|
-
}
|
6137
|
+
}
|
6138
|
+
for (const key in process.env) {
|
6139
|
+
if (prefixes.some((prefix) => key.startsWith(prefix))) {
|
6140
|
+
env[key] = process.env[key];
|
6167
6141
|
}
|
6168
|
-
|
6142
|
+
}
|
6143
|
+
return env;
|
6169
6144
|
}
|
6170
|
-
function resolveEnvPrefix({
|
6171
|
-
|
6172
|
-
|
6173
|
-
|
6174
|
-
|
6175
|
-
|
6145
|
+
function resolveEnvPrefix({
|
6146
|
+
envPrefix = "VITE_"
|
6147
|
+
}) {
|
6148
|
+
envPrefix = arraify(envPrefix);
|
6149
|
+
if (envPrefix.includes("")) {
|
6150
|
+
throw new Error(
|
6151
|
+
`envPrefix option contains value '', which could lead unexpected exposure of sensitive information.`
|
6152
|
+
);
|
6153
|
+
}
|
6154
|
+
return envPrefix;
|
6176
6155
|
}
|
6177
6156
|
|
6178
6157
|
exports.esbuildVersion = esbuild.version;
|
6179
6158
|
exports.createFilter = createFilter;
|
6180
6159
|
exports.createLogger = createLogger;
|
6181
6160
|
exports.isCSSRequest = isCSSRequest;
|
6161
|
+
exports.isFileLoadingAllowed = isFileLoadingAllowed;
|
6182
6162
|
exports.isFileServingAllowed = isFileServingAllowed;
|
6183
6163
|
exports.loadEnv = loadEnv;
|
6184
6164
|
exports.mergeAlias = mergeAlias;
|