vite 8.2.0-beta.0 → 8.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md CHANGED
@@ -1256,7 +1256,7 @@ Repository: https://github.com/lydell/js-tokens
1256
1256
 
1257
1257
  > The MIT License (MIT)
1258
1258
  >
1259
- > Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 Simon Lydell
1259
+ > Copyright (c) 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025 Simon Lydell
1260
1260
  >
1261
1261
  > Permission is hereby granted, free of charge, to any person obtaining a copy
1262
1262
  > of this software and associated documentation files (the "Software"), to deal
@@ -8,7 +8,40 @@ let nanoid = (size = 21) => {
8
8
  return id;
9
9
  };
10
10
  //#endregion
11
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
11
+ //#region ../../node_modules/.pnpm/rolldown@1.2.1/node_modules/rolldown/dist/experimental-runtime-base.mjs
12
+ var __create = Object.create;
13
+ var __defProp = Object.defineProperty;
14
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
+ var __getOwnPropNames = Object.getOwnPropertyNames;
16
+ var __getProtoOf = Object.getPrototypeOf;
17
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
18
+ var __exportAll = (all, no_symbols) => {
19
+ let target = {};
20
+ for (var name in all) __defProp(target, name, {
21
+ get: all[name],
22
+ enumerable: true
23
+ });
24
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
25
+ return target;
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
29
+ key = keys[i];
30
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
31
+ get: ((k) => from[k]).bind(null, key),
32
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
33
+ });
34
+ }
35
+ return to;
36
+ };
37
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
38
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
39
+ value: mod,
40
+ enumerable: true
41
+ }) : target, mod));
42
+ var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
43
+ //#endregion
44
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/typeof.js
12
45
  function _typeof(o) {
13
46
  "@babel/helpers - typeof";
14
47
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -18,7 +51,7 @@ function _typeof(o) {
18
51
  }, _typeof(o);
19
52
  }
20
53
  //#endregion
21
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
54
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPrimitive.js
22
55
  function toPrimitive(t, r) {
23
56
  if ("object" != _typeof(t) || !t) return t;
24
57
  var e = t[Symbol.toPrimitive];
@@ -30,13 +63,13 @@ function toPrimitive(t, r) {
30
63
  return ("string" === r ? String : Number)(t);
31
64
  }
32
65
  //#endregion
33
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
66
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPropertyKey.js
34
67
  function toPropertyKey(t) {
35
68
  var i = toPrimitive(t, "string");
36
69
  return "symbol" == _typeof(i) ? i : i + "";
37
70
  }
38
71
  //#endregion
39
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
72
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/defineProperty.js
40
73
  function _defineProperty(e, r, t) {
41
74
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
42
75
  value: t,
@@ -46,6 +79,283 @@ function _defineProperty(e, r, t) {
46
79
  }) : e[r] = t, e;
47
80
  }
48
81
  //#endregion
82
+ //#region ../../node_modules/.pnpm/rolldown@1.2.1/node_modules/rolldown/dist/experimental-runtime.mjs
83
+ var Module = class {
84
+ /**
85
+ * @param {string} id
86
+ */
87
+ constructor(id) {
88
+ _defineProperty(
89
+ this,
90
+ /**
91
+ * @type {{ exports: any }}
92
+ */
93
+ "exportsHolder",
94
+ { exports: null }
95
+ );
96
+ _defineProperty(
97
+ this,
98
+ /**
99
+ * @type {string}
100
+ */
101
+ "id",
102
+ void 0
103
+ );
104
+ this.id = id;
105
+ }
106
+ get exports() {
107
+ return this.exportsHolder.exports;
108
+ }
109
+ };
110
+ /**
111
+ * Compiler-emitted module-graph delta — pure topology (static + dynamic edges).
112
+ * `ids[0, localCount)` are the modules this payload carries; `ids[localCount, …)` are foreign edge targets.
113
+ * `edges[i]` / `dynamicEdges[i]` are the static / dynamic-`import()` out-edges of `ids[i]`.
114
+ * @typedef {{ ids: string[], localCount: number, edges: number[][], dynamicEdges?: number[][] }} ModuleGraphDelta
115
+ * @typedef {{ createModuleHotContext(moduleId: string): any, onModuleCacheRemoval(moduleId: string): void }} DevRuntimeHooks
116
+ */
117
+ var MissingFactoryError = class extends Error {
118
+ /**
119
+ * @param {string} id
120
+ */
121
+ constructor(id) {
122
+ super(`No factory registered for module ${id}`);
123
+ this.id = id;
124
+ }
125
+ };
126
+ var DevRuntime = class {
127
+ /**
128
+ * @param {string} clientId
129
+ */
130
+ constructor(clientId) {
131
+ _defineProperty(
132
+ this,
133
+ /**
134
+ * Client ID generated at runtime initialization, used for lazy compilation requests.
135
+ * @type {string}
136
+ */
137
+ "clientId",
138
+ void 0
139
+ );
140
+ _defineProperty(
141
+ this,
142
+ /**
143
+ * Static import edges from `registerGraph` — entries persist across `removeModuleCache`
144
+ * and change only by replacement from a newer payload (last write wins).
145
+ * @type {Map<string, { edges: string[] }>}
146
+ */
147
+ "staticImports",
148
+ /* @__PURE__ */ new Map()
149
+ );
150
+ _defineProperty(
151
+ this,
152
+ /**
153
+ * Reverse index over the static imports.
154
+ * @type {Map<string, Set<string>>}
155
+ */
156
+ "importers",
157
+ /* @__PURE__ */ new Map()
158
+ );
159
+ _defineProperty(
160
+ this,
161
+ /**
162
+ * Dynamic `import()` edges from `registerGraph`, keyed by importer — mirror of
163
+ * `staticImports` for the dynamic reverse index.
164
+ * @type {Map<string, { edges: string[] }>}
165
+ */
166
+ "dynamicImports",
167
+ /* @__PURE__ */ new Map()
168
+ );
169
+ _defineProperty(
170
+ this,
171
+ /**
172
+ * Reverse index over the dynamic imports.
173
+ * @type {Map<string, Set<string>>}
174
+ */
175
+ "dynamicImporters",
176
+ /* @__PURE__ */ new Map()
177
+ );
178
+ _defineProperty(
179
+ this,
180
+ /**
181
+ * The module cache. Membership means "this module's side effects ran in this tab" —
182
+ * registration is emitted ahead of every module body, and nothing un-registers on
183
+ * unwind, so a factory that throws mid-body stays registered. A `Map` rather than a
184
+ * plain object: HMR eviction deletes entries, and a `delete` on an object drops V8
185
+ * into dictionary mode, taxing every later lookup on the hottest read path.
186
+ * @type {Map<string, Module>}
187
+ */
188
+ "moduleCache",
189
+ /* @__PURE__ */ new Map()
190
+ );
191
+ _defineProperty(
192
+ this,
193
+ /**
194
+ * Re-runnable factories from HMR patches and lazy chunks. The initial bundle stays
195
+ * scope-hoisted and contributes none.
196
+ * @type {Map<string, { kind: 'esm' | 'cjs', fn: (id: string) => void }>}
197
+ */
198
+ "factories",
199
+ /* @__PURE__ */ new Map()
200
+ );
201
+ _defineProperty(
202
+ this,
203
+ /**
204
+ * Installed by the dev client at boot. The runtime is a store + executor and makes
205
+ * no HMR decisions; accepting, disposing, and reloading live behind these hooks.
206
+ * @type {DevRuntimeHooks | null}
207
+ */
208
+ "hooks",
209
+ null
210
+ );
211
+ _defineProperty(
212
+ this,
213
+ /** @internal */
214
+ "__toESM",
215
+ __toESM
216
+ );
217
+ _defineProperty(
218
+ this,
219
+ /** @internal */
220
+ "__toCommonJS",
221
+ __toCommonJS
222
+ );
223
+ _defineProperty(
224
+ this,
225
+ /** @internal */
226
+ "__exportAll",
227
+ __exportAll
228
+ );
229
+ _defineProperty(
230
+ this,
231
+ /**
232
+ * @param {boolean} [isNodeMode]
233
+ * @returns {(mod: any) => any}
234
+ * @internal
235
+ */
236
+ "__toDynamicImportESM",
237
+ (isNodeMode) => (mod) => __toESM(mod.default, isNodeMode)
238
+ );
239
+ _defineProperty(
240
+ this,
241
+ /** @internal */
242
+ "__reExport",
243
+ __reExport
244
+ );
245
+ this.clientId = clientId;
246
+ }
247
+ /**
248
+ * @param {ModuleGraphDelta} delta
249
+ */
250
+ registerGraph(delta) {
251
+ for (let i = 0; i < delta.localCount; i++) {
252
+ const id = delta.ids[i];
253
+ const edges = delta.edges[i].map((j) => delta.ids[j]);
254
+ for (const target of this.staticImports.get(id)?.edges ?? []) this.importers.get(target)?.delete(id);
255
+ for (const target of edges) {
256
+ let importerSet = this.importers.get(target);
257
+ if (!importerSet) {
258
+ importerSet = /* @__PURE__ */ new Set();
259
+ this.importers.set(target, importerSet);
260
+ }
261
+ importerSet.add(id);
262
+ }
263
+ this.staticImports.set(id, { edges });
264
+ const dynamicEdges = (delta.dynamicEdges?.[i] ?? []).map((j) => delta.ids[j]);
265
+ for (const target of this.dynamicImports.get(id)?.edges ?? []) this.dynamicImporters.get(target)?.delete(id);
266
+ for (const target of dynamicEdges) {
267
+ let importerSet = this.dynamicImporters.get(target);
268
+ if (!importerSet) {
269
+ importerSet = /* @__PURE__ */ new Set();
270
+ this.dynamicImporters.set(target, importerSet);
271
+ }
272
+ importerSet.add(id);
273
+ }
274
+ this.dynamicImports.set(id, { edges: dynamicEdges });
275
+ }
276
+ }
277
+ /**
278
+ * @param {string} id
279
+ * @param {'esm' | 'cjs'} kind
280
+ * @param {(id: string) => void} fn
281
+ */
282
+ registerFactory(id, kind, fn) {
283
+ this.factories.set(id, {
284
+ kind,
285
+ fn
286
+ });
287
+ }
288
+ /**
289
+ * @param {string} id
290
+ * @param {{ exports: any }} exportsHolder
291
+ */
292
+ registerModule(id, exportsHolder) {
293
+ const module = new Module(id);
294
+ module.exportsHolder = exportsHolder;
295
+ this.moduleCache.set(id, module);
296
+ }
297
+ /**
298
+ * @param {string} id
299
+ * @returns {string[]}
300
+ */
301
+ getImporters(id) {
302
+ const dynamic = this.dynamicImporters.get(id);
303
+ if (!dynamic || dynamic.size === 0) return [...this.importers.get(id) ?? []];
304
+ return [.../* @__PURE__ */ new Set([...this.importers.get(id) ?? [], ...dynamic])];
305
+ }
306
+ /**
307
+ * @param {string} id
308
+ */
309
+ isExecuted(id) {
310
+ return this.moduleCache.has(id);
311
+ }
312
+ /**
313
+ * @param {string} id
314
+ */
315
+ hasFactory(id) {
316
+ return this.factories.has(id);
317
+ }
318
+ /**
319
+ * Module-cache delete only — static imports and factories persist. Removal is what
320
+ * re-arms a cache-gated factory for `initModule`.
321
+ * @param {string} id
322
+ */
323
+ removeModuleCache(id) {
324
+ this.moduleCache.delete(id);
325
+ this.hooks?.onModuleCacheRemoval(id);
326
+ }
327
+ /**
328
+ * The one re-execution gate: registered → return the live exports; otherwise run the
329
+ * mapped factory (which registers itself first, then runs the body).
330
+ * @param {string} id
331
+ */
332
+ initModule(id) {
333
+ if (this.moduleCache.has(id)) return this.loadExports(id);
334
+ const factory = this.factories.get(id);
335
+ if (!factory) throw new MissingFactoryError(id);
336
+ factory.fn(id);
337
+ return this.loadExports(id);
338
+ }
339
+ /**
340
+ * @param {string} id
341
+ */
342
+ loadExports(id) {
343
+ const module = this.moduleCache.get(id);
344
+ if (module) return module.exportsHolder.exports;
345
+ else {
346
+ console.warn(`Module ${id} not found`);
347
+ return {};
348
+ }
349
+ }
350
+ /**
351
+ * @param {string} moduleId
352
+ */
353
+ createModuleHotContext(moduleId) {
354
+ if (this.hooks) return this.hooks.createModuleHotContext(moduleId);
355
+ throw new Error("createModuleHotContext requires installed hooks or an override");
356
+ }
357
+ };
358
+ //#endregion
49
359
  //#region src/shared/hmr.ts
50
360
  var HMRContext = class {
51
361
  constructor(hmrClient, ownerPath) {
@@ -243,6 +553,7 @@ var BundledDevHMRClient = class extends HMRClient {
243
553
  this.options = options;
244
554
  this.applyQueue = Promise.resolve();
245
555
  this.lastSeq = 0;
556
+ this.reloadPending = false;
246
557
  }
247
558
  isSelfAccepted(id) {
248
559
  return this.hotModulesMap.get(id)?.callbacks.some((c) => c.deps.includes(id)) ?? false;
@@ -311,6 +622,7 @@ var BundledDevHMRClient = class extends HMRClient {
311
622
  if (disposer) disposer(this.dataMap.get(id));
312
623
  }
313
624
  async applyPush({ changedIds, url, seq }) {
625
+ if (this.reloadPending) return;
314
626
  if (seq !== this.lastSeq + 1) {
315
627
  this.requestFullReload(`hmr update sequence gap (expected ${this.lastSeq + 1}, got ${seq})`);
316
628
  return;
@@ -338,6 +650,7 @@ var BundledDevHMRClient = class extends HMRClient {
338
650
  await this.notifyListeners("vite:afterUpdate", listenerPayload);
339
651
  }
340
652
  async applyInvalidate(id) {
653
+ if (this.reloadPending) return;
341
654
  const firstInvalidatedBy = this.currentFirstInvalidatedBy ?? id;
342
655
  const importers = this.runtime.getImporters(id).filter((p) => this.runtime.isExecuted(p));
343
656
  if (!importers.length) {
@@ -392,8 +705,14 @@ var BundledDevHMRClient = class extends HMRClient {
392
705
  };
393
706
  }
394
707
  requestFullReload(reason) {
395
- this.logger.debug(`full reload: ${reason}`);
396
- this.options.pageReload();
708
+ if (this.reloadPending) return;
709
+ this.reloadPending = true;
710
+ this.logger.debug(`full reload needed: ${reason}`);
711
+ this.send({
712
+ type: "custom",
713
+ event: "vite:bundled-dev:reload-needed",
714
+ data: { reason }
715
+ });
397
716
  }
398
717
  };
399
718
  var BundledDevHMRContext = class extends HMRContext {
@@ -1442,8 +1761,7 @@ if (typeof DevRuntime !== "undefined") {
1442
1761
  debug: (...msg) => console.debug("[vite]", ...msg)
1443
1762
  }, transport, runtime, {
1444
1763
  base,
1445
- beforeApply: clearOverlayOrReloadOnFirstUpdate,
1446
- pageReload
1764
+ beforeApply: clearOverlayOrReloadOnFirstUpdate
1447
1765
  });
1448
1766
  registerBundledDevClient(bundledDevHmrClient);
1449
1767
  runtime.hooks = {
@@ -1,5 +1,5 @@
1
1
  import "@vite/env";
2
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
2
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/typeof.js
3
3
  function _typeof(o) {
4
4
  "@babel/helpers - typeof";
5
5
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -9,7 +9,7 @@ function _typeof(o) {
9
9
  }, _typeof(o);
10
10
  }
11
11
  //#endregion
12
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
12
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPrimitive.js
13
13
  function toPrimitive(t, r) {
14
14
  if ("object" != _typeof(t) || !t) return t;
15
15
  var e = t[Symbol.toPrimitive];
@@ -21,13 +21,13 @@ function toPrimitive(t, r) {
21
21
  return ("string" === r ? String : Number)(t);
22
22
  }
23
23
  //#endregion
24
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
24
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/toPropertyKey.js
25
25
  function toPropertyKey(t) {
26
26
  var i = toPrimitive(t, "string");
27
27
  return "symbol" == _typeof(i) ? i : i + "";
28
28
  }
29
29
  //#endregion
30
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
30
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/defineProperty.js
31
31
  function _defineProperty(e, r, t) {
32
32
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
33
33
  value: t,