vite 6.0.0-alpha.8 → 6.0.0-beta.0
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 +115 -206
- package/bin/vite.js +1 -1
- package/client.d.ts +12 -0
- package/dist/client/client.mjs +614 -612
- package/dist/client/env.mjs +18 -24
- package/dist/node/chunks/{dep-8PNdpITG.js → dep-Bv1xMYNy.js} +45999 -47654
- package/dist/node/chunks/{dep-m9gtlanK.js → dep-CSD_20z-.js} +1 -1
- package/dist/node/chunks/{dep-CrWVpuYf.js → dep-D-7KCb9p.js} +32 -2
- package/dist/node/chunks/{dep-BJOLgJFH.js → dep-D9t7igss.js} +165 -968
- package/dist/node/cli.js +282 -257
- package/dist/node/constants.js +108 -84
- package/dist/node/index.d.ts +2084 -2035
- package/dist/node/index.js +237 -148
- package/dist/node/module-runner.d.ts +31 -12
- package/dist/node/module-runner.js +262 -204
- package/dist/node-cjs/publicUtils.cjs +679 -717
- package/index.cjs +27 -5
- package/package.json +34 -31
- 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
- package/dist/node/chunks/dep-C7zR1Rh8.js +0 -233
@@ -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,67 @@ 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
|
+
|
178
|
+
black: init("\x1b[30m", "\x1b[39m"),
|
179
|
+
red: init("\x1b[31m", "\x1b[39m"),
|
180
|
+
green: init("\x1b[32m", "\x1b[39m"),
|
181
|
+
yellow: init("\x1b[33m", "\x1b[39m"),
|
182
|
+
blue: init("\x1b[34m", "\x1b[39m"),
|
183
|
+
magenta: init("\x1b[35m", "\x1b[39m"),
|
184
|
+
cyan: init("\x1b[36m", "\x1b[39m"),
|
185
|
+
white: init("\x1b[37m", "\x1b[39m"),
|
186
|
+
gray: init("\x1b[90m", "\x1b[39m"),
|
187
|
+
|
188
|
+
bgBlack: init("\x1b[40m", "\x1b[49m"),
|
189
|
+
bgRed: init("\x1b[41m", "\x1b[49m"),
|
190
|
+
bgGreen: init("\x1b[42m", "\x1b[49m"),
|
191
|
+
bgYellow: init("\x1b[43m", "\x1b[49m"),
|
192
|
+
bgBlue: init("\x1b[44m", "\x1b[49m"),
|
193
|
+
bgMagenta: init("\x1b[45m", "\x1b[49m"),
|
194
|
+
bgCyan: init("\x1b[46m", "\x1b[49m"),
|
195
|
+
bgWhite: init("\x1b[47m", "\x1b[49m"),
|
196
|
+
|
197
|
+
blackBright: init("\x1b[90m", "\x1b[39m"),
|
198
|
+
redBright: init("\x1b[91m", "\x1b[39m"),
|
199
|
+
greenBright: init("\x1b[92m", "\x1b[39m"),
|
200
|
+
yellowBright: init("\x1b[93m", "\x1b[39m"),
|
201
|
+
blueBright: init("\x1b[94m", "\x1b[39m"),
|
202
|
+
magentaBright: init("\x1b[95m", "\x1b[39m"),
|
203
|
+
cyanBright: init("\x1b[96m", "\x1b[39m"),
|
204
|
+
whiteBright: init("\x1b[97m", "\x1b[39m"),
|
205
|
+
|
206
|
+
bgBlackBright: init("\x1b[100m","\x1b[49m"),
|
207
|
+
bgRedBright: init("\x1b[101m","\x1b[49m"),
|
208
|
+
bgGreenBright: init("\x1b[102m","\x1b[49m"),
|
209
|
+
bgYellowBright: init("\x1b[103m","\x1b[49m"),
|
210
|
+
bgBlueBright: init("\x1b[104m","\x1b[49m"),
|
211
|
+
bgMagentaBright: init("\x1b[105m","\x1b[49m"),
|
212
|
+
bgCyanBright: init("\x1b[106m","\x1b[49m"),
|
213
|
+
bgWhiteBright: init("\x1b[107m","\x1b[49m"),
|
214
|
+
}
|
215
|
+
};
|
179
216
|
|
180
217
|
picocolors.exports = createColors();
|
181
218
|
picocolors.exports.createColors = createColors;
|
@@ -218,7 +255,7 @@ function requireMs () {
|
|
218
255
|
* @api public
|
219
256
|
*/
|
220
257
|
|
221
|
-
ms = function(val, options) {
|
258
|
+
ms = function (val, options) {
|
222
259
|
options = options || {};
|
223
260
|
var type = typeof val;
|
224
261
|
if (type === 'string' && val.length > 0) {
|
@@ -773,6 +810,8 @@ function requireBrowser () {
|
|
773
810
|
return false;
|
774
811
|
}
|
775
812
|
|
813
|
+
let m;
|
814
|
+
|
776
815
|
// Is webkit? http://stackoverflow.com/a/16459606/376773
|
777
816
|
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
778
817
|
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
@@ -780,7 +819,7 @@ function requireBrowser () {
|
|
780
819
|
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
781
820
|
// Is firefox >= v31?
|
782
821
|
// 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(
|
822
|
+
(typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
|
784
823
|
// Double check webkit in userAgent just in case we are in a worker
|
785
824
|
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
786
825
|
}
|
@@ -1116,11 +1155,11 @@ function requireNode () {
|
|
1116
1155
|
}
|
1117
1156
|
|
1118
1157
|
/**
|
1119
|
-
* Invokes `util.
|
1158
|
+
* Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
|
1120
1159
|
*/
|
1121
1160
|
|
1122
1161
|
function log(...args) {
|
1123
|
-
return process.stderr.write(util.
|
1162
|
+
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
|
1124
1163
|
}
|
1125
1164
|
|
1126
1165
|
/**
|
@@ -2956,9 +2995,9 @@ const isObject$2 = val => val && typeof val === 'object' && !Array.isArray(val);
|
|
2956
2995
|
* @api public
|
2957
2996
|
*/
|
2958
2997
|
|
2959
|
-
const picomatch$
|
2998
|
+
const picomatch$1 = (glob, options, returnState = false) => {
|
2960
2999
|
if (Array.isArray(glob)) {
|
2961
|
-
const fns = glob.map(input => picomatch$
|
3000
|
+
const fns = glob.map(input => picomatch$1(input, options, returnState));
|
2962
3001
|
const arrayMatcher = str => {
|
2963
3002
|
for (const isMatch of fns) {
|
2964
3003
|
const state = isMatch(str);
|
@@ -2978,8 +3017,8 @@ const picomatch$2 = (glob, options, returnState = false) => {
|
|
2978
3017
|
const opts = options || {};
|
2979
3018
|
const posix = utils.isWindows(options);
|
2980
3019
|
const regex = isState
|
2981
|
-
? picomatch$
|
2982
|
-
: picomatch$
|
3020
|
+
? picomatch$1.compileRe(glob, options)
|
3021
|
+
: picomatch$1.makeRe(glob, options, false, true);
|
2983
3022
|
|
2984
3023
|
const state = regex.state;
|
2985
3024
|
delete regex.state;
|
@@ -2987,11 +3026,11 @@ const picomatch$2 = (glob, options, returnState = false) => {
|
|
2987
3026
|
let isIgnored = () => false;
|
2988
3027
|
if (opts.ignore) {
|
2989
3028
|
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
2990
|
-
isIgnored = picomatch$
|
3029
|
+
isIgnored = picomatch$1(opts.ignore, ignoreOpts, returnState);
|
2991
3030
|
}
|
2992
3031
|
|
2993
3032
|
const matcher = (input, returnObject = false) => {
|
2994
|
-
const { isMatch, match, output } = picomatch$
|
3033
|
+
const { isMatch, match, output } = picomatch$1.test(input, regex, options, { glob, posix });
|
2995
3034
|
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
2996
3035
|
|
2997
3036
|
if (typeof opts.onResult === 'function') {
|
@@ -3041,7 +3080,7 @@ const picomatch$2 = (glob, options, returnState = false) => {
|
|
3041
3080
|
* @api public
|
3042
3081
|
*/
|
3043
3082
|
|
3044
|
-
picomatch$
|
3083
|
+
picomatch$1.test = (input, regex, options, { glob, posix } = {}) => {
|
3045
3084
|
if (typeof input !== 'string') {
|
3046
3085
|
throw new TypeError('Expected input to be a string');
|
3047
3086
|
}
|
@@ -3062,7 +3101,7 @@ picomatch$2.test = (input, regex, options, { glob, posix } = {}) => {
|
|
3062
3101
|
|
3063
3102
|
if (match === false || opts.capture === true) {
|
3064
3103
|
if (opts.matchBase === true || opts.basename === true) {
|
3065
|
-
match = picomatch$
|
3104
|
+
match = picomatch$1.matchBase(input, regex, options, posix);
|
3066
3105
|
} else {
|
3067
3106
|
match = regex.exec(output);
|
3068
3107
|
}
|
@@ -3085,8 +3124,8 @@ picomatch$2.test = (input, regex, options, { glob, posix } = {}) => {
|
|
3085
3124
|
* @api public
|
3086
3125
|
*/
|
3087
3126
|
|
3088
|
-
picomatch$
|
3089
|
-
const regex = glob instanceof RegExp ? glob : picomatch$
|
3127
|
+
picomatch$1.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
|
3128
|
+
const regex = glob instanceof RegExp ? glob : picomatch$1.makeRe(glob, options);
|
3090
3129
|
return regex.test(path$1.basename(input));
|
3091
3130
|
};
|
3092
3131
|
|
@@ -3107,7 +3146,7 @@ picomatch$2.matchBase = (input, glob, options, posix = utils.isWindows(options))
|
|
3107
3146
|
* @api public
|
3108
3147
|
*/
|
3109
3148
|
|
3110
|
-
picomatch$
|
3149
|
+
picomatch$1.isMatch = (str, patterns, options) => picomatch$1(patterns, options)(str);
|
3111
3150
|
|
3112
3151
|
/**
|
3113
3152
|
* Parse a glob pattern to create the source string for a regular
|
@@ -3123,8 +3162,8 @@ picomatch$2.isMatch = (str, patterns, options) => picomatch$2(patterns, options)
|
|
3123
3162
|
* @api public
|
3124
3163
|
*/
|
3125
3164
|
|
3126
|
-
picomatch$
|
3127
|
-
if (Array.isArray(pattern)) return pattern.map(p => picomatch$
|
3165
|
+
picomatch$1.parse = (pattern, options) => {
|
3166
|
+
if (Array.isArray(pattern)) return pattern.map(p => picomatch$1.parse(p, options));
|
3128
3167
|
return parse$1(pattern, { ...options, fastpaths: false });
|
3129
3168
|
};
|
3130
3169
|
|
@@ -3155,7 +3194,7 @@ picomatch$2.parse = (pattern, options) => {
|
|
3155
3194
|
* @api public
|
3156
3195
|
*/
|
3157
3196
|
|
3158
|
-
picomatch$
|
3197
|
+
picomatch$1.scan = (input, options) => scan(input, options);
|
3159
3198
|
|
3160
3199
|
/**
|
3161
3200
|
* Compile a regular expression from the `state` object returned by the
|
@@ -3169,7 +3208,7 @@ picomatch$2.scan = (input, options) => scan(input, options);
|
|
3169
3208
|
* @api public
|
3170
3209
|
*/
|
3171
3210
|
|
3172
|
-
picomatch$
|
3211
|
+
picomatch$1.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
3173
3212
|
if (returnOutput === true) {
|
3174
3213
|
return state.output;
|
3175
3214
|
}
|
@@ -3183,7 +3222,7 @@ picomatch$2.compileRe = (state, options, returnOutput = false, returnState = fal
|
|
3183
3222
|
source = `^(?!${source}).*$`;
|
3184
3223
|
}
|
3185
3224
|
|
3186
|
-
const regex = picomatch$
|
3225
|
+
const regex = picomatch$1.toRegex(source, options);
|
3187
3226
|
if (returnState === true) {
|
3188
3227
|
regex.state = state;
|
3189
3228
|
}
|
@@ -3210,7 +3249,7 @@ picomatch$2.compileRe = (state, options, returnOutput = false, returnState = fal
|
|
3210
3249
|
* @api public
|
3211
3250
|
*/
|
3212
3251
|
|
3213
|
-
picomatch$
|
3252
|
+
picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
3214
3253
|
if (!input || typeof input !== 'string') {
|
3215
3254
|
throw new TypeError('Expected a non-empty string');
|
3216
3255
|
}
|
@@ -3225,7 +3264,7 @@ picomatch$2.makeRe = (input, options = {}, returnOutput = false, returnState = f
|
|
3225
3264
|
parsed = parse$1(input, options);
|
3226
3265
|
}
|
3227
3266
|
|
3228
|
-
return picomatch$
|
3267
|
+
return picomatch$1.compileRe(parsed, options, returnOutput, returnState);
|
3229
3268
|
};
|
3230
3269
|
|
3231
3270
|
/**
|
@@ -3245,7 +3284,7 @@ picomatch$2.makeRe = (input, options = {}, returnOutput = false, returnState = f
|
|
3245
3284
|
* @api public
|
3246
3285
|
*/
|
3247
3286
|
|
3248
|
-
picomatch$
|
3287
|
+
picomatch$1.toRegex = (source, options) => {
|
3249
3288
|
try {
|
3250
3289
|
const opts = options || {};
|
3251
3290
|
return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
|
@@ -3260,17 +3299,17 @@ picomatch$2.toRegex = (source, options) => {
|
|
3260
3299
|
* @return {Object}
|
3261
3300
|
*/
|
3262
3301
|
|
3263
|
-
picomatch$
|
3302
|
+
picomatch$1.constants = constants;
|
3264
3303
|
|
3265
3304
|
/**
|
3266
3305
|
* Expose "picomatch"
|
3267
3306
|
*/
|
3268
3307
|
|
3269
|
-
var picomatch_1 = picomatch$
|
3308
|
+
var picomatch_1 = picomatch$1;
|
3270
3309
|
|
3271
3310
|
var picomatch = picomatch_1;
|
3272
3311
|
|
3273
|
-
var
|
3312
|
+
var pm = /*@__PURE__*/getDefaultExportFromCjs(picomatch);
|
3274
3313
|
|
3275
3314
|
// Helper since Typescript can't detect readonly arrays with Array.isArray
|
3276
3315
|
function isArray(arg) {
|
@@ -3310,7 +3349,7 @@ const createFilter$1 = function createFilter(include, exclude, options) {
|
|
3310
3349
|
test: (what) => {
|
3311
3350
|
// this refactor is a tad overly verbose but makes for easy debugging
|
3312
3351
|
const pattern = getMatcherString(id, resolutionBase);
|
3313
|
-
const fn =
|
3352
|
+
const fn = pm(pattern, { dot: true });
|
3314
3353
|
const result = fn(what);
|
3315
3354
|
return result;
|
3316
3355
|
}
|
@@ -3342,363 +3381,320 @@ const builtins = 'arguments Infinity NaN undefined null true false eval uneval i
|
|
3342
3381
|
const forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(' '));
|
3343
3382
|
forbiddenIdentifiers.add('');
|
3344
3383
|
|
3345
|
-
const isWindows = typeof process !==
|
3384
|
+
const isWindows = typeof process !== "undefined" && process.platform === "win32";
|
3346
3385
|
const windowsSlashRE = /\\/g;
|
3347
3386
|
function slash(p) {
|
3348
|
-
|
3387
|
+
return p.replace(windowsSlashRE, "/");
|
3349
3388
|
}
|
3350
3389
|
const postfixRE = /[?#].*$/;
|
3351
3390
|
function cleanUrl(url) {
|
3352
|
-
|
3391
|
+
return url.replace(postfixRE, "");
|
3353
3392
|
}
|
3354
3393
|
function withTrailingSlash(path) {
|
3355
|
-
|
3356
|
-
|
3357
|
-
|
3358
|
-
|
3394
|
+
if (path[path.length - 1] !== "/") {
|
3395
|
+
return `${path}/`;
|
3396
|
+
}
|
3397
|
+
return path;
|
3359
3398
|
}
|
3360
3399
|
|
3361
3400
|
if (process.versions.pnp) {
|
3362
|
-
|
3363
|
-
|
3364
|
-
|
3365
|
-
|
3401
|
+
try {
|
3402
|
+
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");
|
3403
|
+
} catch {
|
3404
|
+
}
|
3366
3405
|
}
|
3367
3406
|
|
3368
3407
|
const createFilter = createFilter$1;
|
3369
|
-
|
3370
|
-
node_module.builtinModules.filter((id) => !id.includes(':'));
|
3408
|
+
node_module.builtinModules.filter((id) => !id.includes(":"));
|
3371
3409
|
function isInNodeModules(id) {
|
3372
|
-
|
3410
|
+
return id.includes("node_modules");
|
3373
3411
|
}
|
3374
|
-
// TODO: use import()
|
3375
3412
|
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
|
-
|
3413
|
+
function resolveDependencyVersion(dep, pkgRelativePath = "../../package.json") {
|
3414
|
+
const pkgPath = path$3.resolve(_require.resolve(dep), pkgRelativePath);
|
3415
|
+
return JSON.parse(fs$1.readFileSync(pkgPath, "utf-8")).version;
|
3379
3416
|
}
|
3380
|
-
const rollupVersion = resolveDependencyVersion(
|
3381
|
-
// set in bin/vite.js
|
3417
|
+
const rollupVersion = resolveDependencyVersion("rollup");
|
3382
3418
|
const filter = process.env.VITE_DEBUG_FILTER;
|
3383
3419
|
const DEBUG = process.env.DEBUG;
|
3384
3420
|
function createDebugger(namespace, options = {}) {
|
3385
|
-
|
3386
|
-
|
3387
|
-
|
3388
|
-
|
3389
|
-
|
3390
|
-
|
3391
|
-
|
3392
|
-
|
3393
|
-
|
3394
|
-
|
3395
|
-
|
3396
|
-
|
3397
|
-
|
3398
|
-
|
3421
|
+
const log = debug$2(namespace);
|
3422
|
+
const { onlyWhenFocused } = options;
|
3423
|
+
let enabled = log.enabled;
|
3424
|
+
if (enabled && onlyWhenFocused) {
|
3425
|
+
const ns = typeof onlyWhenFocused === "string" ? onlyWhenFocused : namespace;
|
3426
|
+
enabled = !!DEBUG?.includes(ns);
|
3427
|
+
}
|
3428
|
+
if (enabled) {
|
3429
|
+
return (...args) => {
|
3430
|
+
if (!filter || args.some((a) => a?.includes?.(filter))) {
|
3431
|
+
log(...args);
|
3432
|
+
}
|
3433
|
+
};
|
3434
|
+
}
|
3399
3435
|
}
|
3400
3436
|
function testCaseInsensitiveFS() {
|
3401
|
-
|
3402
|
-
|
3403
|
-
|
3404
|
-
|
3405
|
-
|
3406
|
-
|
3407
|
-
|
3408
|
-
|
3437
|
+
if (!CLIENT_ENTRY.endsWith("client.mjs")) {
|
3438
|
+
throw new Error(
|
3439
|
+
`cannot test case insensitive FS, CLIENT_ENTRY const doesn't contain client.mjs`
|
3440
|
+
);
|
3441
|
+
}
|
3442
|
+
if (!fs$1.existsSync(CLIENT_ENTRY)) {
|
3443
|
+
throw new Error(
|
3444
|
+
"cannot test case insensitive FS, CLIENT_ENTRY does not point to an existing file: " + CLIENT_ENTRY
|
3445
|
+
);
|
3446
|
+
}
|
3447
|
+
return fs$1.existsSync(CLIENT_ENTRY.replace("client.mjs", "cLiEnT.mjs"));
|
3409
3448
|
}
|
3410
3449
|
const isCaseInsensitiveFS = testCaseInsensitiveFS();
|
3411
3450
|
const VOLUME_RE = /^[A-Z]:/i;
|
3412
3451
|
function normalizePath(id) {
|
3413
|
-
|
3452
|
+
return path$3.posix.normalize(isWindows ? slash(id) : id);
|
3414
3453
|
}
|
3415
3454
|
function fsPathFromId(id) {
|
3416
|
-
|
3417
|
-
|
3455
|
+
const fsPath = normalizePath(
|
3456
|
+
id.startsWith(FS_PREFIX) ? id.slice(FS_PREFIX.length) : id
|
3457
|
+
);
|
3458
|
+
return fsPath[0] === "/" || VOLUME_RE.test(fsPath) ? fsPath : `/${fsPath}`;
|
3418
3459
|
}
|
3419
3460
|
function fsPathFromUrl(url) {
|
3420
|
-
|
3461
|
+
return fsPathFromId(cleanUrl(url));
|
3421
3462
|
}
|
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
3463
|
function isParentDirectory(dir, file) {
|
3432
|
-
|
3433
|
-
|
3434
|
-
(isCaseInsensitiveFS && file.toLowerCase().startsWith(dir.toLowerCase())));
|
3464
|
+
dir = withTrailingSlash(dir);
|
3465
|
+
return file.startsWith(dir) || isCaseInsensitiveFS && file.toLowerCase().startsWith(dir.toLowerCase());
|
3435
3466
|
}
|
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
3467
|
function isSameFileUri(file1, file2) {
|
3446
|
-
|
3447
|
-
(isCaseInsensitiveFS && file1.toLowerCase() === file2.toLowerCase()));
|
3468
|
+
return file1 === file2 || isCaseInsensitiveFS && file1.toLowerCase() === file2.toLowerCase();
|
3448
3469
|
}
|
3449
3470
|
const trailingSeparatorRE = /[?&]$/;
|
3450
3471
|
const timestampRE = /\bt=\d{13}&?\b/;
|
3451
3472
|
function removeTimestampQuery(url) {
|
3452
|
-
|
3473
|
+
return url.replace(timestampRE, "").replace(trailingSeparatorRE, "");
|
3453
3474
|
}
|
3454
3475
|
function isObject$1(value) {
|
3455
|
-
|
3476
|
+
return Object.prototype.toString.call(value) === "[object Object]";
|
3456
3477
|
}
|
3457
3478
|
function tryStatSync(file) {
|
3458
|
-
|
3459
|
-
|
3460
|
-
|
3461
|
-
|
3462
|
-
catch {
|
3463
|
-
// Ignore errors
|
3464
|
-
}
|
3479
|
+
try {
|
3480
|
+
return fs$1.statSync(file, { throwIfNoEntry: false });
|
3481
|
+
} catch {
|
3482
|
+
}
|
3465
3483
|
}
|
3466
3484
|
function isFileReadable(filename) {
|
3467
|
-
|
3468
|
-
|
3469
|
-
|
3470
|
-
|
3471
|
-
|
3472
|
-
|
3473
|
-
|
3474
|
-
|
3475
|
-
|
3476
|
-
return false;
|
3477
|
-
}
|
3485
|
+
if (!tryStatSync(filename)) {
|
3486
|
+
return false;
|
3487
|
+
}
|
3488
|
+
try {
|
3489
|
+
fs$1.accessSync(filename, fs$1.constants.R_OK);
|
3490
|
+
return true;
|
3491
|
+
} catch {
|
3492
|
+
return false;
|
3493
|
+
}
|
3478
3494
|
}
|
3479
3495
|
function arraify(target) {
|
3480
|
-
|
3496
|
+
return Array.isArray(target) ? target : [target];
|
3481
3497
|
}
|
3482
3498
|
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
3499
|
function backwardCompatibleWorkerPlugins(plugins) {
|
3484
|
-
|
3485
|
-
|
3486
|
-
|
3487
|
-
|
3488
|
-
|
3489
|
-
|
3490
|
-
|
3500
|
+
if (Array.isArray(plugins)) {
|
3501
|
+
return plugins;
|
3502
|
+
}
|
3503
|
+
if (typeof plugins === "function") {
|
3504
|
+
return plugins();
|
3505
|
+
}
|
3506
|
+
return [];
|
3491
3507
|
}
|
3492
3508
|
function mergeConfigRecursively(defaults, overrides, rootPath) {
|
3493
|
-
|
3494
|
-
|
3495
|
-
|
3496
|
-
|
3497
|
-
|
3498
|
-
}
|
3499
|
-
const existing = merged[key];
|
3500
|
-
if (existing == null) {
|
3501
|
-
merged[key] = value;
|
3502
|
-
continue;
|
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;
|
3509
|
+
const merged = { ...defaults };
|
3510
|
+
for (const key in overrides) {
|
3511
|
+
const value = overrides[key];
|
3512
|
+
if (value == null) {
|
3513
|
+
continue;
|
3535
3514
|
}
|
3536
|
-
|
3515
|
+
const existing = merged[key];
|
3516
|
+
if (existing == null) {
|
3517
|
+
merged[key] = value;
|
3518
|
+
continue;
|
3519
|
+
}
|
3520
|
+
if (key === "alias" && (rootPath === "resolve" || rootPath === "")) {
|
3521
|
+
merged[key] = mergeAlias(existing, value);
|
3522
|
+
continue;
|
3523
|
+
} else if (key === "assetsInclude" && rootPath === "") {
|
3524
|
+
merged[key] = [].concat(existing, value);
|
3525
|
+
continue;
|
3526
|
+
} else if (key === "noExternal" && (rootPath === "ssr" || rootPath === "resolve") && (existing === true || value === true)) {
|
3527
|
+
merged[key] = true;
|
3528
|
+
continue;
|
3529
|
+
} else if (key === "plugins" && rootPath === "worker") {
|
3530
|
+
merged[key] = () => [
|
3531
|
+
...backwardCompatibleWorkerPlugins(existing),
|
3532
|
+
...backwardCompatibleWorkerPlugins(value)
|
3533
|
+
];
|
3534
|
+
continue;
|
3535
|
+
} else if (key === "server" && rootPath === "server.hmr") {
|
3536
|
+
merged[key] = value;
|
3537
|
+
continue;
|
3538
|
+
}
|
3539
|
+
if (Array.isArray(existing) || Array.isArray(value)) {
|
3540
|
+
merged[key] = [...arraify(existing), ...arraify(value)];
|
3541
|
+
continue;
|
3542
|
+
}
|
3543
|
+
if (isObject$1(existing) && isObject$1(value)) {
|
3544
|
+
merged[key] = mergeConfigRecursively(
|
3545
|
+
existing,
|
3546
|
+
value,
|
3547
|
+
rootPath ? `${rootPath}.${key}` : key
|
3548
|
+
);
|
3549
|
+
continue;
|
3550
|
+
}
|
3551
|
+
merged[key] = value;
|
3552
|
+
}
|
3553
|
+
return merged;
|
3537
3554
|
}
|
3538
3555
|
function mergeConfig(defaults, overrides, isRoot = true) {
|
3539
|
-
|
3540
|
-
|
3541
|
-
|
3542
|
-
|
3556
|
+
if (typeof defaults === "function" || typeof overrides === "function") {
|
3557
|
+
throw new Error(`Cannot merge config in form of callback`);
|
3558
|
+
}
|
3559
|
+
return mergeConfigRecursively(defaults, overrides, isRoot ? "" : ".");
|
3543
3560
|
}
|
3544
3561
|
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)];
|
3562
|
+
if (!a) return b;
|
3563
|
+
if (!b) return a;
|
3564
|
+
if (isObject$1(a) && isObject$1(b)) {
|
3565
|
+
return { ...a, ...b };
|
3566
|
+
}
|
3567
|
+
return [...normalizeAlias(b), ...normalizeAlias(a)];
|
3555
3568
|
}
|
3556
3569
|
function normalizeAlias(o = []) {
|
3557
|
-
|
3558
|
-
|
3559
|
-
|
3560
|
-
|
3561
|
-
|
3562
|
-
|
3570
|
+
return Array.isArray(o) ? o.map(normalizeSingleAlias) : Object.keys(o).map(
|
3571
|
+
(find) => normalizeSingleAlias({
|
3572
|
+
find,
|
3573
|
+
replacement: o[find]
|
3574
|
+
})
|
3575
|
+
);
|
3563
3576
|
}
|
3564
|
-
|
3565
|
-
|
3566
|
-
|
3567
|
-
|
3568
|
-
|
3569
|
-
|
3570
|
-
|
3571
|
-
|
3572
|
-
|
3573
|
-
|
3574
|
-
|
3575
|
-
|
3576
|
-
|
3577
|
-
|
3578
|
-
|
3579
|
-
|
3580
|
-
|
3577
|
+
function normalizeSingleAlias({
|
3578
|
+
find,
|
3579
|
+
replacement,
|
3580
|
+
customResolver
|
3581
|
+
}) {
|
3582
|
+
if (typeof find === "string" && find[find.length - 1] === "/" && replacement[replacement.length - 1] === "/") {
|
3583
|
+
find = find.slice(0, find.length - 1);
|
3584
|
+
replacement = replacement.slice(0, replacement.length - 1);
|
3585
|
+
}
|
3586
|
+
const alias = {
|
3587
|
+
find,
|
3588
|
+
replacement
|
3589
|
+
};
|
3590
|
+
if (customResolver) {
|
3591
|
+
alias.customResolver = customResolver;
|
3592
|
+
}
|
3593
|
+
return alias;
|
3581
3594
|
}
|
3582
3595
|
|
3583
|
-
|
3584
|
-
//
|
3585
|
-
|
3586
|
-
|
3587
|
-
/\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
3596
|
+
const CSS_LANGS_RE = (
|
3597
|
+
// eslint-disable-next-line regexp/no-unused-capturing-group
|
3598
|
+
/\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/
|
3599
|
+
);
|
3588
3600
|
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
3601
|
class SplitVendorChunkCache {
|
3600
|
-
|
3601
|
-
|
3602
|
-
|
3603
|
-
|
3604
|
-
|
3605
|
-
|
3606
|
-
|
3602
|
+
cache;
|
3603
|
+
constructor() {
|
3604
|
+
this.cache = /* @__PURE__ */ new Map();
|
3605
|
+
}
|
3606
|
+
reset() {
|
3607
|
+
this.cache = /* @__PURE__ */ new Map();
|
3608
|
+
}
|
3607
3609
|
}
|
3608
|
-
/**
|
3609
|
-
* @deprecated use build.rollupOutput.manualChunks or framework specific configuration
|
3610
|
-
*/
|
3611
3610
|
function splitVendorChunk(options = {}) {
|
3612
|
-
|
3613
|
-
|
3614
|
-
|
3615
|
-
|
3616
|
-
|
3617
|
-
|
3618
|
-
}
|
3619
|
-
};
|
3611
|
+
const cache = options.cache ?? new SplitVendorChunkCache();
|
3612
|
+
return (id, { getModuleInfo }) => {
|
3613
|
+
if (isInNodeModules(id) && !isCSSRequest(id) && staticImportedByEntry(id, getModuleInfo, cache.cache)) {
|
3614
|
+
return "vendor";
|
3615
|
+
}
|
3616
|
+
};
|
3620
3617
|
}
|
3621
3618
|
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
|
-
|
3619
|
+
if (cache.has(id)) {
|
3620
|
+
return cache.get(id);
|
3621
|
+
}
|
3622
|
+
if (importStack.includes(id)) {
|
3623
|
+
cache.set(id, false);
|
3624
|
+
return false;
|
3625
|
+
}
|
3626
|
+
const mod = getModuleInfo(id);
|
3627
|
+
if (!mod) {
|
3628
|
+
cache.set(id, false);
|
3629
|
+
return false;
|
3630
|
+
}
|
3631
|
+
if (mod.isEntry) {
|
3632
|
+
cache.set(id, true);
|
3633
|
+
return true;
|
3634
|
+
}
|
3635
|
+
const someImporterIs = mod.importers.some(
|
3636
|
+
(importer) => staticImportedByEntry(
|
3637
|
+
importer,
|
3638
|
+
getModuleInfo,
|
3639
|
+
cache,
|
3640
|
+
importStack.concat(id)
|
3641
|
+
)
|
3642
|
+
);
|
3643
|
+
cache.set(id, someImporterIs);
|
3644
|
+
return someImporterIs;
|
3642
3645
|
}
|
3643
|
-
/**
|
3644
|
-
* @deprecated use build.rollupOutput.manualChunks or framework specific configuration
|
3645
|
-
*/
|
3646
3646
|
function splitVendorChunkPlugin() {
|
3647
|
-
|
3648
|
-
|
3649
|
-
|
3650
|
-
|
3651
|
-
|
3652
|
-
|
3653
|
-
|
3654
|
-
|
3655
|
-
}
|
3647
|
+
const caches = [];
|
3648
|
+
function createSplitVendorChunk(output, config) {
|
3649
|
+
const cache = new SplitVendorChunkCache();
|
3650
|
+
caches.push(cache);
|
3651
|
+
const build = config.build ?? {};
|
3652
|
+
const format = output?.format;
|
3653
|
+
if (!build.ssr && !build.lib && format !== "umd" && format !== "iife") {
|
3654
|
+
return splitVendorChunk({ cache });
|
3656
3655
|
}
|
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
|
-
},
|
3656
|
+
}
|
3657
|
+
return {
|
3658
|
+
name: "vite:split-vendor-chunk",
|
3659
|
+
config(config) {
|
3660
|
+
let outputs = config?.build?.rollupOptions?.output;
|
3661
|
+
if (outputs) {
|
3662
|
+
outputs = arraify(outputs);
|
3663
|
+
for (const output of outputs) {
|
3664
|
+
const viteManualChunks = createSplitVendorChunk(output, config);
|
3665
|
+
if (viteManualChunks) {
|
3666
|
+
if (output.manualChunks) {
|
3667
|
+
if (typeof output.manualChunks === "function") {
|
3668
|
+
const userManualChunks = output.manualChunks;
|
3669
|
+
output.manualChunks = (id, api) => {
|
3670
|
+
return userManualChunks(id, api) ?? viteManualChunks(id, api);
|
3695
3671
|
};
|
3672
|
+
} else {
|
3673
|
+
console.warn(
|
3674
|
+
"(!) the `splitVendorChunk` plugin doesn't have any effect when using the object form of `build.rollupOptions.output.manualChunks`. Consider using the function form instead."
|
3675
|
+
);
|
3676
|
+
}
|
3677
|
+
} else {
|
3678
|
+
output.manualChunks = viteManualChunks;
|
3696
3679
|
}
|
3697
|
-
|
3698
|
-
|
3699
|
-
|
3700
|
-
|
3701
|
-
|
3680
|
+
}
|
3681
|
+
}
|
3682
|
+
} else {
|
3683
|
+
return {
|
3684
|
+
build: {
|
3685
|
+
rollupOptions: {
|
3686
|
+
output: {
|
3687
|
+
manualChunks: createSplitVendorChunk({}, config)
|
3688
|
+
}
|
3689
|
+
}
|
3690
|
+
}
|
3691
|
+
};
|
3692
|
+
}
|
3693
|
+
},
|
3694
|
+
buildStart() {
|
3695
|
+
caches.forEach((cache) => cache.reset());
|
3696
|
+
}
|
3697
|
+
};
|
3702
3698
|
}
|
3703
3699
|
|
3704
3700
|
var convertSourceMap$1 = {};
|
@@ -4827,8 +4823,10 @@ class MagicString {
|
|
4827
4823
|
update(start, end, content, options) {
|
4828
4824
|
if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
|
4829
4825
|
|
4830
|
-
|
4831
|
-
|
4826
|
+
if (this.original.length !== 0) {
|
4827
|
+
while (start < 0) start += this.original.length;
|
4828
|
+
while (end < 0) end += this.original.length;
|
4829
|
+
}
|
4832
4830
|
|
4833
4831
|
if (end > this.original.length) throw new Error('end is out of bounds');
|
4834
4832
|
if (start === end)
|
@@ -4924,8 +4922,10 @@ class MagicString {
|
|
4924
4922
|
}
|
4925
4923
|
|
4926
4924
|
remove(start, end) {
|
4927
|
-
|
4928
|
-
|
4925
|
+
if (this.original.length !== 0) {
|
4926
|
+
while (start < 0) start += this.original.length;
|
4927
|
+
while (end < 0) end += this.original.length;
|
4928
|
+
}
|
4929
4929
|
|
4930
4930
|
if (start === end) return this;
|
4931
4931
|
|
@@ -4948,8 +4948,10 @@ class MagicString {
|
|
4948
4948
|
}
|
4949
4949
|
|
4950
4950
|
reset(start, end) {
|
4951
|
-
|
4952
|
-
|
4951
|
+
if (this.original.length !== 0) {
|
4952
|
+
while (start < 0) start += this.original.length;
|
4953
|
+
while (end < 0) end += this.original.length;
|
4954
|
+
}
|
4953
4955
|
|
4954
4956
|
if (start === end) return this;
|
4955
4957
|
|
@@ -5011,8 +5013,10 @@ class MagicString {
|
|
5011
5013
|
}
|
5012
5014
|
|
5013
5015
|
slice(start = 0, end = this.original.length) {
|
5014
|
-
|
5015
|
-
|
5016
|
+
if (this.original.length !== 0) {
|
5017
|
+
while (start < 0) start += this.original.length;
|
5018
|
+
while (end < 0) end += this.original.length;
|
5019
|
+
}
|
5016
5020
|
|
5017
5021
|
let result = '';
|
5018
5022
|
|
@@ -5318,309 +5322,263 @@ class MagicString {
|
|
5318
5322
|
}
|
5319
5323
|
}
|
5320
5324
|
|
5321
|
-
const debug$1 = createDebugger(
|
5322
|
-
|
5325
|
+
const debug$1 = createDebugger("vite:sourcemap", {
|
5326
|
+
onlyWhenFocused: true
|
5323
5327
|
});
|
5324
5328
|
function genSourceMapUrl(map) {
|
5325
|
-
|
5326
|
-
|
5327
|
-
|
5328
|
-
|
5329
|
+
if (typeof map !== "string") {
|
5330
|
+
map = JSON.stringify(map);
|
5331
|
+
}
|
5332
|
+
return `data:application/json;base64,${Buffer.from(map).toString("base64")}`;
|
5329
5333
|
}
|
5330
5334
|
function getCodeWithSourcemap(type, code, map) {
|
5331
|
-
|
5332
|
-
|
5333
|
-
|
5334
|
-
|
5335
|
-
|
5336
|
-
|
5337
|
-
|
5338
|
-
|
5339
|
-
|
5340
|
-
|
5335
|
+
if (debug$1) {
|
5336
|
+
code += `
|
5337
|
+
/*${JSON.stringify(map, null, 2).replace(/\*\//g, "*\\/")}*/
|
5338
|
+
`;
|
5339
|
+
}
|
5340
|
+
if (type === "js") {
|
5341
|
+
code += `
|
5342
|
+
//# sourceMappingURL=${genSourceMapUrl(map)}`;
|
5343
|
+
} else if (type === "css") {
|
5344
|
+
code += `
|
5345
|
+
/*# sourceMappingURL=${genSourceMapUrl(map)} */`;
|
5346
|
+
}
|
5347
|
+
return code;
|
5341
5348
|
}
|
5342
5349
|
|
5343
|
-
const debug = createDebugger(
|
5344
|
-
|
5350
|
+
const debug = createDebugger("vite:send", {
|
5351
|
+
onlyWhenFocused: true
|
5345
5352
|
});
|
5346
5353
|
const alias = {
|
5347
|
-
|
5348
|
-
|
5349
|
-
|
5350
|
-
|
5354
|
+
js: "text/javascript",
|
5355
|
+
css: "text/css",
|
5356
|
+
html: "text/html",
|
5357
|
+
json: "application/json"
|
5351
5358
|
};
|
5352
5359
|
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
|
-
|
5360
|
+
const {
|
5361
|
+
etag = getEtag(content, { weak: true }),
|
5362
|
+
cacheControl = "no-cache",
|
5363
|
+
headers,
|
5364
|
+
map
|
5365
|
+
} = options;
|
5366
|
+
if (res.writableEnded) {
|
5367
|
+
return;
|
5368
|
+
}
|
5369
|
+
if (req.headers["if-none-match"] === etag) {
|
5370
|
+
res.statusCode = 304;
|
5371
|
+
res.end();
|
5372
|
+
return;
|
5373
|
+
}
|
5374
|
+
res.setHeader("Content-Type", alias[type] || type);
|
5375
|
+
res.setHeader("Cache-Control", cacheControl);
|
5376
|
+
res.setHeader("Etag", etag);
|
5377
|
+
if (headers) {
|
5378
|
+
for (const name in headers) {
|
5379
|
+
res.setHeader(name, headers[name]);
|
5369
5380
|
}
|
5370
|
-
|
5371
|
-
|
5372
|
-
|
5373
|
-
|
5374
|
-
}
|
5381
|
+
}
|
5382
|
+
if (map && "version" in map && map.mappings) {
|
5383
|
+
if (type === "js" || type === "css") {
|
5384
|
+
content = getCodeWithSourcemap(type, content.toString(), map);
|
5375
5385
|
}
|
5376
|
-
|
5377
|
-
|
5378
|
-
|
5379
|
-
|
5380
|
-
|
5381
|
-
|
5382
|
-
|
5383
|
-
|
5384
|
-
|
5385
|
-
|
5386
|
-
|
5387
|
-
|
5388
|
-
|
5389
|
-
|
5390
|
-
|
5391
|
-
|
5392
|
-
}
|
5386
|
+
} else if (type === "js" && (!map || map.mappings !== "")) {
|
5387
|
+
const code = content.toString();
|
5388
|
+
if (convertSourceMap.mapFileCommentRegex.test(code)) {
|
5389
|
+
debug?.(`Skipped injecting fallback sourcemap for ${req.url}`);
|
5390
|
+
} else {
|
5391
|
+
const urlWithoutTimestamp = removeTimestampQuery(req.url);
|
5392
|
+
const ms = new MagicString(code);
|
5393
|
+
content = getCodeWithSourcemap(
|
5394
|
+
type,
|
5395
|
+
code,
|
5396
|
+
ms.generateMap({
|
5397
|
+
source: path$3.basename(urlWithoutTimestamp),
|
5398
|
+
hires: "boundary",
|
5399
|
+
includeContent: true
|
5400
|
+
})
|
5401
|
+
);
|
5393
5402
|
}
|
5394
|
-
|
5395
|
-
|
5396
|
-
|
5403
|
+
}
|
5404
|
+
res.statusCode = 200;
|
5405
|
+
res.end(content);
|
5406
|
+
return;
|
5397
5407
|
}
|
5398
5408
|
|
5399
|
-
/* eslint no-console: 0 */
|
5400
5409
|
const LogLevels = {
|
5401
|
-
|
5402
|
-
|
5403
|
-
|
5404
|
-
|
5410
|
+
silent: 0,
|
5411
|
+
error: 1,
|
5412
|
+
warn: 2,
|
5413
|
+
info: 3
|
5405
5414
|
};
|
5406
5415
|
let lastType;
|
5407
5416
|
let lastMsg;
|
5408
5417
|
let sameCount = 0;
|
5409
5418
|
function clearScreen() {
|
5410
|
-
|
5411
|
-
|
5412
|
-
|
5413
|
-
|
5414
|
-
|
5419
|
+
const repeatCount = process.stdout.rows - 2;
|
5420
|
+
const blank = repeatCount > 0 ? "\n".repeat(repeatCount) : "";
|
5421
|
+
console.log(blank);
|
5422
|
+
readline.cursorTo(process.stdout, 0, 0);
|
5423
|
+
readline.clearScreenDown(process.stdout);
|
5415
5424
|
}
|
5416
|
-
// Only initialize the timeFormatter when the timestamp option is used, and
|
5417
|
-
// reuse it across all loggers
|
5418
5425
|
let timeFormatter;
|
5419
5426
|
function getTimeFormatter() {
|
5420
|
-
|
5421
|
-
|
5422
|
-
|
5423
|
-
|
5424
|
-
|
5425
|
-
|
5427
|
+
timeFormatter ??= new Intl.DateTimeFormat(void 0, {
|
5428
|
+
hour: "numeric",
|
5429
|
+
minute: "numeric",
|
5430
|
+
second: "numeric"
|
5431
|
+
});
|
5432
|
+
return timeFormatter;
|
5426
5433
|
}
|
5427
|
-
function createLogger(level =
|
5428
|
-
|
5429
|
-
|
5434
|
+
function createLogger(level = "info", options = {}) {
|
5435
|
+
if (options.customLogger) {
|
5436
|
+
return options.customLogger;
|
5437
|
+
}
|
5438
|
+
const loggedErrors = /* @__PURE__ */ new WeakSet();
|
5439
|
+
const { prefix = "[vite]", allowClearScreen = true } = options;
|
5440
|
+
const thresh = LogLevels[level];
|
5441
|
+
const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
|
5442
|
+
const clear = canClearScreen ? clearScreen : () => {
|
5443
|
+
};
|
5444
|
+
function format(type, msg, options2 = {}) {
|
5445
|
+
if (options2.timestamp) {
|
5446
|
+
let tag = "";
|
5447
|
+
if (type === "info") {
|
5448
|
+
tag = colors.cyan(colors.bold(prefix));
|
5449
|
+
} else if (type === "warn") {
|
5450
|
+
tag = colors.yellow(colors.bold(prefix));
|
5451
|
+
} else {
|
5452
|
+
tag = colors.red(colors.bold(prefix));
|
5453
|
+
}
|
5454
|
+
const environment = options2.environment ? options2.environment + " " : "";
|
5455
|
+
return `${colors.dim(getTimeFormatter().format(/* @__PURE__ */ new Date()))} ${tag} ${environment}${msg}`;
|
5456
|
+
} else {
|
5457
|
+
return msg;
|
5430
5458
|
}
|
5431
|
-
|
5432
|
-
|
5433
|
-
|
5434
|
-
|
5435
|
-
|
5436
|
-
|
5437
|
-
|
5438
|
-
|
5439
|
-
|
5440
|
-
|
5441
|
-
|
5442
|
-
|
5443
|
-
|
5444
|
-
|
5445
|
-
|
5446
|
-
}
|
5447
|
-
|
5448
|
-
|
5459
|
+
}
|
5460
|
+
function output(type, msg, options2 = {}) {
|
5461
|
+
if (thresh >= LogLevels[type]) {
|
5462
|
+
const method = type === "info" ? "log" : type;
|
5463
|
+
if (options2.error) {
|
5464
|
+
loggedErrors.add(options2.error);
|
5465
|
+
}
|
5466
|
+
if (canClearScreen) {
|
5467
|
+
if (type === lastType && msg === lastMsg) {
|
5468
|
+
sameCount++;
|
5469
|
+
clear();
|
5470
|
+
console[method](
|
5471
|
+
format(type, msg, options2),
|
5472
|
+
colors.yellow(`(x${sameCount + 1})`)
|
5473
|
+
);
|
5474
|
+
} else {
|
5475
|
+
sameCount = 0;
|
5476
|
+
lastMsg = msg;
|
5477
|
+
lastType = type;
|
5478
|
+
if (options2.clear) {
|
5479
|
+
clear();
|
5480
|
+
}
|
5481
|
+
console[method](format(type, msg, options2));
|
5449
5482
|
}
|
5483
|
+
} else {
|
5484
|
+
console[method](format(type, msg, options2));
|
5485
|
+
}
|
5450
5486
|
}
|
5451
|
-
|
5452
|
-
|
5453
|
-
|
5454
|
-
|
5455
|
-
|
5456
|
-
|
5457
|
-
|
5458
|
-
|
5459
|
-
|
5460
|
-
|
5461
|
-
|
5462
|
-
|
5463
|
-
|
5464
|
-
|
5465
|
-
|
5466
|
-
|
5467
|
-
|
5468
|
-
|
5469
|
-
|
5470
|
-
|
5471
|
-
|
5472
|
-
|
5473
|
-
|
5474
|
-
|
5475
|
-
|
5476
|
-
|
5487
|
+
}
|
5488
|
+
const warnedMessages = /* @__PURE__ */ new Set();
|
5489
|
+
const logger = {
|
5490
|
+
hasWarned: false,
|
5491
|
+
info(msg, opts) {
|
5492
|
+
output("info", msg, opts);
|
5493
|
+
},
|
5494
|
+
warn(msg, opts) {
|
5495
|
+
logger.hasWarned = true;
|
5496
|
+
output("warn", msg, opts);
|
5497
|
+
},
|
5498
|
+
warnOnce(msg, opts) {
|
5499
|
+
if (warnedMessages.has(msg)) return;
|
5500
|
+
logger.hasWarned = true;
|
5501
|
+
output("warn", msg, opts);
|
5502
|
+
warnedMessages.add(msg);
|
5503
|
+
},
|
5504
|
+
error(msg, opts) {
|
5505
|
+
logger.hasWarned = true;
|
5506
|
+
output("error", msg, opts);
|
5507
|
+
},
|
5508
|
+
clearScreen(type) {
|
5509
|
+
if (thresh >= LogLevels[type]) {
|
5510
|
+
clear();
|
5511
|
+
}
|
5512
|
+
},
|
5513
|
+
hasErrorLogged(error) {
|
5514
|
+
return loggedErrors.has(error);
|
5477
5515
|
}
|
5478
|
-
|
5479
|
-
|
5480
|
-
hasWarned: false,
|
5481
|
-
info(msg, opts) {
|
5482
|
-
output('info', msg, opts);
|
5483
|
-
},
|
5484
|
-
warn(msg, opts) {
|
5485
|
-
logger.hasWarned = true;
|
5486
|
-
output('warn', msg, opts);
|
5487
|
-
},
|
5488
|
-
warnOnce(msg, opts) {
|
5489
|
-
if (warnedMessages.has(msg))
|
5490
|
-
return;
|
5491
|
-
logger.hasWarned = true;
|
5492
|
-
output('warn', msg, opts);
|
5493
|
-
warnedMessages.add(msg);
|
5494
|
-
},
|
5495
|
-
error(msg, opts) {
|
5496
|
-
logger.hasWarned = true;
|
5497
|
-
output('error', msg, opts);
|
5498
|
-
},
|
5499
|
-
clearScreen(type) {
|
5500
|
-
if (thresh >= LogLevels[type]) {
|
5501
|
-
clear();
|
5502
|
-
}
|
5503
|
-
},
|
5504
|
-
hasErrorLogged(error) {
|
5505
|
-
return loggedErrors.has(error);
|
5506
|
-
},
|
5507
|
-
};
|
5508
|
-
return logger;
|
5516
|
+
};
|
5517
|
+
return logger;
|
5509
5518
|
}
|
5510
5519
|
|
5511
|
-
// https://github.com/vitejs/vite/issues/2820#issuecomment-812495079
|
5512
5520
|
const ROOT_FILES = [
|
5513
|
-
|
5514
|
-
|
5515
|
-
|
5516
|
-
|
5517
|
-
|
5518
|
-
|
5519
|
-
|
5520
|
-
|
5521
|
-
|
5522
|
-
|
5521
|
+
// '.git',
|
5522
|
+
// https://pnpm.io/workspaces/
|
5523
|
+
"pnpm-workspace.yaml",
|
5524
|
+
// https://rushjs.io/pages/advanced/config_files/
|
5525
|
+
// 'rush.json',
|
5526
|
+
// https://nx.dev/latest/react/getting-started/nx-setup
|
5527
|
+
// 'workspace.json',
|
5528
|
+
// 'nx.json',
|
5529
|
+
// https://github.com/lerna/lerna#lernajson
|
5530
|
+
"lerna.json"
|
5523
5531
|
];
|
5524
|
-
// npm: https://docs.npmjs.com/cli/v7/using-npm/workspaces#installing-workspaces
|
5525
|
-
// yarn: https://classic.yarnpkg.com/en/docs/workspaces/#toc-how-to-use-it
|
5526
5532
|
function hasWorkspacePackageJSON(root) {
|
5527
|
-
|
5528
|
-
|
5529
|
-
|
5530
|
-
|
5531
|
-
|
5532
|
-
|
5533
|
-
|
5534
|
-
|
5535
|
-
|
5536
|
-
|
5537
|
-
}
|
5533
|
+
const path = path$3.join(root, "package.json");
|
5534
|
+
if (!isFileReadable(path)) {
|
5535
|
+
return false;
|
5536
|
+
}
|
5537
|
+
try {
|
5538
|
+
const content = JSON.parse(fs$1.readFileSync(path, "utf-8")) || {};
|
5539
|
+
return !!content.workspaces;
|
5540
|
+
} catch {
|
5541
|
+
return false;
|
5542
|
+
}
|
5538
5543
|
}
|
5539
5544
|
function hasRootFile(root) {
|
5540
|
-
|
5545
|
+
return ROOT_FILES.some((file) => fs$1.existsSync(path$3.join(root, file)));
|
5541
5546
|
}
|
5542
5547
|
function hasPackageJSON(root) {
|
5543
|
-
|
5544
|
-
|
5548
|
+
const path = path$3.join(root, "package.json");
|
5549
|
+
return fs$1.existsSync(path);
|
5545
5550
|
}
|
5546
|
-
/**
|
5547
|
-
* Search up for the nearest `package.json`
|
5548
|
-
*/
|
5549
5551
|
function searchForPackageRoot(current, root = current) {
|
5550
|
-
|
5551
|
-
|
5552
|
-
|
5553
|
-
|
5554
|
-
if (!dir || dir === current)
|
5555
|
-
return root;
|
5556
|
-
return searchForPackageRoot(dir, root);
|
5552
|
+
if (hasPackageJSON(current)) return current;
|
5553
|
+
const dir = path$3.dirname(current);
|
5554
|
+
if (!dir || dir === current) return root;
|
5555
|
+
return searchForPackageRoot(dir, root);
|
5557
5556
|
}
|
5558
|
-
/**
|
5559
|
-
* Search up for the nearest workspace root
|
5560
|
-
*/
|
5561
5557
|
function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
|
5562
|
-
|
5563
|
-
|
5564
|
-
|
5565
|
-
|
5566
|
-
|
5567
|
-
// reach the fs root
|
5568
|
-
if (!dir || dir === current)
|
5569
|
-
return root;
|
5570
|
-
return searchForWorkspaceRoot(dir, root);
|
5558
|
+
if (hasRootFile(current)) return current;
|
5559
|
+
if (hasWorkspacePackageJSON(current)) return current;
|
5560
|
+
const dir = path$3.dirname(current);
|
5561
|
+
if (!dir || dir === current) return root;
|
5562
|
+
return searchForWorkspaceRoot(dir, root);
|
5571
5563
|
}
|
5572
5564
|
|
5573
|
-
|
5574
|
-
|
5575
|
-
|
5576
|
-
|
5577
|
-
|
5578
|
-
|
5579
|
-
}
|
5580
|
-
return safeModulePaths.has(filePath);
|
5581
|
-
}
|
5582
|
-
const fsDenyGlobCache = new WeakMap();
|
5583
|
-
function fsDenyGlob(config, filePath) {
|
5584
|
-
let matcher = fsDenyGlobCache.get(config);
|
5585
|
-
if (!matcher) {
|
5586
|
-
(matcher = picomatch$1(
|
5587
|
-
// matchBase: true does not work as it's documented
|
5588
|
-
// https://github.com/micromatch/picomatch/issues/89
|
5589
|
-
// convert patterns without `/` on our side for now
|
5590
|
-
config.server.fs.deny.map((pattern) => pattern.includes('/') ? pattern : `**/${pattern}`), {
|
5591
|
-
matchBase: false,
|
5592
|
-
nocase: true,
|
5593
|
-
dot: true,
|
5594
|
-
})),
|
5595
|
-
fsDenyGlobCache.set(config, matcher);
|
5596
|
-
}
|
5597
|
-
return matcher(filePath);
|
5598
|
-
}
|
5599
|
-
/**
|
5600
|
-
* Check if the url is allowed to be served, via the `server.fs` config.
|
5601
|
-
* @deprecate use isFileLoadingAllowed
|
5602
|
-
*/
|
5603
|
-
function isFileServingAllowed(url, server) {
|
5604
|
-
const { config } = server;
|
5605
|
-
if (!config.server.fs.strict)
|
5606
|
-
return true;
|
5607
|
-
const filePath = fsPathFromUrl(url);
|
5608
|
-
return isFileLoadingAllowed(config, filePath);
|
5565
|
+
function isFileServingAllowed(configOrUrl, urlOrServer) {
|
5566
|
+
const config = typeof urlOrServer === "string" ? configOrUrl : urlOrServer.config;
|
5567
|
+
const url = typeof urlOrServer === "string" ? urlOrServer : configOrUrl;
|
5568
|
+
if (!config.server.fs.strict) return true;
|
5569
|
+
const filePath = fsPathFromUrl(url);
|
5570
|
+
return isFileLoadingAllowed(config, filePath);
|
5609
5571
|
}
|
5610
5572
|
function isUriInFilePath(uri, filePath) {
|
5611
|
-
|
5573
|
+
return isSameFileUri(uri, filePath) || isParentDirectory(uri, filePath);
|
5612
5574
|
}
|
5613
5575
|
function isFileLoadingAllowed(config, filePath) {
|
5614
|
-
|
5615
|
-
|
5616
|
-
|
5617
|
-
|
5618
|
-
|
5619
|
-
|
5620
|
-
return true;
|
5621
|
-
if (fs.allow.some((uri) => isUriInFilePath(uri, filePath)))
|
5622
|
-
return true;
|
5623
|
-
return false;
|
5576
|
+
const { fs } = config.server;
|
5577
|
+
if (!fs.strict) return true;
|
5578
|
+
if (config.fsDenyGlob(filePath)) return false;
|
5579
|
+
if (config.safeModulePaths.has(filePath)) return true;
|
5580
|
+
if (fs.allow.some((uri) => isUriInFilePath(uri, filePath))) return true;
|
5581
|
+
return false;
|
5624
5582
|
}
|
5625
5583
|
|
5626
5584
|
var main$1 = {exports: {}};
|
@@ -6156,68 +6114,72 @@ function expand (options) {
|
|
6156
6114
|
var expand_1 = expand;
|
6157
6115
|
|
6158
6116
|
function getEnvFilesForMode(mode, envDir) {
|
6159
|
-
|
6160
|
-
|
6161
|
-
|
6162
|
-
|
6163
|
-
|
6164
|
-
|
6117
|
+
return [
|
6118
|
+
/** default file */
|
6119
|
+
`.env`,
|
6120
|
+
/** local file */
|
6121
|
+
`.env.local`,
|
6122
|
+
/** mode file */
|
6123
|
+
`.env.${mode}`,
|
6124
|
+
/** mode local file */
|
6125
|
+
`.env.${mode}.local`
|
6126
|
+
].map((file) => normalizePath(path$3.join(envDir, file)));
|
6165
6127
|
}
|
6166
|
-
function loadEnv(mode, envDir, prefixes =
|
6167
|
-
|
6168
|
-
|
6169
|
-
|
6170
|
-
|
6171
|
-
|
6172
|
-
|
6173
|
-
|
6174
|
-
|
6175
|
-
|
6176
|
-
|
6177
|
-
|
6178
|
-
|
6179
|
-
|
6180
|
-
|
6181
|
-
|
6182
|
-
|
6183
|
-
|
6184
|
-
|
6185
|
-
|
6186
|
-
|
6187
|
-
|
6188
|
-
|
6189
|
-
|
6190
|
-
|
6191
|
-
|
6192
|
-
|
6193
|
-
|
6194
|
-
|
6195
|
-
for (const [key, value] of Object.entries(parsed)) {
|
6196
|
-
if (prefixes.some((prefix) => key.startsWith(prefix))) {
|
6197
|
-
env[key] = value;
|
6198
|
-
}
|
6128
|
+
function loadEnv(mode, envDir, prefixes = "VITE_") {
|
6129
|
+
if (mode === "local") {
|
6130
|
+
throw new Error(
|
6131
|
+
`"local" cannot be used as a mode name because it conflicts with the .local postfix for .env files.`
|
6132
|
+
);
|
6133
|
+
}
|
6134
|
+
prefixes = arraify(prefixes);
|
6135
|
+
const env = {};
|
6136
|
+
const envFiles = getEnvFilesForMode(mode, envDir);
|
6137
|
+
const parsed = Object.fromEntries(
|
6138
|
+
envFiles.flatMap((filePath) => {
|
6139
|
+
if (!tryStatSync(filePath)?.isFile()) return [];
|
6140
|
+
return Object.entries(parse_1(fs$1.readFileSync(filePath)));
|
6141
|
+
})
|
6142
|
+
);
|
6143
|
+
if (parsed.NODE_ENV && process.env.VITE_USER_NODE_ENV === void 0) {
|
6144
|
+
process.env.VITE_USER_NODE_ENV = parsed.NODE_ENV;
|
6145
|
+
}
|
6146
|
+
if (parsed.BROWSER && process.env.BROWSER === void 0) {
|
6147
|
+
process.env.BROWSER = parsed.BROWSER;
|
6148
|
+
}
|
6149
|
+
if (parsed.BROWSER_ARGS && process.env.BROWSER_ARGS === void 0) {
|
6150
|
+
process.env.BROWSER_ARGS = parsed.BROWSER_ARGS;
|
6151
|
+
}
|
6152
|
+
const processEnv = { ...process.env };
|
6153
|
+
expand_1({ parsed, processEnv });
|
6154
|
+
for (const [key, value] of Object.entries(parsed)) {
|
6155
|
+
if (prefixes.some((prefix) => key.startsWith(prefix))) {
|
6156
|
+
env[key] = value;
|
6199
6157
|
}
|
6200
|
-
|
6201
|
-
|
6202
|
-
|
6203
|
-
|
6204
|
-
env[key] = process.env[key];
|
6205
|
-
}
|
6158
|
+
}
|
6159
|
+
for (const key in process.env) {
|
6160
|
+
if (prefixes.some((prefix) => key.startsWith(prefix))) {
|
6161
|
+
env[key] = process.env[key];
|
6206
6162
|
}
|
6207
|
-
|
6163
|
+
}
|
6164
|
+
return env;
|
6208
6165
|
}
|
6209
|
-
function resolveEnvPrefix({
|
6210
|
-
|
6211
|
-
|
6212
|
-
|
6213
|
-
|
6214
|
-
|
6166
|
+
function resolveEnvPrefix({
|
6167
|
+
envPrefix = "VITE_"
|
6168
|
+
}) {
|
6169
|
+
envPrefix = arraify(envPrefix);
|
6170
|
+
if (envPrefix.includes("")) {
|
6171
|
+
throw new Error(
|
6172
|
+
`envPrefix option contains value '', which could lead unexpected exposure of sensitive information.`
|
6173
|
+
);
|
6174
|
+
}
|
6175
|
+
return envPrefix;
|
6215
6176
|
}
|
6216
6177
|
|
6217
6178
|
exports.esbuildVersion = esbuild.version;
|
6218
6179
|
exports.createFilter = createFilter;
|
6219
6180
|
exports.createLogger = createLogger;
|
6220
6181
|
exports.isCSSRequest = isCSSRequest;
|
6182
|
+
exports.isFileLoadingAllowed = isFileLoadingAllowed;
|
6221
6183
|
exports.isFileServingAllowed = isFileServingAllowed;
|
6222
6184
|
exports.loadEnv = loadEnv;
|
6223
6185
|
exports.mergeAlias = mergeAlias;
|