vite 6.0.0-alpha.2 → 6.0.0-alpha.20
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-BVDN2Cqw.js} +1 -1
- package/dist/node/chunks/{dep-E4cF1RpV.js → dep-CpuHsFvF.js} +37411 -39030
- package/dist/node/chunks/{dep-CrWVpuYf.js → dep-D-7KCb9p.js} +32 -2
- package/dist/node/chunks/{dep-DKZVy3_n.js → dep-D1nw2wDG.js} +165 -968
- package/dist/node/cli.js +260 -265
- package/dist/node/constants.js +108 -84
- package/dist/node/index.d.ts +2121 -1984
- 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 +638 -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,321 @@ 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" && // TODO: environments
|
3507
|
+
rootPath === "ssr" && (existing === true || value === true)) {
|
3508
|
+
merged[key] = true;
|
3509
|
+
continue;
|
3510
|
+
} else if (key === "plugins" && rootPath === "worker") {
|
3511
|
+
merged[key] = () => [
|
3512
|
+
...backwardCompatibleWorkerPlugins(existing),
|
3513
|
+
...backwardCompatibleWorkerPlugins(value)
|
3514
|
+
];
|
3515
|
+
continue;
|
3516
|
+
} else if (key === "server" && rootPath === "server.hmr") {
|
3517
|
+
merged[key] = value;
|
3518
|
+
continue;
|
3519
|
+
}
|
3520
|
+
if (Array.isArray(existing) || Array.isArray(value)) {
|
3521
|
+
merged[key] = [...arraify(existing), ...arraify(value)];
|
3522
|
+
continue;
|
3523
|
+
}
|
3524
|
+
if (isObject$1(existing) && isObject$1(value)) {
|
3525
|
+
merged[key] = mergeConfigRecursively(
|
3526
|
+
existing,
|
3527
|
+
value,
|
3528
|
+
rootPath ? `${rootPath}.${key}` : key
|
3529
|
+
);
|
3530
|
+
continue;
|
3531
|
+
}
|
3532
|
+
merged[key] = value;
|
3533
|
+
}
|
3534
|
+
return merged;
|
3537
3535
|
}
|
3538
3536
|
function mergeConfig(defaults, overrides, isRoot = true) {
|
3539
|
-
|
3540
|
-
|
3541
|
-
|
3542
|
-
|
3537
|
+
if (typeof defaults === "function" || typeof overrides === "function") {
|
3538
|
+
throw new Error(`Cannot merge config in form of callback`);
|
3539
|
+
}
|
3540
|
+
return mergeConfigRecursively(defaults, overrides, isRoot ? "" : ".");
|
3543
3541
|
}
|
3544
3542
|
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)];
|
3543
|
+
if (!a) return b;
|
3544
|
+
if (!b) return a;
|
3545
|
+
if (isObject$1(a) && isObject$1(b)) {
|
3546
|
+
return { ...a, ...b };
|
3547
|
+
}
|
3548
|
+
return [...normalizeAlias(b), ...normalizeAlias(a)];
|
3555
3549
|
}
|
3556
3550
|
function normalizeAlias(o = []) {
|
3557
|
-
|
3558
|
-
|
3559
|
-
|
3560
|
-
|
3561
|
-
|
3562
|
-
|
3551
|
+
return Array.isArray(o) ? o.map(normalizeSingleAlias) : Object.keys(o).map(
|
3552
|
+
(find) => normalizeSingleAlias({
|
3553
|
+
find,
|
3554
|
+
replacement: o[find]
|
3555
|
+
})
|
3556
|
+
);
|
3563
3557
|
}
|
3564
|
-
|
3565
|
-
|
3566
|
-
|
3567
|
-
|
3568
|
-
|
3569
|
-
|
3570
|
-
|
3571
|
-
|
3572
|
-
|
3573
|
-
|
3574
|
-
|
3575
|
-
|
3576
|
-
|
3577
|
-
|
3578
|
-
|
3579
|
-
|
3580
|
-
|
3558
|
+
function normalizeSingleAlias({
|
3559
|
+
find,
|
3560
|
+
replacement,
|
3561
|
+
customResolver
|
3562
|
+
}) {
|
3563
|
+
if (typeof find === "string" && find[find.length - 1] === "/" && replacement[replacement.length - 1] === "/") {
|
3564
|
+
find = find.slice(0, find.length - 1);
|
3565
|
+
replacement = replacement.slice(0, replacement.length - 1);
|
3566
|
+
}
|
3567
|
+
const alias = {
|
3568
|
+
find,
|
3569
|
+
replacement
|
3570
|
+
};
|
3571
|
+
if (customResolver) {
|
3572
|
+
alias.customResolver = customResolver;
|
3573
|
+
}
|
3574
|
+
return alias;
|
3581
3575
|
}
|
3582
3576
|
|
3583
|
-
|
3584
|
-
//
|
3585
|
-
|
3586
|
-
|
3587
|
-
/\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
3577
|
+
const CSS_LANGS_RE = (
|
3578
|
+
// eslint-disable-next-line regexp/no-unused-capturing-group
|
3579
|
+
/\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/
|
3580
|
+
);
|
3588
3581
|
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
3582
|
class SplitVendorChunkCache {
|
3600
|
-
|
3601
|
-
|
3602
|
-
|
3603
|
-
|
3604
|
-
|
3605
|
-
|
3606
|
-
|
3583
|
+
cache;
|
3584
|
+
constructor() {
|
3585
|
+
this.cache = /* @__PURE__ */ new Map();
|
3586
|
+
}
|
3587
|
+
reset() {
|
3588
|
+
this.cache = /* @__PURE__ */ new Map();
|
3589
|
+
}
|
3607
3590
|
}
|
3608
|
-
/**
|
3609
|
-
* @deprecated use build.rollupOutput.manualChunks or framework specific configuration
|
3610
|
-
*/
|
3611
3591
|
function splitVendorChunk(options = {}) {
|
3612
|
-
|
3613
|
-
|
3614
|
-
|
3615
|
-
|
3616
|
-
|
3617
|
-
|
3618
|
-
}
|
3619
|
-
};
|
3592
|
+
const cache = options.cache ?? new SplitVendorChunkCache();
|
3593
|
+
return (id, { getModuleInfo }) => {
|
3594
|
+
if (isInNodeModules(id) && !isCSSRequest(id) && staticImportedByEntry(id, getModuleInfo, cache.cache)) {
|
3595
|
+
return "vendor";
|
3596
|
+
}
|
3597
|
+
};
|
3620
3598
|
}
|
3621
3599
|
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
|
-
|
3600
|
+
if (cache.has(id)) {
|
3601
|
+
return cache.get(id);
|
3602
|
+
}
|
3603
|
+
if (importStack.includes(id)) {
|
3604
|
+
cache.set(id, false);
|
3605
|
+
return false;
|
3606
|
+
}
|
3607
|
+
const mod = getModuleInfo(id);
|
3608
|
+
if (!mod) {
|
3609
|
+
cache.set(id, false);
|
3610
|
+
return false;
|
3611
|
+
}
|
3612
|
+
if (mod.isEntry) {
|
3613
|
+
cache.set(id, true);
|
3614
|
+
return true;
|
3615
|
+
}
|
3616
|
+
const someImporterIs = mod.importers.some(
|
3617
|
+
(importer) => staticImportedByEntry(
|
3618
|
+
importer,
|
3619
|
+
getModuleInfo,
|
3620
|
+
cache,
|
3621
|
+
importStack.concat(id)
|
3622
|
+
)
|
3623
|
+
);
|
3624
|
+
cache.set(id, someImporterIs);
|
3625
|
+
return someImporterIs;
|
3642
3626
|
}
|
3643
|
-
/**
|
3644
|
-
* @deprecated use build.rollupOutput.manualChunks or framework specific configuration
|
3645
|
-
*/
|
3646
3627
|
function splitVendorChunkPlugin() {
|
3647
|
-
|
3648
|
-
|
3649
|
-
|
3650
|
-
|
3651
|
-
|
3652
|
-
|
3653
|
-
|
3654
|
-
|
3655
|
-
}
|
3628
|
+
const caches = [];
|
3629
|
+
function createSplitVendorChunk(output, config) {
|
3630
|
+
const cache = new SplitVendorChunkCache();
|
3631
|
+
caches.push(cache);
|
3632
|
+
const build = config.build ?? {};
|
3633
|
+
const format = output?.format;
|
3634
|
+
if (!build.ssr && !build.lib && format !== "umd" && format !== "iife") {
|
3635
|
+
return splitVendorChunk({ cache });
|
3656
3636
|
}
|
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
|
-
},
|
3637
|
+
}
|
3638
|
+
return {
|
3639
|
+
name: "vite:split-vendor-chunk",
|
3640
|
+
config(config) {
|
3641
|
+
let outputs = config?.build?.rollupOptions?.output;
|
3642
|
+
if (outputs) {
|
3643
|
+
outputs = arraify(outputs);
|
3644
|
+
for (const output of outputs) {
|
3645
|
+
const viteManualChunks = createSplitVendorChunk(output, config);
|
3646
|
+
if (viteManualChunks) {
|
3647
|
+
if (output.manualChunks) {
|
3648
|
+
if (typeof output.manualChunks === "function") {
|
3649
|
+
const userManualChunks = output.manualChunks;
|
3650
|
+
output.manualChunks = (id, api) => {
|
3651
|
+
return userManualChunks(id, api) ?? viteManualChunks(id, api);
|
3695
3652
|
};
|
3653
|
+
} else {
|
3654
|
+
console.warn(
|
3655
|
+
"(!) the `splitVendorChunk` plugin doesn't have any effect when using the object form of `build.rollupOptions.output.manualChunks`. Consider using the function form instead."
|
3656
|
+
);
|
3657
|
+
}
|
3658
|
+
} else {
|
3659
|
+
output.manualChunks = viteManualChunks;
|
3696
3660
|
}
|
3697
|
-
|
3698
|
-
|
3699
|
-
|
3700
|
-
|
3701
|
-
|
3661
|
+
}
|
3662
|
+
}
|
3663
|
+
} else {
|
3664
|
+
return {
|
3665
|
+
build: {
|
3666
|
+
rollupOptions: {
|
3667
|
+
output: {
|
3668
|
+
manualChunks: createSplitVendorChunk({}, config)
|
3669
|
+
}
|
3670
|
+
}
|
3671
|
+
}
|
3672
|
+
};
|
3673
|
+
}
|
3674
|
+
},
|
3675
|
+
buildStart() {
|
3676
|
+
caches.forEach((cache) => cache.reset());
|
3677
|
+
}
|
3678
|
+
};
|
3702
3679
|
}
|
3703
3680
|
|
3704
3681
|
var convertSourceMap$1 = {};
|
@@ -4827,8 +4804,10 @@ class MagicString {
|
|
4827
4804
|
update(start, end, content, options) {
|
4828
4805
|
if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
|
4829
4806
|
|
4830
|
-
|
4831
|
-
|
4807
|
+
if (this.original.length !== 0) {
|
4808
|
+
while (start < 0) start += this.original.length;
|
4809
|
+
while (end < 0) end += this.original.length;
|
4810
|
+
}
|
4832
4811
|
|
4833
4812
|
if (end > this.original.length) throw new Error('end is out of bounds');
|
4834
4813
|
if (start === end)
|
@@ -4924,8 +4903,10 @@ class MagicString {
|
|
4924
4903
|
}
|
4925
4904
|
|
4926
4905
|
remove(start, end) {
|
4927
|
-
|
4928
|
-
|
4906
|
+
if (this.original.length !== 0) {
|
4907
|
+
while (start < 0) start += this.original.length;
|
4908
|
+
while (end < 0) end += this.original.length;
|
4909
|
+
}
|
4929
4910
|
|
4930
4911
|
if (start === end) return this;
|
4931
4912
|
|
@@ -4948,8 +4929,10 @@ class MagicString {
|
|
4948
4929
|
}
|
4949
4930
|
|
4950
4931
|
reset(start, end) {
|
4951
|
-
|
4952
|
-
|
4932
|
+
if (this.original.length !== 0) {
|
4933
|
+
while (start < 0) start += this.original.length;
|
4934
|
+
while (end < 0) end += this.original.length;
|
4935
|
+
}
|
4953
4936
|
|
4954
4937
|
if (start === end) return this;
|
4955
4938
|
|
@@ -5011,8 +4994,10 @@ class MagicString {
|
|
5011
4994
|
}
|
5012
4995
|
|
5013
4996
|
slice(start = 0, end = this.original.length) {
|
5014
|
-
|
5015
|
-
|
4997
|
+
if (this.original.length !== 0) {
|
4998
|
+
while (start < 0) start += this.original.length;
|
4999
|
+
while (end < 0) end += this.original.length;
|
5000
|
+
}
|
5016
5001
|
|
5017
5002
|
let result = '';
|
5018
5003
|
|
@@ -5318,270 +5303,262 @@ class MagicString {
|
|
5318
5303
|
}
|
5319
5304
|
}
|
5320
5305
|
|
5321
|
-
const debug$1 = createDebugger(
|
5322
|
-
|
5306
|
+
const debug$1 = createDebugger("vite:sourcemap", {
|
5307
|
+
onlyWhenFocused: true
|
5323
5308
|
});
|
5324
5309
|
function genSourceMapUrl(map) {
|
5325
|
-
|
5326
|
-
|
5327
|
-
|
5328
|
-
|
5310
|
+
if (typeof map !== "string") {
|
5311
|
+
map = JSON.stringify(map);
|
5312
|
+
}
|
5313
|
+
return `data:application/json;base64,${Buffer.from(map).toString("base64")}`;
|
5329
5314
|
}
|
5330
5315
|
function getCodeWithSourcemap(type, code, map) {
|
5331
|
-
|
5332
|
-
|
5333
|
-
|
5334
|
-
|
5335
|
-
|
5336
|
-
|
5337
|
-
|
5338
|
-
|
5339
|
-
|
5340
|
-
|
5316
|
+
if (debug$1) {
|
5317
|
+
code += `
|
5318
|
+
/*${JSON.stringify(map, null, 2).replace(/\*\//g, "*\\/")}*/
|
5319
|
+
`;
|
5320
|
+
}
|
5321
|
+
if (type === "js") {
|
5322
|
+
code += `
|
5323
|
+
//# sourceMappingURL=${genSourceMapUrl(map)}`;
|
5324
|
+
} else if (type === "css") {
|
5325
|
+
code += `
|
5326
|
+
/*# sourceMappingURL=${genSourceMapUrl(map)} */`;
|
5327
|
+
}
|
5328
|
+
return code;
|
5341
5329
|
}
|
5342
5330
|
|
5343
|
-
const debug = createDebugger(
|
5344
|
-
|
5331
|
+
const debug = createDebugger("vite:send", {
|
5332
|
+
onlyWhenFocused: true
|
5345
5333
|
});
|
5346
5334
|
const alias = {
|
5347
|
-
|
5348
|
-
|
5349
|
-
|
5350
|
-
|
5335
|
+
js: "text/javascript",
|
5336
|
+
css: "text/css",
|
5337
|
+
html: "text/html",
|
5338
|
+
json: "application/json"
|
5351
5339
|
};
|
5352
5340
|
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
|
-
|
5341
|
+
const {
|
5342
|
+
etag = getEtag(content, { weak: true }),
|
5343
|
+
cacheControl = "no-cache",
|
5344
|
+
headers,
|
5345
|
+
map
|
5346
|
+
} = options;
|
5347
|
+
if (res.writableEnded) {
|
5348
|
+
return;
|
5349
|
+
}
|
5350
|
+
if (req.headers["if-none-match"] === etag) {
|
5351
|
+
res.statusCode = 304;
|
5352
|
+
res.end();
|
5353
|
+
return;
|
5354
|
+
}
|
5355
|
+
res.setHeader("Content-Type", alias[type] || type);
|
5356
|
+
res.setHeader("Cache-Control", cacheControl);
|
5357
|
+
res.setHeader("Etag", etag);
|
5358
|
+
if (headers) {
|
5359
|
+
for (const name in headers) {
|
5360
|
+
res.setHeader(name, headers[name]);
|
5369
5361
|
}
|
5370
|
-
|
5371
|
-
|
5372
|
-
|
5373
|
-
|
5374
|
-
}
|
5362
|
+
}
|
5363
|
+
if (map && "version" in map && map.mappings) {
|
5364
|
+
if (type === "js" || type === "css") {
|
5365
|
+
content = getCodeWithSourcemap(type, content.toString(), map);
|
5375
5366
|
}
|
5376
|
-
|
5377
|
-
|
5378
|
-
|
5379
|
-
|
5380
|
-
|
5381
|
-
|
5382
|
-
|
5383
|
-
|
5384
|
-
|
5385
|
-
|
5386
|
-
|
5387
|
-
|
5388
|
-
|
5389
|
-
|
5390
|
-
|
5391
|
-
|
5392
|
-
}
|
5367
|
+
} else if (type === "js" && (!map || map.mappings !== "")) {
|
5368
|
+
const code = content.toString();
|
5369
|
+
if (convertSourceMap.mapFileCommentRegex.test(code)) {
|
5370
|
+
debug?.(`Skipped injecting fallback sourcemap for ${req.url}`);
|
5371
|
+
} else {
|
5372
|
+
const urlWithoutTimestamp = removeTimestampQuery(req.url);
|
5373
|
+
const ms = new MagicString(code);
|
5374
|
+
content = getCodeWithSourcemap(
|
5375
|
+
type,
|
5376
|
+
code,
|
5377
|
+
ms.generateMap({
|
5378
|
+
source: path$3.basename(urlWithoutTimestamp),
|
5379
|
+
hires: "boundary",
|
5380
|
+
includeContent: true
|
5381
|
+
})
|
5382
|
+
);
|
5393
5383
|
}
|
5394
|
-
|
5395
|
-
|
5396
|
-
|
5384
|
+
}
|
5385
|
+
res.statusCode = 200;
|
5386
|
+
res.end(content);
|
5387
|
+
return;
|
5397
5388
|
}
|
5398
5389
|
|
5399
|
-
/* eslint no-console: 0 */
|
5400
5390
|
const LogLevels = {
|
5401
|
-
|
5402
|
-
|
5403
|
-
|
5404
|
-
|
5391
|
+
silent: 0,
|
5392
|
+
error: 1,
|
5393
|
+
warn: 2,
|
5394
|
+
info: 3
|
5405
5395
|
};
|
5406
5396
|
let lastType;
|
5407
5397
|
let lastMsg;
|
5408
5398
|
let sameCount = 0;
|
5409
5399
|
function clearScreen() {
|
5410
|
-
|
5411
|
-
|
5412
|
-
|
5413
|
-
|
5414
|
-
|
5400
|
+
const repeatCount = process.stdout.rows - 2;
|
5401
|
+
const blank = repeatCount > 0 ? "\n".repeat(repeatCount) : "";
|
5402
|
+
console.log(blank);
|
5403
|
+
readline.cursorTo(process.stdout, 0, 0);
|
5404
|
+
readline.clearScreenDown(process.stdout);
|
5415
5405
|
}
|
5416
|
-
// Only initialize the timeFormatter when the timestamp option is used, and
|
5417
|
-
// reuse it across all loggers
|
5418
5406
|
let timeFormatter;
|
5419
5407
|
function getTimeFormatter() {
|
5420
|
-
|
5421
|
-
|
5422
|
-
|
5423
|
-
|
5424
|
-
|
5425
|
-
|
5408
|
+
timeFormatter ??= new Intl.DateTimeFormat(void 0, {
|
5409
|
+
hour: "numeric",
|
5410
|
+
minute: "numeric",
|
5411
|
+
second: "numeric"
|
5412
|
+
});
|
5413
|
+
return timeFormatter;
|
5426
5414
|
}
|
5427
|
-
function createLogger(level =
|
5428
|
-
|
5429
|
-
|
5415
|
+
function createLogger(level = "info", options = {}) {
|
5416
|
+
if (options.customLogger) {
|
5417
|
+
return options.customLogger;
|
5418
|
+
}
|
5419
|
+
const loggedErrors = /* @__PURE__ */ new WeakSet();
|
5420
|
+
const { prefix = "[vite]", allowClearScreen = true } = options;
|
5421
|
+
const thresh = LogLevels[level];
|
5422
|
+
const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
|
5423
|
+
const clear = canClearScreen ? clearScreen : () => {
|
5424
|
+
};
|
5425
|
+
function format(type, msg, options2 = {}) {
|
5426
|
+
if (options2.timestamp) {
|
5427
|
+
let tag = "";
|
5428
|
+
if (type === "info") {
|
5429
|
+
tag = colors.cyan(colors.bold(prefix));
|
5430
|
+
} else if (type === "warn") {
|
5431
|
+
tag = colors.yellow(colors.bold(prefix));
|
5432
|
+
} else {
|
5433
|
+
tag = colors.red(colors.bold(prefix));
|
5434
|
+
}
|
5435
|
+
const environment = options2.environment ? options2.environment + " " : "";
|
5436
|
+
return `${colors.dim(getTimeFormatter().format(/* @__PURE__ */ new Date()))} ${tag} ${environment}${msg}`;
|
5437
|
+
} else {
|
5438
|
+
return msg;
|
5430
5439
|
}
|
5431
|
-
|
5432
|
-
|
5433
|
-
|
5434
|
-
|
5435
|
-
|
5436
|
-
|
5437
|
-
|
5438
|
-
|
5439
|
-
|
5440
|
-
|
5441
|
-
|
5442
|
-
|
5443
|
-
|
5444
|
-
|
5445
|
-
|
5446
|
-
|
5440
|
+
}
|
5441
|
+
function output(type, msg, options2 = {}) {
|
5442
|
+
if (thresh >= LogLevels[type]) {
|
5443
|
+
const method = type === "info" ? "log" : type;
|
5444
|
+
if (options2.error) {
|
5445
|
+
loggedErrors.add(options2.error);
|
5446
|
+
}
|
5447
|
+
if (canClearScreen) {
|
5448
|
+
if (type === lastType && msg === lastMsg) {
|
5449
|
+
sameCount++;
|
5450
|
+
clear();
|
5451
|
+
console[method](
|
5452
|
+
format(type, msg, options2),
|
5453
|
+
colors.yellow(`(x${sameCount + 1})`)
|
5454
|
+
);
|
5455
|
+
} else {
|
5456
|
+
sameCount = 0;
|
5457
|
+
lastMsg = msg;
|
5458
|
+
lastType = type;
|
5459
|
+
if (options2.clear) {
|
5460
|
+
clear();
|
5461
|
+
}
|
5462
|
+
console[method](format(type, msg, options2));
|
5447
5463
|
}
|
5464
|
+
} else {
|
5465
|
+
console[method](format(type, msg, options2));
|
5466
|
+
}
|
5448
5467
|
}
|
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
|
-
|
5468
|
+
}
|
5469
|
+
const warnedMessages = /* @__PURE__ */ new Set();
|
5470
|
+
const logger = {
|
5471
|
+
hasWarned: false,
|
5472
|
+
info(msg, opts) {
|
5473
|
+
output("info", msg, opts);
|
5474
|
+
},
|
5475
|
+
warn(msg, opts) {
|
5476
|
+
logger.hasWarned = true;
|
5477
|
+
output("warn", msg, opts);
|
5478
|
+
},
|
5479
|
+
warnOnce(msg, opts) {
|
5480
|
+
if (warnedMessages.has(msg)) return;
|
5481
|
+
logger.hasWarned = true;
|
5482
|
+
output("warn", msg, opts);
|
5483
|
+
warnedMessages.add(msg);
|
5484
|
+
},
|
5485
|
+
error(msg, opts) {
|
5486
|
+
logger.hasWarned = true;
|
5487
|
+
output("error", msg, opts);
|
5488
|
+
},
|
5489
|
+
clearScreen(type) {
|
5490
|
+
if (thresh >= LogLevels[type]) {
|
5491
|
+
clear();
|
5492
|
+
}
|
5493
|
+
},
|
5494
|
+
hasErrorLogged(error) {
|
5495
|
+
return loggedErrors.has(error);
|
5475
5496
|
}
|
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;
|
5497
|
+
};
|
5498
|
+
return logger;
|
5507
5499
|
}
|
5508
5500
|
|
5509
|
-
// https://github.com/vitejs/vite/issues/2820#issuecomment-812495079
|
5510
5501
|
const ROOT_FILES = [
|
5511
|
-
|
5512
|
-
|
5513
|
-
|
5514
|
-
|
5515
|
-
|
5516
|
-
|
5517
|
-
|
5518
|
-
|
5519
|
-
|
5520
|
-
|
5502
|
+
// '.git',
|
5503
|
+
// https://pnpm.io/workspaces/
|
5504
|
+
"pnpm-workspace.yaml",
|
5505
|
+
// https://rushjs.io/pages/advanced/config_files/
|
5506
|
+
// 'rush.json',
|
5507
|
+
// https://nx.dev/latest/react/getting-started/nx-setup
|
5508
|
+
// 'workspace.json',
|
5509
|
+
// 'nx.json',
|
5510
|
+
// https://github.com/lerna/lerna#lernajson
|
5511
|
+
"lerna.json"
|
5521
5512
|
];
|
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
5513
|
function hasWorkspacePackageJSON(root) {
|
5525
|
-
|
5526
|
-
|
5527
|
-
|
5528
|
-
|
5529
|
-
|
5530
|
-
|
5531
|
-
|
5532
|
-
|
5533
|
-
|
5534
|
-
|
5535
|
-
}
|
5514
|
+
const path = path$3.join(root, "package.json");
|
5515
|
+
if (!isFileReadable(path)) {
|
5516
|
+
return false;
|
5517
|
+
}
|
5518
|
+
try {
|
5519
|
+
const content = JSON.parse(fs$1.readFileSync(path, "utf-8")) || {};
|
5520
|
+
return !!content.workspaces;
|
5521
|
+
} catch {
|
5522
|
+
return false;
|
5523
|
+
}
|
5536
5524
|
}
|
5537
5525
|
function hasRootFile(root) {
|
5538
|
-
|
5526
|
+
return ROOT_FILES.some((file) => fs$1.existsSync(path$3.join(root, file)));
|
5539
5527
|
}
|
5540
5528
|
function hasPackageJSON(root) {
|
5541
|
-
|
5542
|
-
|
5529
|
+
const path = path$3.join(root, "package.json");
|
5530
|
+
return fs$1.existsSync(path);
|
5543
5531
|
}
|
5544
|
-
/**
|
5545
|
-
* Search up for the nearest `package.json`
|
5546
|
-
*/
|
5547
5532
|
function searchForPackageRoot(current, root = current) {
|
5548
|
-
|
5549
|
-
|
5550
|
-
|
5551
|
-
|
5552
|
-
if (!dir || dir === current)
|
5553
|
-
return root;
|
5554
|
-
return searchForPackageRoot(dir, root);
|
5533
|
+
if (hasPackageJSON(current)) return current;
|
5534
|
+
const dir = path$3.dirname(current);
|
5535
|
+
if (!dir || dir === current) return root;
|
5536
|
+
return searchForPackageRoot(dir, root);
|
5555
5537
|
}
|
5556
|
-
/**
|
5557
|
-
* Search up for the nearest workspace root
|
5558
|
-
*/
|
5559
5538
|
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);
|
5539
|
+
if (hasRootFile(current)) return current;
|
5540
|
+
if (hasWorkspacePackageJSON(current)) return current;
|
5541
|
+
const dir = path$3.dirname(current);
|
5542
|
+
if (!dir || dir === current) return root;
|
5543
|
+
return searchForWorkspaceRoot(dir, root);
|
5569
5544
|
}
|
5570
5545
|
|
5571
|
-
/**
|
5572
|
-
* Check if the url is allowed to be served, via the `server.fs` config.
|
5573
|
-
*/
|
5574
5546
|
function isFileServingAllowed(url, server) {
|
5575
|
-
|
5576
|
-
|
5577
|
-
|
5578
|
-
|
5579
|
-
|
5580
|
-
|
5581
|
-
|
5582
|
-
|
5583
|
-
|
5584
|
-
|
5547
|
+
const { config } = server;
|
5548
|
+
if (!config.server.fs.strict) return true;
|
5549
|
+
const filePath = fsPathFromUrl(url);
|
5550
|
+
return isFileLoadingAllowed(config, filePath);
|
5551
|
+
}
|
5552
|
+
function isUriInFilePath(uri, filePath) {
|
5553
|
+
return isSameFileUri(uri, filePath) || isParentDirectory(uri, filePath);
|
5554
|
+
}
|
5555
|
+
function isFileLoadingAllowed(config, filePath) {
|
5556
|
+
const { fs } = config.server;
|
5557
|
+
if (!fs.strict) return true;
|
5558
|
+
if (config.fsDenyGlob(filePath)) return false;
|
5559
|
+
if (config.safeModulePaths.has(filePath)) return true;
|
5560
|
+
if (fs.allow.some((uri) => isUriInFilePath(uri, filePath))) return true;
|
5561
|
+
return false;
|
5585
5562
|
}
|
5586
5563
|
|
5587
5564
|
var main$1 = {exports: {}};
|
@@ -6117,68 +6094,72 @@ function expand (options) {
|
|
6117
6094
|
var expand_1 = expand;
|
6118
6095
|
|
6119
6096
|
function getEnvFilesForMode(mode, envDir) {
|
6120
|
-
|
6121
|
-
|
6122
|
-
|
6123
|
-
|
6124
|
-
|
6125
|
-
|
6097
|
+
return [
|
6098
|
+
/** default file */
|
6099
|
+
`.env`,
|
6100
|
+
/** local file */
|
6101
|
+
`.env.local`,
|
6102
|
+
/** mode file */
|
6103
|
+
`.env.${mode}`,
|
6104
|
+
/** mode local file */
|
6105
|
+
`.env.${mode}.local`
|
6106
|
+
].map((file) => normalizePath(path$3.join(envDir, file)));
|
6126
6107
|
}
|
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
|
-
}
|
6108
|
+
function loadEnv(mode, envDir, prefixes = "VITE_") {
|
6109
|
+
if (mode === "local") {
|
6110
|
+
throw new Error(
|
6111
|
+
`"local" cannot be used as a mode name because it conflicts with the .local postfix for .env files.`
|
6112
|
+
);
|
6113
|
+
}
|
6114
|
+
prefixes = arraify(prefixes);
|
6115
|
+
const env = {};
|
6116
|
+
const envFiles = getEnvFilesForMode(mode, envDir);
|
6117
|
+
const parsed = Object.fromEntries(
|
6118
|
+
envFiles.flatMap((filePath) => {
|
6119
|
+
if (!tryStatSync(filePath)?.isFile()) return [];
|
6120
|
+
return Object.entries(parse_1(fs$1.readFileSync(filePath)));
|
6121
|
+
})
|
6122
|
+
);
|
6123
|
+
if (parsed.NODE_ENV && process.env.VITE_USER_NODE_ENV === void 0) {
|
6124
|
+
process.env.VITE_USER_NODE_ENV = parsed.NODE_ENV;
|
6125
|
+
}
|
6126
|
+
if (parsed.BROWSER && process.env.BROWSER === void 0) {
|
6127
|
+
process.env.BROWSER = parsed.BROWSER;
|
6128
|
+
}
|
6129
|
+
if (parsed.BROWSER_ARGS && process.env.BROWSER_ARGS === void 0) {
|
6130
|
+
process.env.BROWSER_ARGS = parsed.BROWSER_ARGS;
|
6131
|
+
}
|
6132
|
+
const processEnv = { ...process.env };
|
6133
|
+
expand_1({ parsed, processEnv });
|
6134
|
+
for (const [key, value] of Object.entries(parsed)) {
|
6135
|
+
if (prefixes.some((prefix) => key.startsWith(prefix))) {
|
6136
|
+
env[key] = value;
|
6160
6137
|
}
|
6161
|
-
|
6162
|
-
|
6163
|
-
|
6164
|
-
|
6165
|
-
env[key] = process.env[key];
|
6166
|
-
}
|
6138
|
+
}
|
6139
|
+
for (const key in process.env) {
|
6140
|
+
if (prefixes.some((prefix) => key.startsWith(prefix))) {
|
6141
|
+
env[key] = process.env[key];
|
6167
6142
|
}
|
6168
|
-
|
6143
|
+
}
|
6144
|
+
return env;
|
6169
6145
|
}
|
6170
|
-
function resolveEnvPrefix({
|
6171
|
-
|
6172
|
-
|
6173
|
-
|
6174
|
-
|
6175
|
-
|
6146
|
+
function resolveEnvPrefix({
|
6147
|
+
envPrefix = "VITE_"
|
6148
|
+
}) {
|
6149
|
+
envPrefix = arraify(envPrefix);
|
6150
|
+
if (envPrefix.includes("")) {
|
6151
|
+
throw new Error(
|
6152
|
+
`envPrefix option contains value '', which could lead unexpected exposure of sensitive information.`
|
6153
|
+
);
|
6154
|
+
}
|
6155
|
+
return envPrefix;
|
6176
6156
|
}
|
6177
6157
|
|
6178
6158
|
exports.esbuildVersion = esbuild.version;
|
6179
6159
|
exports.createFilter = createFilter;
|
6180
6160
|
exports.createLogger = createLogger;
|
6181
6161
|
exports.isCSSRequest = isCSSRequest;
|
6162
|
+
exports.isFileLoadingAllowed = isFileLoadingAllowed;
|
6182
6163
|
exports.isFileServingAllowed = isFileServingAllowed;
|
6183
6164
|
exports.loadEnv = loadEnv;
|
6184
6165
|
exports.mergeAlias = mergeAlias;
|