vite 8.2.2 → 8.3.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/bin/vite.js +17 -6
- package/dist/client/bundledDevClient.mjs +70 -42
- package/dist/client/client.mjs +288 -260
- package/dist/node/chunks/node.js +30385 -30111
- package/dist/node/cli.js +11 -7
- package/dist/node/index.d.ts +1565 -1522
- package/dist/node/index.js +1 -1
- package/dist/node/module-runner.d.ts +1 -1
- package/dist/node/module-runner.js +191 -194
- package/package.json +12 -12
- package/types/customEvent.d.ts +8 -0
- package/types/hmrPayload.d.ts +8 -0
- package/types/internal/cssPreprocessorOptions.d.ts +2 -2
package/bin/vite.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { performance } from 'node:perf_hooks'
|
|
3
2
|
import module from 'node:module'
|
|
3
|
+
import { performance } from 'node:perf_hooks'
|
|
4
4
|
|
|
5
5
|
if (!import.meta.url.includes('node_modules')) {
|
|
6
6
|
if (!process.env.DEBUG_DISABLE_SOURCE_MAP) {
|
|
@@ -20,7 +20,9 @@ const debugIndex = process.argv.findIndex((arg) => /^(?:-d|--debug)$/.test(arg))
|
|
|
20
20
|
const filterIndex = process.argv.findIndex((arg) =>
|
|
21
21
|
/^(?:-f|--filter)$/.test(arg),
|
|
22
22
|
)
|
|
23
|
-
const profileIndex = process.argv.
|
|
23
|
+
const profileIndex = process.argv.findIndex(
|
|
24
|
+
(arg) => arg === '--profile' || arg.startsWith('--profile='),
|
|
25
|
+
)
|
|
24
26
|
|
|
25
27
|
if (debugIndex > 0) {
|
|
26
28
|
let value = process.argv[debugIndex + 1]
|
|
@@ -63,10 +65,19 @@ function start() {
|
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
if (profileIndex > 0) {
|
|
66
|
-
process.argv.splice(profileIndex, 1)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
const [profileArg] = process.argv.splice(profileIndex, 1)
|
|
69
|
+
// `--profile [name]` writes the profile to `<name>.cpuprofile`. The value is
|
|
70
|
+
// optional and consumed like cac does for other `[optional]` value flags.
|
|
71
|
+
let profileName = profileArg.slice('--profile='.length)
|
|
72
|
+
if (!profileName) {
|
|
73
|
+
const next = process.argv[profileIndex]
|
|
74
|
+
if (next && next[0] !== '-') {
|
|
75
|
+
process.argv.splice(profileIndex, 1)
|
|
76
|
+
profileName = next
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (profileName) {
|
|
80
|
+
global.__vite_profile_name = profileName
|
|
70
81
|
}
|
|
71
82
|
const inspector = await import('node:inspector').then((r) => r.default)
|
|
72
83
|
const session = (global.__vite_profile_session = new inspector.Session())
|
|
@@ -8,7 +8,7 @@ let nanoid = (size = 21) => {
|
|
|
8
8
|
return id;
|
|
9
9
|
};
|
|
10
10
|
//#endregion
|
|
11
|
-
//#region ../../node_modules/.pnpm/rolldown@1.2.
|
|
11
|
+
//#region ../../node_modules/.pnpm/rolldown@1.2.6/node_modules/rolldown/dist/experimental-runtime-base.mjs
|
|
12
12
|
var __create = Object.create;
|
|
13
13
|
var __defProp = Object.defineProperty;
|
|
14
14
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -41,7 +41,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
41
41
|
}) : target, mod));
|
|
42
42
|
var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
43
43
|
//#endregion
|
|
44
|
-
//#region \0@oxc-project+runtime@0.
|
|
44
|
+
//#region \0@oxc-project+runtime@0.147.0/helpers/esm/typeof.js
|
|
45
45
|
function _typeof(o) {
|
|
46
46
|
"@babel/helpers - typeof";
|
|
47
47
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -51,7 +51,7 @@ function _typeof(o) {
|
|
|
51
51
|
}, _typeof(o);
|
|
52
52
|
}
|
|
53
53
|
//#endregion
|
|
54
|
-
//#region \0@oxc-project+runtime@0.
|
|
54
|
+
//#region \0@oxc-project+runtime@0.147.0/helpers/esm/toPrimitive.js
|
|
55
55
|
function toPrimitive(t, r) {
|
|
56
56
|
if ("object" != _typeof(t) || !t) return t;
|
|
57
57
|
var e = t[Symbol.toPrimitive];
|
|
@@ -63,13 +63,13 @@ function toPrimitive(t, r) {
|
|
|
63
63
|
return ("string" === r ? String : Number)(t);
|
|
64
64
|
}
|
|
65
65
|
//#endregion
|
|
66
|
-
//#region \0@oxc-project+runtime@0.
|
|
66
|
+
//#region \0@oxc-project+runtime@0.147.0/helpers/esm/toPropertyKey.js
|
|
67
67
|
function toPropertyKey(t) {
|
|
68
68
|
var i = toPrimitive(t, "string");
|
|
69
69
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
70
70
|
}
|
|
71
71
|
//#endregion
|
|
72
|
-
//#region \0@oxc-project+runtime@0.
|
|
72
|
+
//#region \0@oxc-project+runtime@0.147.0/helpers/esm/defineProperty.js
|
|
73
73
|
function _defineProperty(e, r, t) {
|
|
74
74
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
75
75
|
value: t,
|
|
@@ -79,7 +79,7 @@ function _defineProperty(e, r, t) {
|
|
|
79
79
|
}) : e[r] = t, e;
|
|
80
80
|
}
|
|
81
81
|
//#endregion
|
|
82
|
-
//#region ../../node_modules/.pnpm/rolldown@1.2.
|
|
82
|
+
//#region ../../node_modules/.pnpm/rolldown@1.2.6/node_modules/rolldown/dist/experimental-runtime.mjs
|
|
83
83
|
var Module = class {
|
|
84
84
|
/**
|
|
85
85
|
* @param {string} id
|
|
@@ -287,9 +287,9 @@ var DevRuntime = class {
|
|
|
287
287
|
}
|
|
288
288
|
/**
|
|
289
289
|
* @param {string} id
|
|
290
|
-
* @param {{ exports: any }} exportsHolder
|
|
290
|
+
* @param {{ exports: any }} [exportsHolder]
|
|
291
291
|
*/
|
|
292
|
-
registerModule(id, exportsHolder) {
|
|
292
|
+
registerModule(id, exportsHolder = { exports: {} }) {
|
|
293
293
|
const module = new Module(id);
|
|
294
294
|
module.exportsHolder = exportsHolder;
|
|
295
295
|
this.moduleCache.set(id, module);
|
|
@@ -782,9 +782,33 @@ var BundledDevHMRContext = class extends HMRContext {
|
|
|
782
782
|
};
|
|
783
783
|
//#endregion
|
|
784
784
|
//#region src/shared/constants.ts
|
|
785
|
+
/**
|
|
786
|
+
* Prefix for resolved Ids that are not valid browser import specifiers
|
|
787
|
+
*/
|
|
788
|
+
const VALID_ID_PREFIX = `/@id/`;
|
|
789
|
+
/**
|
|
790
|
+
* Plugins that use 'virtual modules' (e.g. for helper functions), prefix the
|
|
791
|
+
* module ID with `\0`, a convention from the rollup ecosystem.
|
|
792
|
+
* This prevents other plugins from trying to process the id (like node resolution),
|
|
793
|
+
* and core features like sourcemaps can use this info to differentiate between
|
|
794
|
+
* virtual modules and regular files.
|
|
795
|
+
* `\0` is not a permitted char in import URLs so we have to replace them during
|
|
796
|
+
* import analysis. The id will be decoded back before entering the plugins pipeline.
|
|
797
|
+
* These encoded virtual ids are also prefixed by the VALID_ID_PREFIX, so virtual
|
|
798
|
+
* modules in the browser end up encoded as `/@id/__x00__{id}`
|
|
799
|
+
*/
|
|
800
|
+
const NULL_BYTE_PLACEHOLDER = `__x00__`;
|
|
785
801
|
let SOURCEMAPPING_URL = "sourceMa";
|
|
786
802
|
SOURCEMAPPING_URL += "ppingURL";
|
|
787
803
|
typeof process !== "undefined" && process.platform;
|
|
804
|
+
/**
|
|
805
|
+
* Prepend `/@id/` and replace null byte so the id is URL-safe.
|
|
806
|
+
* This is prepended to resolved ids that are not valid browser
|
|
807
|
+
* import specifiers by the importAnalysis plugin.
|
|
808
|
+
*/
|
|
809
|
+
function wrapId(id) {
|
|
810
|
+
return id.startsWith(VALID_ID_PREFIX) ? id : VALID_ID_PREFIX + id.replace("\0", NULL_BYTE_PLACEHOLDER);
|
|
811
|
+
}
|
|
788
812
|
(async function() {}).constructor;
|
|
789
813
|
function promiseWithResolvers() {
|
|
790
814
|
let resolve;
|
|
@@ -1002,39 +1026,6 @@ const createWebSocketModuleRunnerTransport = (options) => {
|
|
|
1002
1026
|
};
|
|
1003
1027
|
};
|
|
1004
1028
|
//#endregion
|
|
1005
|
-
//#region src/shared/hmrHandler.ts
|
|
1006
|
-
function createHMRHandler(handler) {
|
|
1007
|
-
const queue = new Queue();
|
|
1008
|
-
return (payload) => queue.enqueue(() => handler(payload));
|
|
1009
|
-
}
|
|
1010
|
-
var Queue = class {
|
|
1011
|
-
constructor() {
|
|
1012
|
-
_defineProperty(this, "queue", []);
|
|
1013
|
-
_defineProperty(this, "pending", false);
|
|
1014
|
-
}
|
|
1015
|
-
enqueue(promise) {
|
|
1016
|
-
return new Promise((resolve, reject) => {
|
|
1017
|
-
this.queue.push({
|
|
1018
|
-
promise,
|
|
1019
|
-
resolve,
|
|
1020
|
-
reject
|
|
1021
|
-
});
|
|
1022
|
-
this.dequeue();
|
|
1023
|
-
});
|
|
1024
|
-
}
|
|
1025
|
-
dequeue() {
|
|
1026
|
-
if (this.pending) return false;
|
|
1027
|
-
const item = this.queue.shift();
|
|
1028
|
-
if (!item) return false;
|
|
1029
|
-
this.pending = true;
|
|
1030
|
-
item.promise().then(item.resolve).catch(item.reject).finally(() => {
|
|
1031
|
-
this.pending = false;
|
|
1032
|
-
this.dequeue();
|
|
1033
|
-
});
|
|
1034
|
-
return true;
|
|
1035
|
-
}
|
|
1036
|
-
};
|
|
1037
|
-
//#endregion
|
|
1038
1029
|
//#region src/shared/forwardConsole.ts
|
|
1039
1030
|
function setupForwardConsoleHandler(transport, options, console = globalThis.console) {
|
|
1040
1031
|
if (!options.enabled) return;
|
|
@@ -1163,6 +1154,39 @@ function stringifyConsoleArg(value) {
|
|
|
1163
1154
|
}
|
|
1164
1155
|
}
|
|
1165
1156
|
//#endregion
|
|
1157
|
+
//#region src/shared/hmrHandler.ts
|
|
1158
|
+
function createHMRHandler(handler) {
|
|
1159
|
+
const queue = new Queue();
|
|
1160
|
+
return (payload) => queue.enqueue(() => handler(payload));
|
|
1161
|
+
}
|
|
1162
|
+
var Queue = class {
|
|
1163
|
+
constructor() {
|
|
1164
|
+
_defineProperty(this, "queue", []);
|
|
1165
|
+
_defineProperty(this, "pending", false);
|
|
1166
|
+
}
|
|
1167
|
+
enqueue(promise) {
|
|
1168
|
+
return new Promise((resolve, reject) => {
|
|
1169
|
+
this.queue.push({
|
|
1170
|
+
promise,
|
|
1171
|
+
resolve,
|
|
1172
|
+
reject
|
|
1173
|
+
});
|
|
1174
|
+
this.dequeue();
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
dequeue() {
|
|
1178
|
+
if (this.pending) return false;
|
|
1179
|
+
const item = this.queue.shift();
|
|
1180
|
+
if (!item) return false;
|
|
1181
|
+
this.pending = true;
|
|
1182
|
+
item.promise().then(item.resolve).catch(item.reject).finally(() => {
|
|
1183
|
+
this.pending = false;
|
|
1184
|
+
this.dequeue();
|
|
1185
|
+
});
|
|
1186
|
+
return true;
|
|
1187
|
+
}
|
|
1188
|
+
};
|
|
1189
|
+
//#endregion
|
|
1166
1190
|
//#region src/client/overlay.ts
|
|
1167
1191
|
const hmrConfigName = __HMR_CONFIG_NAME__;
|
|
1168
1192
|
const base$1 = __BASE__ || "/";
|
|
@@ -1480,14 +1504,18 @@ const debounceReload = (time) => {
|
|
|
1480
1504
|
};
|
|
1481
1505
|
};
|
|
1482
1506
|
const pageReload = debounceReload(20);
|
|
1507
|
+
function wrapIdIfNeeded(id) {
|
|
1508
|
+
return id[0] === "." || id[0] === "/" ? id : wrapId(id);
|
|
1509
|
+
}
|
|
1483
1510
|
const hmrClient = new HMRClient({
|
|
1484
1511
|
error: (err) => console.error("[vite]", err),
|
|
1485
1512
|
debug: (...msg) => console.debug("[vite]", ...msg)
|
|
1486
1513
|
}, transport, async function importUpdatedModule({ acceptedPath, timestamp, explicitImportRequired, isWithinCircularImport }) {
|
|
1487
1514
|
const [acceptedPathWithoutQuery, query] = acceptedPath.split(`?`);
|
|
1515
|
+
const browserPath = wrapIdIfNeeded(acceptedPathWithoutQuery);
|
|
1488
1516
|
const importPromise = import(
|
|
1489
1517
|
/* @vite-ignore */
|
|
1490
|
-
base +
|
|
1518
|
+
base + browserPath.slice(1) + `?${explicitImportRequired ? "import&" : ""}t=${timestamp}${query ? `&${query}` : ""}`
|
|
1491
1519
|
);
|
|
1492
1520
|
if (isWithinCircularImport) importPromise.catch(() => {
|
|
1493
1521
|
console.info(`[hmr] ${acceptedPath} failed to apply HMR as it's within a circular import. Reloading page to reset the execution order. To debug and break the circular import, you can run \`vite --debug hmr\` to log the circular dependency path if a file change triggered it.`);
|