vite 8.2.0-beta.0 → 8.2.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.
@@ -243,6 +243,7 @@ var BundledDevHMRClient = class extends HMRClient {
243
243
  this.options = options;
244
244
  this.applyQueue = Promise.resolve();
245
245
  this.lastSeq = 0;
246
+ this.reloadPending = false;
246
247
  }
247
248
  isSelfAccepted(id) {
248
249
  return this.hotModulesMap.get(id)?.callbacks.some((c) => c.deps.includes(id)) ?? false;
@@ -311,6 +312,7 @@ var BundledDevHMRClient = class extends HMRClient {
311
312
  if (disposer) disposer(this.dataMap.get(id));
312
313
  }
313
314
  async applyPush({ changedIds, url, seq }) {
315
+ if (this.reloadPending) return;
314
316
  if (seq !== this.lastSeq + 1) {
315
317
  this.requestFullReload(`hmr update sequence gap (expected ${this.lastSeq + 1}, got ${seq})`);
316
318
  return;
@@ -338,6 +340,7 @@ var BundledDevHMRClient = class extends HMRClient {
338
340
  await this.notifyListeners("vite:afterUpdate", listenerPayload);
339
341
  }
340
342
  async applyInvalidate(id) {
343
+ if (this.reloadPending) return;
341
344
  const firstInvalidatedBy = this.currentFirstInvalidatedBy ?? id;
342
345
  const importers = this.runtime.getImporters(id).filter((p) => this.runtime.isExecuted(p));
343
346
  if (!importers.length) {
@@ -392,8 +395,14 @@ var BundledDevHMRClient = class extends HMRClient {
392
395
  };
393
396
  }
394
397
  requestFullReload(reason) {
395
- this.logger.debug(`full reload: ${reason}`);
396
- this.options.pageReload();
398
+ if (this.reloadPending) return;
399
+ this.reloadPending = true;
400
+ this.logger.debug(`full reload needed: ${reason}`);
401
+ this.send({
402
+ type: "custom",
403
+ event: "vite:bundled-dev:reload-needed",
404
+ data: { reason }
405
+ });
397
406
  }
398
407
  };
399
408
  var BundledDevHMRContext = class extends HMRContext {
@@ -1442,8 +1451,7 @@ if (typeof DevRuntime !== "undefined") {
1442
1451
  debug: (...msg) => console.debug("[vite]", ...msg)
1443
1452
  }, transport, runtime, {
1444
1453
  base,
1445
- beforeApply: clearOverlayOrReloadOnFirstUpdate,
1446
- pageReload
1454
+ beforeApply: clearOverlayOrReloadOnFirstUpdate
1447
1455
  });
1448
1456
  registerBundledDevClient(bundledDevHmrClient);
1449
1457
  runtime.hooks = {
@@ -1,6 +1,6 @@
1
1
  import { ft as __commonJSMin, pt as __require } from "./node.js";
2
2
  import { t as require_lib } from "./lib.js";
3
- //#region ../../node_modules/.pnpm/postcss-modules@9.0.1_postcss@8.5.20/node_modules/postcss-modules/build/fs.js
3
+ //#region ../../node_modules/.pnpm/postcss-modules@9.0.1_postcss@8.5.23/node_modules/postcss-modules/build/fs.js
4
4
  var require_fs = /* @__PURE__ */ __commonJSMin(((exports) => {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  function _export(target, all) {
@@ -34,7 +34,7 @@ var require_fs = /* @__PURE__ */ __commonJSMin(((exports) => {
34
34
  }
35
35
  }));
36
36
  //#endregion
37
- //#region ../../node_modules/.pnpm/postcss-modules@9.0.1_postcss@8.5.20/node_modules/postcss-modules/build/unquote.js
37
+ //#region ../../node_modules/.pnpm/postcss-modules@9.0.1_postcss@8.5.23/node_modules/postcss-modules/build/unquote.js
38
38
  var require_unquote = /* @__PURE__ */ __commonJSMin(((exports) => {
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
40
  Object.defineProperty(exports, "default", {
@@ -52,7 +52,7 @@ var require_unquote = /* @__PURE__ */ __commonJSMin(((exports) => {
52
52
  }
53
53
  }));
54
54
  //#endregion
55
- //#region ../../node_modules/.pnpm/icss-utils@5.1.0_postcss@8.5.20/node_modules/icss-utils/src/replaceValueSymbols.js
55
+ //#region ../../node_modules/.pnpm/icss-utils@5.1.0_postcss@8.5.23/node_modules/icss-utils/src/replaceValueSymbols.js
56
56
  var require_replaceValueSymbols = /* @__PURE__ */ __commonJSMin(((exports, module) => {
57
57
  const matchValueName = /[$]?[\w-]+/g;
58
58
  const replaceValueSymbols = (value, replacements) => {
@@ -69,7 +69,7 @@ var require_replaceValueSymbols = /* @__PURE__ */ __commonJSMin(((exports, modul
69
69
  module.exports = replaceValueSymbols;
70
70
  }));
71
71
  //#endregion
72
- //#region ../../node_modules/.pnpm/icss-utils@5.1.0_postcss@8.5.20/node_modules/icss-utils/src/replaceSymbols.js
72
+ //#region ../../node_modules/.pnpm/icss-utils@5.1.0_postcss@8.5.23/node_modules/icss-utils/src/replaceSymbols.js
73
73
  var require_replaceSymbols = /* @__PURE__ */ __commonJSMin(((exports, module) => {
74
74
  const replaceValueSymbols = require_replaceValueSymbols();
75
75
  const replaceSymbols = (css, replacements) => {
@@ -82,7 +82,7 @@ var require_replaceSymbols = /* @__PURE__ */ __commonJSMin(((exports, module) =>
82
82
  module.exports = replaceSymbols;
83
83
  }));
84
84
  //#endregion
85
- //#region ../../node_modules/.pnpm/icss-utils@5.1.0_postcss@8.5.20/node_modules/icss-utils/src/extractICSS.js
85
+ //#region ../../node_modules/.pnpm/icss-utils@5.1.0_postcss@8.5.23/node_modules/icss-utils/src/extractICSS.js
86
86
  var require_extractICSS = /* @__PURE__ */ __commonJSMin(((exports, module) => {
87
87
  const importPattern = /^:import\(("[^"]*"|'[^']*'|[^"']+)\)$/;
88
88
  const balancedQuotes = /^("[^"]*"|'[^']*'|[^"']+)$/;
@@ -136,7 +136,7 @@ var require_extractICSS = /* @__PURE__ */ __commonJSMin(((exports, module) => {
136
136
  module.exports = extractICSS;
137
137
  }));
138
138
  //#endregion
139
- //#region ../../node_modules/.pnpm/icss-utils@5.1.0_postcss@8.5.20/node_modules/icss-utils/src/createICSSRules.js
139
+ //#region ../../node_modules/.pnpm/icss-utils@5.1.0_postcss@8.5.23/node_modules/icss-utils/src/createICSSRules.js
140
140
  var require_createICSSRules = /* @__PURE__ */ __commonJSMin(((exports, module) => {
141
141
  const createImports = (imports, postcss, mode = "rule") => {
142
142
  return Object.keys(imports).map((path) => {
@@ -180,7 +180,7 @@ var require_createICSSRules = /* @__PURE__ */ __commonJSMin(((exports, module) =
180
180
  module.exports = createICSSRules;
181
181
  }));
182
182
  //#endregion
183
- //#region ../../node_modules/.pnpm/icss-utils@5.1.0_postcss@8.5.20/node_modules/icss-utils/src/index.js
183
+ //#region ../../node_modules/.pnpm/icss-utils@5.1.0_postcss@8.5.23/node_modules/icss-utils/src/index.js
184
184
  var require_src$4 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
185
185
  module.exports = {
186
186
  replaceValueSymbols: require_replaceValueSymbols(),
@@ -190,7 +190,7 @@ var require_src$4 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
190
190
  };
191
191
  }));
192
192
  //#endregion
193
- //#region ../../node_modules/.pnpm/postcss-modules@9.0.1_postcss@8.5.20/node_modules/postcss-modules/build/Parser.js
193
+ //#region ../../node_modules/.pnpm/postcss-modules@9.0.1_postcss@8.5.23/node_modules/postcss-modules/build/Parser.js
194
194
  var require_Parser = /* @__PURE__ */ __commonJSMin(((exports) => {
195
195
  Object.defineProperty(exports, "__esModule", { value: true });
196
196
  Object.defineProperty(exports, "default", {
@@ -262,7 +262,7 @@ var require_Parser = /* @__PURE__ */ __commonJSMin(((exports) => {
262
262
  };
263
263
  }));
264
264
  //#endregion
265
- //#region ../../node_modules/.pnpm/postcss-modules@9.0.1_postcss@8.5.20/node_modules/postcss-modules/build/saveJSON.js
265
+ //#region ../../node_modules/.pnpm/postcss-modules@9.0.1_postcss@8.5.23/node_modules/postcss-modules/build/saveJSON.js
266
266
  var require_saveJSON = /* @__PURE__ */ __commonJSMin(((exports) => {
267
267
  Object.defineProperty(exports, "__esModule", { value: true });
268
268
  Object.defineProperty(exports, "default", {
@@ -944,7 +944,7 @@ var require_lodash_camelcase = /* @__PURE__ */ __commonJSMin(((exports, module)
944
944
  module.exports = camelCase;
945
945
  }));
946
946
  //#endregion
947
- //#region ../../node_modules/.pnpm/postcss-modules@9.0.1_postcss@8.5.20/node_modules/postcss-modules/build/localsConvention.js
947
+ //#region ../../node_modules/.pnpm/postcss-modules@9.0.1_postcss@8.5.23/node_modules/postcss-modules/build/localsConvention.js
948
948
  var require_localsConvention = /* @__PURE__ */ __commonJSMin(((exports) => {
949
949
  Object.defineProperty(exports, "__esModule", { value: true });
950
950
  Object.defineProperty(exports, "makeLocalsConventionReducer", {
@@ -1001,7 +1001,7 @@ var require_localsConvention = /* @__PURE__ */ __commonJSMin(((exports) => {
1001
1001
  }
1002
1002
  }));
1003
1003
  //#endregion
1004
- //#region ../../node_modules/.pnpm/postcss-modules@9.0.1_postcss@8.5.20/node_modules/postcss-modules/build/FileSystemLoader.js
1004
+ //#region ../../node_modules/.pnpm/postcss-modules@9.0.1_postcss@8.5.23/node_modules/postcss-modules/build/FileSystemLoader.js
1005
1005
  var require_FileSystemLoader = /* @__PURE__ */ __commonJSMin(((exports) => {
1006
1006
  Object.defineProperty(exports, "__esModule", { value: true });
1007
1007
  Object.defineProperty(exports, "default", {
@@ -1090,7 +1090,7 @@ var require_FileSystemLoader = /* @__PURE__ */ __commonJSMin(((exports) => {
1090
1090
  };
1091
1091
  }));
1092
1092
  //#endregion
1093
- //#region ../../node_modules/.pnpm/postcss-modules-extract-imports@3.1.0_postcss@8.5.20/node_modules/postcss-modules-extract-imports/src/topologicalSort.js
1093
+ //#region ../../node_modules/.pnpm/postcss-modules-extract-imports@3.1.0_postcss@8.5.23/node_modules/postcss-modules-extract-imports/src/topologicalSort.js
1094
1094
  var require_topologicalSort = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1095
1095
  const PERMANENT_MARKER = 2;
1096
1096
  const TEMPORARY_MARKER = 1;
@@ -1129,7 +1129,7 @@ var require_topologicalSort = /* @__PURE__ */ __commonJSMin(((exports, module) =
1129
1129
  module.exports = topologicalSort;
1130
1130
  }));
1131
1131
  //#endregion
1132
- //#region ../../node_modules/.pnpm/postcss-modules-extract-imports@3.1.0_postcss@8.5.20/node_modules/postcss-modules-extract-imports/src/index.js
1132
+ //#region ../../node_modules/.pnpm/postcss-modules-extract-imports@3.1.0_postcss@8.5.23/node_modules/postcss-modules-extract-imports/src/index.js
1133
1133
  var require_src$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1134
1134
  const topologicalSort = require_topologicalSort();
1135
1135
  const matchImports = /^(.+?)\s+from\s+(?:"([^"]+)"|'([^']+)'|(global))$/;
@@ -4640,7 +4640,7 @@ var require_dist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4640
4640
  module.exports = exports.default;
4641
4641
  }));
4642
4642
  //#endregion
4643
- //#region ../../node_modules/.pnpm/postcss-modules-local-by-default@4.2.0_postcss@8.5.20/node_modules/postcss-modules-local-by-default/src/index.js
4643
+ //#region ../../node_modules/.pnpm/postcss-modules-local-by-default@4.2.0_postcss@8.5.23/node_modules/postcss-modules-local-by-default/src/index.js
4644
4644
  var require_src$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4645
4645
  const selectorParser = require_dist();
4646
4646
  const valueParser = require_lib();
@@ -5038,7 +5038,7 @@ var require_src$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5038
5038
  module.exports.postcss = true;
5039
5039
  }));
5040
5040
  //#endregion
5041
- //#region ../../node_modules/.pnpm/postcss-modules-scope@3.2.1_postcss@8.5.20/node_modules/postcss-modules-scope/src/index.js
5041
+ //#region ../../node_modules/.pnpm/postcss-modules-scope@3.2.1_postcss@8.5.23/node_modules/postcss-modules-scope/src/index.js
5042
5042
  var require_src$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5043
5043
  const selectorParser = require_dist();
5044
5044
  const hasOwnProperty = Object.prototype.hasOwnProperty;
@@ -5218,7 +5218,7 @@ var require_string_hash = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5218
5218
  module.exports = hash;
5219
5219
  }));
5220
5220
  //#endregion
5221
- //#region ../../node_modules/.pnpm/postcss-modules-values@4.0.0_postcss@8.5.20/node_modules/postcss-modules-values/src/index.js
5221
+ //#region ../../node_modules/.pnpm/postcss-modules-values@4.0.0_postcss@8.5.23/node_modules/postcss-modules-values/src/index.js
5222
5222
  var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5223
5223
  const ICSSUtils = require_src$4();
5224
5224
  const matchImports = /^(.+?|\([\s\S]+?\))\s+from\s+("[^"]*"|'[^']*'|[\w-]+)$/;
@@ -5305,7 +5305,7 @@ var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5305
5305
  module.exports.postcss = true;
5306
5306
  }));
5307
5307
  //#endregion
5308
- //#region ../../node_modules/.pnpm/postcss-modules@9.0.1_postcss@8.5.20/node_modules/postcss-modules/build/scoping.js
5308
+ //#region ../../node_modules/.pnpm/postcss-modules@9.0.1_postcss@8.5.23/node_modules/postcss-modules/build/scoping.js
5309
5309
  var require_scoping = /* @__PURE__ */ __commonJSMin(((exports) => {
5310
5310
  Object.defineProperty(exports, "__esModule", { value: true });
5311
5311
  function _export(target, all) {
@@ -5384,7 +5384,7 @@ var require_scoping = /* @__PURE__ */ __commonJSMin(((exports) => {
5384
5384
  }
5385
5385
  }));
5386
5386
  //#endregion
5387
- //#region ../../node_modules/.pnpm/postcss-modules@9.0.1_postcss@8.5.20/node_modules/postcss-modules/build/pluginFactory.js
5387
+ //#region ../../node_modules/.pnpm/postcss-modules@9.0.1_postcss@8.5.23/node_modules/postcss-modules/build/pluginFactory.js
5388
5388
  var require_pluginFactory = /* @__PURE__ */ __commonJSMin(((exports) => {
5389
5389
  Object.defineProperty(exports, "__esModule", { value: true });
5390
5390
  Object.defineProperty(exports, "makePlugin", {
@@ -5466,7 +5466,7 @@ var require_pluginFactory = /* @__PURE__ */ __commonJSMin(((exports) => {
5466
5466
  }
5467
5467
  }));
5468
5468
  //#endregion
5469
- //#region ../../node_modules/.pnpm/postcss-modules@9.0.1_postcss@8.5.20/node_modules/postcss-modules/build/index.js
5469
+ //#region ../../node_modules/.pnpm/postcss-modules@9.0.1_postcss@8.5.23/node_modules/postcss-modules/build/index.js
5470
5470
  var require_build = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5471
5471
  Object.defineProperty(exports, "__esModule", { value: true });
5472
5472
  const _fs = __require("fs");
@@ -2653,7 +2653,15 @@ function resolveServerUrls(server, options, hostname, httpsOptions, config) {
2653
2653
  if (loopbackHosts.has(hostname.host)) local.push(address);
2654
2654
  else {
2655
2655
  network.push(address);
2656
- networkInterfaceNames.push(void 0);
2656
+ let interfaceName;
2657
+ if (hostname.host) {
2658
+ const interfaces = os.networkInterfaces();
2659
+ outer: for (const [name, nInterface] of Object.entries(interfaces)) for (const detail of nInterface ?? []) if (detail.address === hostname.host) {
2660
+ interfaceName = name;
2661
+ break outer;
2662
+ }
2663
+ }
2664
+ networkInterfaceNames.push(interfaceName);
2657
2665
  }
2658
2666
  } else Object.entries(os.networkInterfaces()).forEach(([name, nInterface]) => {
2659
2667
  (nInterface ?? []).filter((detail) => detail.address && detail.family === "IPv4").forEach((detail) => {
@@ -4197,7 +4205,7 @@ function warnDeprecatedShouldBeConvertedToPluginOptions(logger, name) {
4197
4205
  logger.warn(import_picocolors.default.yellow(`\`esbuild.${name}\` option was specified. But this option is deprecated and will be removed in future versions. This option can be achieved by using a plugin with transform hook, please use that instead.`));
4198
4206
  }
4199
4207
  //#endregion
4200
- //#region ../../node_modules/.pnpm/magic-string@1.0.0/node_modules/magic-string/dist/index.mjs
4208
+ //#region ../../node_modules/.pnpm/magic-string@1.1.0/node_modules/magic-string/dist/index.mjs
4201
4209
  var BitSet = class BitSet {
4202
4210
  constructor(arg) {
4203
4211
  this.bits = arg instanceof BitSet ? arg.bits.slice() : [];
@@ -4308,10 +4316,8 @@ var Chunk = class Chunk {
4308
4316
  if (this.outro.length) return true;
4309
4317
  const trimmed = this.content.replace(rx, "");
4310
4318
  if (trimmed.length) {
4311
- if (trimmed !== this.content) {
4312
- this.split(this.start + trimmed.length).edit("", void 0, true);
4313
- if (this.edited) this.edit(trimmed, this.storeName, true);
4314
- }
4319
+ if (trimmed !== this.content) if (this.edited) this.edit(trimmed, this.storeName, true);
4320
+ else this.split(this.start + trimmed.length).edit("", void 0, true);
4315
4321
  return true;
4316
4322
  } else {
4317
4323
  this.edit("", void 0, true);
@@ -4324,9 +4330,9 @@ var Chunk = class Chunk {
4324
4330
  if (this.intro.length) return true;
4325
4331
  const trimmed = this.content.replace(rx, "");
4326
4332
  if (trimmed.length) {
4327
- if (trimmed !== this.content) {
4328
- const newChunk = this.split(this.end - trimmed.length);
4329
- if (this.edited) newChunk.edit(trimmed, this.storeName, true);
4333
+ if (trimmed !== this.content) if (this.edited) this.edit(trimmed, this.storeName, true);
4334
+ else {
4335
+ this.split(this.end - trimmed.length);
4330
4336
  this.edit("", void 0, true);
4331
4337
  }
4332
4338
  return true;
@@ -4594,8 +4600,8 @@ var MagicString = class MagicString {
4594
4600
  value: options.offset || 0
4595
4601
  }
4596
4602
  });
4597
- this.byStart[0] = chunk;
4598
- this.byEnd[string.length] = chunk;
4603
+ this.byStart = /* @__PURE__ */ new Map([[0, chunk]]);
4604
+ this.byEnd = /* @__PURE__ */ new Map([[string.length, chunk]]);
4599
4605
  }
4600
4606
  /**
4601
4607
  * Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is false.
@@ -4620,7 +4626,7 @@ var MagicString = class MagicString {
4620
4626
  index = index + this.offset;
4621
4627
  if (typeof content !== "string") throw new TypeError("inserted content must be a string");
4622
4628
  this._split(index);
4623
- const chunk = this.byEnd[index];
4629
+ const chunk = this.byEnd.get(index);
4624
4630
  if (chunk) chunk.appendLeft(content);
4625
4631
  else this.intro += content;
4626
4632
  return this;
@@ -4634,7 +4640,7 @@ var MagicString = class MagicString {
4634
4640
  index = index + this.offset;
4635
4641
  if (typeof content !== "string") throw new TypeError("inserted content must be a string");
4636
4642
  this._split(index);
4637
- const chunk = this.byStart[index];
4643
+ const chunk = this.byStart.get(index);
4638
4644
  if (chunk) chunk.appendRight(content);
4639
4645
  else this.outro += content;
4640
4646
  return this;
@@ -4650,8 +4656,8 @@ var MagicString = class MagicString {
4650
4656
  let originalChunk = this.firstChunk;
4651
4657
  let clonedChunk = cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone();
4652
4658
  while (originalChunk) {
4653
- cloned.byStart[clonedChunk.start] = clonedChunk;
4654
- cloned.byEnd[clonedChunk.end] = clonedChunk;
4659
+ cloned.byStart.set(clonedChunk.start, clonedChunk);
4660
+ cloned.byEnd.set(clonedChunk.end, clonedChunk);
4655
4661
  const nextOriginalChunk = originalChunk.next;
4656
4662
  const nextClonedChunk = nextOriginalChunk && nextOriginalChunk.clone();
4657
4663
  if (nextClonedChunk) {
@@ -4824,11 +4830,11 @@ var MagicString = class MagicString {
4824
4830
  this._split(start);
4825
4831
  this._split(end);
4826
4832
  this._split(index);
4827
- const first = this.byStart[start];
4828
- const last = this.byEnd[end];
4833
+ const first = this.byStart.get(start);
4834
+ const last = this.byEnd.get(end);
4829
4835
  const oldLeft = first.previous;
4830
4836
  const oldRight = last.next;
4831
- const newRight = this.byStart[index];
4837
+ const newRight = this.byStart.get(index);
4832
4838
  if (!newRight && last === this.lastChunk) return this;
4833
4839
  const newLeft = newRight ? newRight.previous : this.lastChunk;
4834
4840
  if (oldLeft) oldLeft.next = oldRight;
@@ -4900,12 +4906,12 @@ var MagicString = class MagicString {
4900
4906
  enumerable: true
4901
4907
  });
4902
4908
  }
4903
- const first = this.byStart[start];
4904
- const last = this.byEnd[end];
4909
+ const first = this.byStart.get(start);
4910
+ const last = this.byEnd.get(end);
4905
4911
  if (first) {
4906
4912
  let chunk = first;
4907
4913
  while (chunk !== last) {
4908
- if (chunk.next !== this.byStart[chunk.end]) throw new Error("Cannot overwrite across a split point");
4914
+ if (chunk.next !== this.byStart.get(chunk.end)) throw new Error("Cannot overwrite across a split point");
4909
4915
  chunk = chunk.next;
4910
4916
  chunk.edit("", false);
4911
4917
  }
@@ -4932,7 +4938,7 @@ var MagicString = class MagicString {
4932
4938
  index = index + this.offset;
4933
4939
  if (typeof content !== "string") throw new TypeError("inserted content must be a string");
4934
4940
  this._split(index);
4935
- const chunk = this.byEnd[index];
4941
+ const chunk = this.byEnd.get(index);
4936
4942
  if (chunk) chunk.prependLeft(content);
4937
4943
  else this.intro = content + this.intro;
4938
4944
  return this;
@@ -4944,7 +4950,7 @@ var MagicString = class MagicString {
4944
4950
  index = index + this.offset;
4945
4951
  if (typeof content !== "string") throw new TypeError("inserted content must be a string");
4946
4952
  this._split(index);
4947
- const chunk = this.byStart[index];
4953
+ const chunk = this.byStart.get(index);
4948
4954
  if (chunk) chunk.prependRight(content);
4949
4955
  else this.outro = content + this.outro;
4950
4956
  return this;
@@ -4965,12 +4971,12 @@ var MagicString = class MagicString {
4965
4971
  if (start > end) throw new Error("end must be greater than start");
4966
4972
  this._split(start);
4967
4973
  this._split(end);
4968
- let chunk = this.byStart[start];
4974
+ let chunk = this.byStart.get(start);
4969
4975
  while (chunk) {
4970
4976
  chunk.intro = "";
4971
4977
  chunk.outro = "";
4972
4978
  chunk.edit("");
4973
- chunk = end > chunk.end ? this.byStart[chunk.end] : null;
4979
+ chunk = end > chunk.end ? this.byStart.get(chunk.end) : null;
4974
4980
  }
4975
4981
  return this;
4976
4982
  }
@@ -4989,10 +4995,10 @@ var MagicString = class MagicString {
4989
4995
  if (start > end) throw new Error("end must be greater than start");
4990
4996
  this._split(start);
4991
4997
  this._split(end);
4992
- let chunk = this.byStart[start];
4998
+ let chunk = this.byStart.get(start);
4993
4999
  while (chunk) {
4994
5000
  chunk.reset();
4995
- chunk = end > chunk.end ? this.byStart[chunk.end] : null;
5001
+ chunk = end > chunk.end ? this.byStart.get(chunk.end) : null;
4996
5002
  }
4997
5003
  return this;
4998
5004
  }
@@ -5078,13 +5084,13 @@ var MagicString = class MagicString {
5078
5084
  }
5079
5085
  /** @internal */
5080
5086
  _split(index) {
5081
- if (this.byStart[index] || this.byEnd[index]) return;
5087
+ if (this.byStart.get(index) || this.byEnd.get(index)) return;
5082
5088
  let chunk = this.lastSearchedChunk;
5083
5089
  let previousChunk = chunk;
5084
5090
  const searchForward = index > chunk.end;
5085
5091
  while (chunk) {
5086
5092
  if (chunk.contains(index)) return this._splitChunk(chunk, index);
5087
- chunk = searchForward ? this.byStart[chunk.end] : this.byEnd[chunk.start];
5093
+ chunk = searchForward ? this.byStart.get(chunk.end) : this.byEnd.get(chunk.start);
5088
5094
  if (chunk === previousChunk) return;
5089
5095
  previousChunk = chunk;
5090
5096
  }
@@ -5096,9 +5102,9 @@ var MagicString = class MagicString {
5096
5102
  throw new Error(`Cannot split a chunk that has already been edited (${loc.line}:${loc.column} – "${chunk.original}")`);
5097
5103
  }
5098
5104
  const newChunk = chunk.split(index);
5099
- this.byEnd[index] = chunk;
5100
- this.byStart[index] = newChunk;
5101
- this.byEnd[newChunk.end] = newChunk;
5105
+ this.byEnd.set(index, chunk);
5106
+ this.byStart.set(index, newChunk);
5107
+ this.byEnd.set(newChunk.end, newChunk);
5102
5108
  if (chunk === this.lastChunk) this.lastChunk = newChunk;
5103
5109
  this.lastSearchedChunk = chunk;
5104
5110
  return true;
@@ -5158,9 +5164,9 @@ var MagicString = class MagicString {
5158
5164
  const aborted = chunk.trimEnd(rx);
5159
5165
  if (chunk.end !== end) {
5160
5166
  if (this.lastChunk === chunk) this.lastChunk = chunk.next;
5161
- this.byEnd[chunk.end] = chunk;
5162
- this.byStart[chunk.next.start] = chunk.next;
5163
- this.byEnd[chunk.next.end] = chunk.next;
5167
+ this.byEnd.set(chunk.end, chunk);
5168
+ this.byStart.set(chunk.next.start, chunk.next);
5169
+ this.byEnd.set(chunk.next.end, chunk.next);
5164
5170
  }
5165
5171
  if (aborted) return true;
5166
5172
  chunk = chunk.previous;
@@ -5185,9 +5191,9 @@ var MagicString = class MagicString {
5185
5191
  const aborted = chunk.trimStart(rx);
5186
5192
  if (chunk.end !== end) {
5187
5193
  if (chunk === this.lastChunk) this.lastChunk = chunk.next;
5188
- this.byEnd[chunk.end] = chunk;
5189
- this.byStart[chunk.next.start] = chunk.next;
5190
- this.byEnd[chunk.next.end] = chunk.next;
5194
+ this.byEnd.set(chunk.end, chunk);
5195
+ this.byStart.set(chunk.next.start, chunk.next);
5196
+ this.byEnd.set(chunk.next.end, chunk.next);
5191
5197
  }
5192
5198
  if (aborted) return true;
5193
5199
  chunk = chunk.next;
@@ -21852,7 +21858,7 @@ var require_src$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
21852
21858
  };
21853
21859
  }));
21854
21860
  //#endregion
21855
- //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.20_tsx@4.23.1_yaml@2.9.0/node_modules/postcss-load-config/src/req.js
21861
+ //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.23_tsx@4.23.1_yaml@2.9.0/node_modules/postcss-load-config/src/req.js
21856
21862
  var require_req = /* @__PURE__ */ __commonJSMin(((exports, module) => {
21857
21863
  const { createRequire: createRequire$1 } = __require("node:module");
21858
21864
  const { fileURLToPath: fileURLToPath$1, pathToFileURL: pathToFileURL$1 } = __require("node:url");
@@ -21894,7 +21900,7 @@ var require_req = /* @__PURE__ */ __commonJSMin(((exports, module) => {
21894
21900
  module.exports = req;
21895
21901
  }));
21896
21902
  //#endregion
21897
- //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.20_tsx@4.23.1_yaml@2.9.0/node_modules/postcss-load-config/src/options.js
21903
+ //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.23_tsx@4.23.1_yaml@2.9.0/node_modules/postcss-load-config/src/options.js
21898
21904
  var require_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
21899
21905
  const req = require_req();
21900
21906
  /**
@@ -21928,7 +21934,7 @@ var require_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
21928
21934
  module.exports = options;
21929
21935
  }));
21930
21936
  //#endregion
21931
- //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.20_tsx@4.23.1_yaml@2.9.0/node_modules/postcss-load-config/src/plugins.js
21937
+ //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.23_tsx@4.23.1_yaml@2.9.0/node_modules/postcss-load-config/src/plugins.js
21932
21938
  var require_plugins = /* @__PURE__ */ __commonJSMin(((exports, module) => {
21933
21939
  const req = require_req();
21934
21940
  /**
@@ -21982,7 +21988,7 @@ var require_plugins = /* @__PURE__ */ __commonJSMin(((exports, module) => {
21982
21988
  module.exports = plugins;
21983
21989
  }));
21984
21990
  //#endregion
21985
- //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.20_tsx@4.23.1_yaml@2.9.0/node_modules/postcss-load-config/src/index.js
21991
+ //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.23_tsx@4.23.1_yaml@2.9.0/node_modules/postcss-load-config/src/index.js
21986
21992
  var require_src = /* @__PURE__ */ __commonJSMin(((exports, module) => {
21987
21993
  const { resolve: resolve$3 } = __require("node:path");
21988
21994
  const config = require_src$1();
@@ -25431,7 +25437,7 @@ const processNodeUrl = (url, useSrcSetReplacer, config, htmlPath, originalUrl, s
25431
25437
  else if (url[0] === "." || isBareRelative(url)) preTransformUrl = path.posix.join(config.base, getHtmlDirnameForRelativeUrl(htmlPath), url);
25432
25438
  }
25433
25439
  if (server) {
25434
- const mod = server.environments.client.moduleGraph.urlToModuleMap.get(preTransformUrl || url);
25440
+ const mod = server.environments.client.moduleGraph.urlToModuleMap.get(stripBase(preTransformUrl || url, config.decodedBase));
25435
25441
  if (mod && mod.lastHMRTimestamp > 0) url = injectQuery(url, `t=${mod.lastHMRTimestamp}`);
25436
25442
  }
25437
25443
  if (server && preTransformUrl) {
@@ -26874,7 +26880,9 @@ function getSortedHotUpdatePlugins(environment) {
26874
26880
  async function handleHMRUpdate(type, file, server) {
26875
26881
  const { config } = server;
26876
26882
  const mixedModuleGraph = ignoreDeprecationWarnings(() => server.moduleGraph);
26877
- const environments = Object.values(server.environments);
26883
+ const environmentSnapshot = server.environments;
26884
+ const environments = Object.values(environmentSnapshot);
26885
+ const isStale = () => server.environments !== environmentSnapshot;
26878
26886
  const shortFile = getShortName(file, config.root);
26879
26887
  const isConfig = file === config.configFile;
26880
26888
  const isConfigDependency = config.configFileDependencies.some((name) => file === name);
@@ -26935,8 +26943,9 @@ async function handleHMRUpdate(type, file, server) {
26935
26943
  const clientHotUpdateOptions = hotMap.get(clientEnvironment).options;
26936
26944
  const ssrHotUpdateOptions = hotMap.get(ssrEnvironment)?.options;
26937
26945
  try {
26938
- for (const plugin of getSortedHotUpdatePlugins(server.environments.client)) if (plugin.hotUpdate) {
26946
+ for (const plugin of getSortedHotUpdatePlugins(clientEnvironment)) if (plugin.hotUpdate) {
26939
26947
  const filteredModules = await getHookHandler(plugin.hotUpdate).call(clientContext, clientHotUpdateOptions);
26948
+ if (isStale()) return;
26940
26949
  if (filteredModules) {
26941
26950
  clientHotUpdateOptions.modules = filteredModules;
26942
26951
  mixedHmrContext.modules = mixedHmrContext.modules.filter((mixedMod) => filteredModules.some((mod) => mixedMod.id === mod.id) || ssrHotUpdateOptions?.modules.some((ssrMod) => ssrMod.id === mixedMod.id));
@@ -26945,6 +26954,7 @@ async function handleHMRUpdate(type, file, server) {
26945
26954
  } else if (type === "update") {
26946
26955
  warnFutureDeprecation(config, "removePluginHookHandleHotUpdate", `Used in plugin "${plugin.name}".`, false);
26947
26956
  const filteredModules = await getHookHandler(plugin.handleHotUpdate).call(contextForHandleHotUpdate, mixedHmrContext);
26957
+ if (isStale()) return;
26948
26958
  if (filteredModules) {
26949
26959
  mixedHmrContext.modules = filteredModules;
26950
26960
  clientHotUpdateOptions.modules = clientHotUpdateOptions.modules.filter((mod) => filteredModules.some((mixedMod) => mod.id === mixedMod.id));
@@ -26956,7 +26966,8 @@ async function handleHMRUpdate(type, file, server) {
26956
26966
  }
26957
26967
  }
26958
26968
  } catch (error) {
26959
- hotMap.get(server.environments.client).error = error;
26969
+ if (isStale()) return;
26970
+ hotMap.get(clientEnvironment).error = error;
26960
26971
  }
26961
26972
  for (const environment of environments) {
26962
26973
  if (environment.name === "client") continue;
@@ -26965,13 +26976,16 @@ async function handleHMRUpdate(type, file, server) {
26965
26976
  try {
26966
26977
  for (const plugin of getSortedHotUpdatePlugins(environment)) if (plugin.hotUpdate) {
26967
26978
  const filteredModules = await getHookHandler(plugin.hotUpdate).call(context, hot.options);
26979
+ if (isStale()) return;
26968
26980
  if (filteredModules) hot.options.modules = filteredModules;
26969
26981
  }
26970
26982
  } catch (error) {
26983
+ if (isStale()) return;
26971
26984
  hot.error = error;
26972
26985
  }
26973
26986
  }
26974
26987
  async function hmr(environment) {
26988
+ if (isStale()) return;
26975
26989
  try {
26976
26990
  const { options, error } = hotMap.get(environment);
26977
26991
  if (error) throw error;
@@ -26996,6 +27010,7 @@ async function handleHMRUpdate(type, file, server) {
26996
27010
  });
26997
27011
  }
26998
27012
  }
27013
+ if (isStale()) return;
26999
27014
  await (server.config.server.hotUpdateEnvironments ?? ((server, hmr) => {
27000
27015
  return Promise.all(Object.values(server.environments).map((environment) => hmr(environment)));
27001
27016
  }))(server, hmr);
@@ -27489,6 +27504,22 @@ async function workerFileToUrl(config, id) {
27489
27504
  }, config.logger);
27490
27505
  return bundle;
27491
27506
  }
27507
+ /**
27508
+ * Emit the bundled worker files during `load` / `transform`.
27509
+ *
27510
+ * They normally reach the output through `generateBundle`, which an HMR patch
27511
+ * skips, so without this a patched worker points at a file that was never
27512
+ * emitted.
27513
+ */
27514
+ function emitWorkerAssetsForBundledDev(pluginContext, config) {
27515
+ if (config.isWorker) return;
27516
+ const workerOutput = workerOutputCaches.get(config.mainConfig || config);
27517
+ for (const asset of workerOutput.getAssets()) pluginContext.emitFile({
27518
+ type: "asset",
27519
+ fileName: asset.fileName,
27520
+ source: asset.source
27521
+ });
27522
+ }
27492
27523
  function webWorkerPostPlugin(_config) {
27493
27524
  return {
27494
27525
  name: "vite:worker-post",
@@ -27599,8 +27630,10 @@ function webWorkerPlugin(config) {
27599
27630
  } else {
27600
27631
  const result = await workerFileToUrl(config, id);
27601
27632
  let url;
27602
- if (this.environment.config.command === "serve" && this.environment.config.isBundled) url = toOutputFilePathInJSForBundledDev(this.environment, result.entryFilename);
27603
- else url = result.entryUrlPlaceholder;
27633
+ if (this.environment.config.command === "serve" && this.environment.config.isBundled) {
27634
+ emitWorkerAssetsForBundledDev(this, config);
27635
+ url = toOutputFilePathInJSForBundledDev(this.environment, result.entryFilename);
27636
+ } else url = result.entryUrlPlaceholder;
27604
27637
  urlCode = JSON.stringify(url);
27605
27638
  for (const file of result.watchedFiles) this.addWatchFile(file);
27606
27639
  }
@@ -27994,7 +28027,7 @@ function importAnalysisPlugin(config) {
27994
28027
  config.safeModulePaths.add(fsPathFromUrl(stripBase(url, base)));
27995
28028
  if (url !== specifier) {
27996
28029
  let rewriteDone = false;
27997
- if (!depsOptimizer?.isOptimizedDepFile(importer) && depsOptimizer?.isOptimizedDepFile(resolvedId) && !optimizedDepChunkRE.test(resolvedId)) {
28030
+ if (!(depsOptimizer?.isOptimizedDepFile(importer) && specifier[0] === ".") && depsOptimizer?.isOptimizedDepFile(resolvedId) && !optimizedDepChunkRE.test(resolvedId)) {
27998
28031
  const file = cleanUrl(resolvedId);
27999
28032
  const depInfo = optimizedDepInfoFromFile(depsOptimizer.metadata, file);
28000
28033
  const needsInterop = await optimizedDepNeedsInterop(environment, depsOptimizer.metadata, file);
@@ -28631,8 +28664,10 @@ function workerImportMetaUrlPlugin(config) {
28631
28664
  let builtUrl;
28632
28665
  if (isBundled) {
28633
28666
  const result = await workerFileToUrl(config, file);
28634
- if (this.environment.config.command === "serve") builtUrl = toOutputFilePathInJSForBundledDev(this.environment, result.entryFilename);
28635
- else builtUrl = result.entryUrlPlaceholder;
28667
+ if (this.environment.config.command === "serve") {
28668
+ emitWorkerAssetsForBundledDev(this, config);
28669
+ builtUrl = toOutputFilePathInJSForBundledDev(this.environment, result.entryFilename);
28670
+ } else builtUrl = result.entryUrlPlaceholder;
28636
28671
  for (const file of result.watchedFiles) this.addWatchFile(file);
28637
28672
  } else {
28638
28673
  builtUrl = await fileToUrl$1(this, cleanUrl(file));
@@ -30622,7 +30657,11 @@ var EnvironmentPluginContainer = class {
30622
30657
  }
30623
30658
  this._started = true;
30624
30659
  const config = this.environment.getTopLevelConfig();
30625
- this._buildStartPromise = this.handleHookPromise(this.hookParallel("buildStart", (plugin) => this._getPluginContext(plugin), () => [this.options], (plugin) => this.environment.name === "client" || config.server.perEnvironmentStartEndDuringDev || plugin.perEnvironmentStartEndDuringDev));
30660
+ const hookPromise = this.handleHookPromise(this.hookParallel("buildStart", (plugin) => this._getPluginContext(plugin), () => [this.options], (plugin) => this.environment.name === "client" || config.server.perEnvironmentStartEndDuringDev || plugin.perEnvironmentStartEndDuringDev));
30661
+ this._buildStartPromise = (async () => {
30662
+ await hookPromise;
30663
+ if (this.environment.mode === "dev") await this.environment._registerInputsAsSafeModules();
30664
+ })();
30626
30665
  await this._buildStartPromise;
30627
30666
  this._buildStartPromise = void 0;
30628
30667
  }
@@ -31286,11 +31325,10 @@ function scanImports(environment) {
31286
31325
  async function computeEntries(environment) {
31287
31326
  let entries = [];
31288
31327
  const explicitEntryPatterns = environment.config.optimizeDeps.entries;
31289
- const buildInput = environment.config.input ?? environment.config.build.rolldownOptions.input;
31328
+ const input = environment.config.input ?? environment.config.build.rolldownOptions.input;
31290
31329
  if (explicitEntryPatterns) entries = await globEntries(explicitEntryPatterns, environment);
31291
- else if (buildInput) {
31330
+ else if (input) {
31292
31331
  const resolvePath = async (p) => {
31293
- if (environment.config.input) return p;
31294
31332
  const id = (await environment.pluginContainer.resolveId(p, void 0, {
31295
31333
  isEntry: true,
31296
31334
  scan: true
@@ -31298,9 +31336,9 @@ async function computeEntries(environment) {
31298
31336
  if (id === void 0) throw new Error(`failed to resolve rolldownOptions.input value: ${JSON.stringify(p)}.`);
31299
31337
  return id;
31300
31338
  };
31301
- if (typeof buildInput === "string") entries = [await resolvePath(buildInput)];
31302
- else if (Array.isArray(buildInput)) entries = await Promise.all(buildInput.map(resolvePath));
31303
- else if (isObject$1(buildInput)) entries = await Promise.all(Object.values(buildInput).map(resolvePath));
31339
+ if (typeof input === "string") entries = [await resolvePath(input)];
31340
+ else if (Array.isArray(input)) entries = await Promise.all(input.map(resolvePath));
31341
+ else if (isObject$1(input)) entries = await Promise.all(Object.values(input).map(resolvePath));
31304
31342
  else throw new Error("invalid rolldownOptions.input value.");
31305
31343
  } else entries = await globEntries("**/*.html", environment);
31306
31344
  entries = entries.filter((entry) => isScannable(entry, environment.config.optimizeDeps.extensions) && fs.existsSync(entry));
@@ -33505,7 +33543,7 @@ function resolveRolldownOptions(environment, chunkMetadataMap) {
33505
33543
  const resolve = (p) => path.resolve(root, p);
33506
33544
  const topLevelInput = environment.config.input;
33507
33545
  if (libOptions && libOptions.entry == null) throw new Error(`Either "build.lib.entry" or the top-level "input" option is required when "build.lib" is set.`);
33508
- const input = libOptions ? options.rolldownOptions.input || (typeof libOptions.entry === "string" ? resolve(libOptions.entry) : Array.isArray(libOptions.entry) ? libOptions.entry.map(resolve) : Object.fromEntries(Object.entries(libOptions.entry).map(([alias, file]) => [alias, resolve(file)]))) : typeof options.ssr === "string" ? resolve(options.ssr) : options.rolldownOptions.input || (topLevelInput != null ? topLevelInput : resolve("index.html"));
33546
+ const input = libOptions ? options.rolldownOptions.input || (typeof libOptions.entry === "string" ? resolve(libOptions.entry) : Array.isArray(libOptions.entry) ? libOptions.entry.map(resolve) : Object.fromEntries(Object.entries(libOptions.entry).map(([alias, file]) => [alias, resolve(file)]))) : typeof options.ssr === "string" ? resolve(options.ssr) : options.rolldownOptions.input || (topLevelInput ?? resolve("index.html"));
33509
33547
  if (ssr && typeof input === "string" && input.endsWith(".html")) throw new Error("rolldownOptions.input should not be an html file when building for SSR. Please specify a dedicated SSR entry.");
33510
33548
  if (options.cssCodeSplit === false) {
33511
33549
  if ((typeof input === "string" ? [input] : Array.isArray(input) ? input : Object.values(input)).some((input) => input.endsWith(".css"))) throw new Error(`When "build.cssCodeSplit: false" is set, "rolldownOptions.input" should not include CSS files.`);
@@ -34931,6 +34969,16 @@ var BundledDev = class {
34931
34969
  this.environment.logger.info(import_picocolors.default.green(`page reload`), { timestamp: true });
34932
34970
  });
34933
34971
  fullReloadPending = false;
34972
+ reloadNeededClientIds = /* @__PURE__ */ new Set();
34973
+ debouncedReloadNeededFlush = debounce(20, () => {
34974
+ if (this.lastBuildError || this.reloadNeededClientIds.size === 0) return;
34975
+ for (const clientId of this.reloadNeededClientIds) this.clients.get(clientId)?.send({
34976
+ type: "full-reload",
34977
+ path: "*"
34978
+ });
34979
+ this.reloadNeededClientIds.clear();
34980
+ this.environment.logger.info(import_picocolors.default.green(`page reload`), { timestamp: true });
34981
+ });
34934
34982
  lastBuildError = null;
34935
34983
  memoryFiles = new MemoryFiles();
34936
34984
  constructor(environment) {
@@ -34963,11 +35011,26 @@ var BundledDev = class {
34963
35011
  });
34964
35012
  this.environment.hot.on("vite:client:disconnect", (_payload, client) => {
34965
35013
  const clientId = this.clients.delete(client);
34966
- if (clientId) this.devEngine.removeClient(clientId);
35014
+ if (clientId) {
35015
+ this.devEngine.removeClient(clientId);
35016
+ this.reloadNeededClientIds.delete(clientId);
35017
+ }
35018
+ });
35019
+ this.environment.hot.on("vite:bundled-dev:reload-needed", (payload, client) => {
35020
+ const clientId = this.clients.getId(client);
35021
+ if (!clientId) return;
35022
+ debug$1?.(`TRIGGER: client ${clientId} requested a page reload (${payload.reason})`);
35023
+ this.environment.logger.info(import_picocolors.default.green(`bundling for page reload `) + import_picocolors.default.dim(payload.reason), {
35024
+ clear: true,
35025
+ timestamp: true
35026
+ });
35027
+ this.reloadNeededClientIds.add(clientId);
35028
+ this.ensureOutputAndFlushReloadNeeded();
34967
35029
  });
34968
35030
  this._devEngine = await dev(rolldownOptions, outputOptions, {
34969
35031
  onHmrUpdates: (result) => {
34970
35032
  if (result instanceof Error) {
35033
+ this.environment.logger.error(import_picocolors.default.red(`✘ Build error: ${result.message}`), { error: result });
34971
35034
  for (const client of this.clients.getAll()) client.send({
34972
35035
  type: "error",
34973
35036
  err: prepareError(result)
@@ -34984,6 +35047,7 @@ var BundledDev = class {
34984
35047
  const client = this.clients.get(clientId);
34985
35048
  if (client) this.handleHmrOutput(client, changedFiles, update);
34986
35049
  }
35050
+ if (this.reloadNeededClientIds.size) this.ensureOutputAndFlushReloadNeeded();
34987
35051
  },
34988
35052
  onOutput: (result) => {
34989
35053
  if (result instanceof Error) {
@@ -35002,6 +35066,7 @@ var BundledDev = class {
35002
35066
  this.fullReloadPending = false;
35003
35067
  this.debouncedFullReload();
35004
35068
  }
35069
+ if (this.reloadNeededClientIds.size) this.debouncedReloadNeededFlush();
35005
35070
  },
35006
35071
  onAdditionalAssets: (result) => {
35007
35072
  this.storeOutputFiles(result.output);
@@ -35038,6 +35103,9 @@ var BundledDev = class {
35038
35103
  state = await this.devEngine.getBundleState();
35039
35104
  }
35040
35105
  }
35106
+ ensureOutputAndFlushReloadNeeded() {
35107
+ this.devEngine.ensureLatestBuildOutput().then(() => this.debouncedReloadNeededFlush(), () => {});
35108
+ }
35041
35109
  async triggerBundleRegenerationIfStale() {
35042
35110
  const bundleState = await this.devEngine.getBundleState();
35043
35111
  if (this.initialBuildCompleted && bundleState.lastBuildErrored && bundleState.lastErrorStage === "Hmr") {
@@ -35175,6 +35243,9 @@ var Clients = class {
35175
35243
  get(id) {
35176
35244
  return this.idToClient.get(id);
35177
35245
  }
35246
+ getId(client) {
35247
+ return this.clientToId.get(client);
35248
+ }
35178
35249
  getAll() {
35179
35250
  return Array.from(this.idToClient.values());
35180
35251
  }
@@ -35290,6 +35361,23 @@ var DevEnvironment = class extends BaseEnvironment {
35290
35361
  this._initiated = true;
35291
35362
  this._pluginContainer = await createEnvironmentPluginContainer(this, this.config.plugins, options?.watcher);
35292
35363
  }
35364
+ /** @internal */
35365
+ async _registerInputsAsSafeModules() {
35366
+ const input = this.config.input;
35367
+ const entries = input == null ? ["index.html"] : typeof input === "string" ? [input] : Array.isArray(input) ? input : Object.values(input);
35368
+ const resolveEntries = async () => {
35369
+ const resolvedEntries = await Promise.all(entries.map((entry) => this.pluginContainer.resolveId(entry, void 0, {
35370
+ isEntry: true,
35371
+ scan: true
35372
+ })));
35373
+ for (const resolved of resolvedEntries) if (resolved && !resolved.external) {
35374
+ const resolvedId = cleanUrl(resolved.id);
35375
+ if (path.isAbsolute(resolvedId)) this.getTopLevelConfig().safeModulePaths.add(resolvedId);
35376
+ }
35377
+ };
35378
+ if (input == null) await resolveEntries().catch(() => {});
35379
+ else await resolveEntries();
35380
+ }
35293
35381
  /**
35294
35382
  * When the dev server is restarted, the methods are called in the following order:
35295
35383
  * - new instance `init`
@@ -35758,7 +35846,7 @@ function findEsmSyntaxInCjs(code, ast, file) {
35758
35846
  }
35759
35847
  }
35760
35848
  function describeIncompatibility(item, root) {
35761
- const loc = `${normalizePath(path.relative(root, item.file))}:${item.line}`;
35849
+ const loc = `${normalizePath(path.relative(root, item.file))}:${item.line}:${item.column + 1}`;
35762
35850
  switch (item.type) {
35763
35851
  case "dirname": return `\`__dirname\` (${loc}). Use \`import.meta.dirname\` instead`;
35764
35852
  case "filename": return `\`__filename\` (${loc}). Use \`import.meta.filename\` instead`;
@@ -36144,21 +36232,12 @@ const configDefaults = Object.freeze({
36144
36232
  environments: {},
36145
36233
  appType: "spa"
36146
36234
  });
36147
- function resolveInput(input, root) {
36235
+ function normalizeInput(input) {
36148
36236
  if (input === void 0) return;
36149
- if (typeof input === "string") {
36150
- const unescapedInput = unescapeGlobCharacters(input);
36151
- return normalizePath(path.resolve(root, unescapedInput));
36152
- }
36153
- if (Array.isArray(input)) return input.map((inp) => {
36154
- const unescapedInput = unescapeGlobCharacters(inp);
36155
- return normalizePath(path.resolve(root, unescapedInput));
36156
- });
36237
+ if (typeof input === "string") return unescapeGlobCharacters(input);
36238
+ if (Array.isArray(input)) return input.map(unescapeGlobCharacters);
36157
36239
  const resolved = {};
36158
- for (const key in input) {
36159
- const unescapedInput = unescapeGlobCharacters(input[key]);
36160
- resolved[key] = normalizePath(path.resolve(root, unescapedInput));
36161
- }
36240
+ for (const key in input) resolved[key] = unescapeGlobCharacters(input[key]);
36162
36241
  return resolved;
36163
36242
  }
36164
36243
  const escapedGlobCharactersRE = /\\([*?[\]{}()!+@|])/g;
@@ -36180,7 +36259,7 @@ function resolveDevEnvironmentOptions(dev, environmentName, consumer, preTransfo
36180
36259
  sourcemapIgnoreList: resolved.sourcemapIgnoreList === false ? () => false : resolved.sourcemapIgnoreList
36181
36260
  };
36182
36261
  }
36183
- function resolveEnvironmentOptions(options, alias, preserveSymlinks, root, forceOptimizeDeps, logger, environmentName, isBuild, isBundledDev, isSsrTargetWebworkerSet, preTransformRequests) {
36262
+ function resolveEnvironmentOptions(options, alias, preserveSymlinks, forceOptimizeDeps, logger, environmentName, isBuild, isBundledDev, isSsrTargetWebworkerSet, preTransformRequests) {
36184
36263
  const isClientEnvironment = environmentName === "client";
36185
36264
  const consumer = options.consumer ?? (isClientEnvironment ? "client" : "server");
36186
36265
  const isSsrTargetWebworkerEnvironment = isSsrTargetWebworkerSet && environmentName === "ssr";
@@ -36194,7 +36273,7 @@ function resolveEnvironmentOptions(options, alias, preserveSymlinks, root, force
36194
36273
  }
36195
36274
  const resolve = resolveEnvironmentResolveOptions(options.resolve, alias, preserveSymlinks, logger, consumer, isSsrTargetWebworkerEnvironment);
36196
36275
  return {
36197
- input: resolveInput(options.input, root),
36276
+ input: normalizeInput(options.input),
36198
36277
  define: options.define,
36199
36278
  resolve,
36200
36279
  keepProcessEnv: options.keepProcessEnv ?? (isSsrTargetWebworkerEnvironment ? false : consumer === "server"),
@@ -36453,7 +36532,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
36453
36532
  config.resolve.mainFields = config.environments.client.resolve?.mainFields;
36454
36533
  const resolvedDefaultResolve = resolveResolveOptions(config.resolve, logger);
36455
36534
  const resolvedEnvironments = {};
36456
- for (const environmentName of Object.keys(config.environments)) resolvedEnvironments[environmentName] = resolveEnvironmentOptions(config.environments[environmentName], resolvedDefaultResolve.alias, resolvedDefaultResolve.preserveSymlinks, resolvedRoot, inlineConfig.forceOptimizeDeps, logger, environmentName, isBuild, isBundledDev, config.ssr?.target === "webworker", config.server?.preTransformRequests);
36535
+ for (const environmentName of Object.keys(config.environments)) resolvedEnvironments[environmentName] = resolveEnvironmentOptions(config.environments[environmentName], resolvedDefaultResolve.alias, resolvedDefaultResolve.preserveSymlinks, inlineConfig.forceOptimizeDeps, logger, environmentName, isBuild, isBundledDev, config.ssr?.target === "webworker", config.server?.preTransformRequests);
36457
36536
  const backwardCompatibleOptimizeDeps = resolvedEnvironments.client.optimizeDeps;
36458
36537
  const resolvedDevEnvironmentOptions = resolveDevEnvironmentOptions(config.dev, void 0, void 0);
36459
36538
  const resolvedBuildOptions = resolveBuildEnvironmentOptions(config.build ?? {}, logger, void 0, isBundledDev, config.input);
@@ -36489,6 +36568,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
36489
36568
  const assetsFilter = config.assetsInclude && (!Array.isArray(config.assetsInclude) || config.assetsInclude.length) ? createFilter$1(config.assetsInclude) : () => false;
36490
36569
  const { publicDir } = config;
36491
36570
  const resolvedPublicDir = publicDir !== false && publicDir !== "" ? normalizePath(path.resolve(resolvedRoot, typeof publicDir === "string" ? publicDir : configDefaults.publicDir)) : "";
36571
+ const input = normalizeInput(config.input);
36492
36572
  const server = await resolveServerOptions(resolvedRoot, config.server, logger);
36493
36573
  const builder = resolveBuilderOptions(config.builder);
36494
36574
  const BASE_URL = resolvedBase;
@@ -36613,7 +36693,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
36613
36693
  removeSsrLoadModule: "warn"
36614
36694
  } : config.future,
36615
36695
  ssr,
36616
- input: resolveInput(config.input, resolvedRoot),
36696
+ input,
36617
36697
  optimizeDeps: backwardCompatibleOptimizeDeps,
36618
36698
  resolve: resolvedDefaultResolve,
36619
36699
  dev: resolvedDevEnvironmentOptions,
@@ -1,6 +1,6 @@
1
1
  import { ft as __commonJSMin, pt as __require } from "./node.js";
2
2
  import { t as require_lib } from "./lib.js";
3
- //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.20/node_modules/postcss-import/lib/format-import-prelude.js
3
+ //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.23/node_modules/postcss-import/lib/format-import-prelude.js
4
4
  var require_format_import_prelude = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5
5
  module.exports = function formatImportPrelude(layer, media, supports) {
6
6
  const parts = [];
@@ -15,7 +15,7 @@ var require_format_import_prelude = /* @__PURE__ */ __commonJSMin(((exports, mod
15
15
  };
16
16
  }));
17
17
  //#endregion
18
- //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.20/node_modules/postcss-import/lib/base64-encoded-import.js
18
+ //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.23/node_modules/postcss-import/lib/base64-encoded-import.js
19
19
  var require_base64_encoded_import = /* @__PURE__ */ __commonJSMin(((exports, module) => {
20
20
  const formatImportPrelude = require_format_import_prelude();
21
21
  module.exports = function base64EncodedConditionalImport(prelude, conditions) {
@@ -28,7 +28,7 @@ var require_base64_encoded_import = /* @__PURE__ */ __commonJSMin(((exports, mod
28
28
  };
29
29
  }));
30
30
  //#endregion
31
- //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.20/node_modules/postcss-import/lib/apply-conditions.js
31
+ //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.23/node_modules/postcss-import/lib/apply-conditions.js
32
32
  var require_apply_conditions = /* @__PURE__ */ __commonJSMin(((exports, module) => {
33
33
  const base64EncodedConditionalImport = require_base64_encoded_import();
34
34
  module.exports = function applyConditions(bundle, atRule) {
@@ -103,7 +103,7 @@ var require_apply_conditions = /* @__PURE__ */ __commonJSMin(((exports, module)
103
103
  };
104
104
  }));
105
105
  //#endregion
106
- //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.20/node_modules/postcss-import/lib/apply-raws.js
106
+ //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.23/node_modules/postcss-import/lib/apply-raws.js
107
107
  var require_apply_raws = /* @__PURE__ */ __commonJSMin(((exports, module) => {
108
108
  module.exports = function applyRaws(bundle) {
109
109
  bundle.forEach((stmt, index) => {
@@ -117,7 +117,7 @@ var require_apply_raws = /* @__PURE__ */ __commonJSMin(((exports, module) => {
117
117
  };
118
118
  }));
119
119
  //#endregion
120
- //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.20/node_modules/postcss-import/lib/apply-styles.js
120
+ //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.23/node_modules/postcss-import/lib/apply-styles.js
121
121
  var require_apply_styles = /* @__PURE__ */ __commonJSMin(((exports, module) => {
122
122
  module.exports = function applyStyles(bundle, styles) {
123
123
  styles.nodes = [];
@@ -137,7 +137,7 @@ var require_apply_styles = /* @__PURE__ */ __commonJSMin(((exports, module) => {
137
137
  };
138
138
  }));
139
139
  //#endregion
140
- //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.20/node_modules/postcss-import/lib/data-url.js
140
+ //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.23/node_modules/postcss-import/lib/data-url.js
141
141
  var require_data_url = /* @__PURE__ */ __commonJSMin(((exports, module) => {
142
142
  const anyDataURLRegexp = /^data:text\/css(?:;(base64|plain))?,/i;
143
143
  const base64DataURLRegexp = /^data:text\/css;base64,/i;
@@ -156,7 +156,7 @@ var require_data_url = /* @__PURE__ */ __commonJSMin(((exports, module) => {
156
156
  };
157
157
  }));
158
158
  //#endregion
159
- //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.20/node_modules/postcss-import/lib/parse-statements.js
159
+ //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.23/node_modules/postcss-import/lib/parse-statements.js
160
160
  var require_parse_statements = /* @__PURE__ */ __commonJSMin(((exports, module) => {
161
161
  const valueParser = require_lib();
162
162
  const { stringify } = valueParser;
@@ -281,7 +281,7 @@ var require_parse_statements = /* @__PURE__ */ __commonJSMin(((exports, module)
281
281
  }
282
282
  }));
283
283
  //#endregion
284
- //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.20/node_modules/postcss-import/lib/process-content.js
284
+ //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.23/node_modules/postcss-import/lib/process-content.js
285
285
  var require_process_content = /* @__PURE__ */ __commonJSMin(((exports, module) => {
286
286
  const path$2 = __require("path");
287
287
  let sugarss;
@@ -315,7 +315,7 @@ var require_process_content = /* @__PURE__ */ __commonJSMin(((exports, module) =
315
315
  }
316
316
  }));
317
317
  //#endregion
318
- //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.20/node_modules/postcss-import/lib/parse-styles.js
318
+ //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.23/node_modules/postcss-import/lib/parse-styles.js
319
319
  var require_parse_styles = /* @__PURE__ */ __commonJSMin(((exports, module) => {
320
320
  const path$1 = __require("path");
321
321
  const dataURL = require_data_url();
@@ -418,7 +418,7 @@ var require_parse_styles = /* @__PURE__ */ __commonJSMin(((exports, module) => {
418
418
  module.exports = parseStyles;
419
419
  }));
420
420
  //#endregion
421
- //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.20/node_modules/postcss-import/index.js
421
+ //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.23/node_modules/postcss-import/index.js
422
422
  var require_postcss_import = /* @__PURE__ */ __commonJSMin(((exports, module) => {
423
423
  const path = __require("path");
424
424
  const applyConditions = require_apply_conditions();
@@ -30,7 +30,7 @@ import { LessPreprocessorBaseOptions, SassModernPreprocessBaseOptions, StylusPre
30
30
  import { withFilter } from "rolldown/filter";
31
31
  import { GeneralImportGlobOptions, ImportGlobFunction, ImportGlobOptions, KnownAsTypeMap, KnownQueryTypeMap } from "#types/importGlob";
32
32
  //#endregion
33
- //#region ../../node_modules/.pnpm/@vitejs+devtools@0.4.1_crossws@0.4.10_srvx@0.11.15_typescript@6.0.3_valibot@1.4.2_vite@packages+vite/node_modules/@vitejs/devtools/dist/cli-commands.d.ts
33
+ //#region ../../node_modules/.pnpm/@vitejs+devtools@0.4.8_crossws@0.4.10_srvx@0.11.15_typescript@6.0.3_valibot@1.4.2_vite@packages+vite/node_modules/@vitejs/devtools/dist/cli-commands.d.ts
34
34
  //#region src/node/cli-commands.d.ts
35
35
  interface StartOptions {
36
36
  root?: string;
@@ -40,7 +40,7 @@ interface StartOptions {
40
40
  open?: boolean;
41
41
  }
42
42
  //#endregion
43
- //#region ../../node_modules/.pnpm/@vitejs+devtools@0.4.1_crossws@0.4.10_srvx@0.11.15_typescript@6.0.3_valibot@1.4.2_vite@packages+vite/node_modules/@vitejs/devtools/dist/config.d.ts
43
+ //#region ../../node_modules/.pnpm/@vitejs+devtools@0.4.8_crossws@0.4.10_srvx@0.11.15_typescript@6.0.3_valibot@1.4.2_vite@packages+vite/node_modules/@vitejs/devtools/dist/config.d.ts
44
44
  //#region src/node/config.d.ts
45
45
  interface DevToolsConfig extends Partial<StartOptions> {
46
46
  enabled: boolean;
@@ -1631,6 +1631,8 @@ declare class BundledDev {
1631
1631
  private clients;
1632
1632
  private debouncedFullReload;
1633
1633
  private fullReloadPending;
1634
+ private reloadNeededClientIds;
1635
+ private debouncedReloadNeededFlush;
1634
1636
  private lastBuildError;
1635
1637
  memoryFiles: MemoryFiles;
1636
1638
  constructor(environment: DevEnvironment);
@@ -1638,6 +1640,7 @@ declare class BundledDev {
1638
1640
  private pendingPayloadFilenames;
1639
1641
  listen(): Promise<void>;
1640
1642
  private waitForInitialBuildFinish;
1643
+ private ensureOutputAndFlushReloadNeeded;
1641
1644
  triggerBundleRegenerationIfStale(): Promise<boolean>;
1642
1645
  triggerLazyBundling(moduleId: string | null, clientId: string | null): Promise<{
1643
1646
  code: string;
@@ -3097,7 +3100,7 @@ type ResolveIdFn = (environment: PartialEnvironment, id: string, importer?: stri
3097
3100
  */
3098
3101
  declare function createIdResolver(config: ResolvedConfig, options?: Partial<InternalResolveOptions>): ResolveIdFn;
3099
3102
  //#endregion
3100
- //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.20_tsx@4.23.1_yaml@2.9.0/node_modules/postcss-load-config/src/index.d.ts
3103
+ //#region ../../node_modules/.pnpm/postcss-load-config@6.0.1_jiti@2.7.0_postcss@8.5.23_tsx@4.23.1_yaml@2.9.0/node_modules/postcss-load-config/src/index.d.ts
3101
3104
  type ConfigPlugin = Transformer | PostCSS.Plugin | Processor;
3102
3105
  interface Config {
3103
3106
  parser?: string | ProcessOptions['parser'] | false;
@@ -3496,7 +3499,7 @@ interface UserConfig extends DefaultEnvironmentOptions {
3496
3499
  * the performance. You can use `--force` flag or manually delete the directory
3497
3500
  * to regenerate the cache files. The value can be either an absolute file
3498
3501
  * system path or a path relative to project root.
3499
- * Default to `.vite` when no `package.json` is detected.
3502
+ * Default to `.vite` when neither a `package.json` nor a `node_modules` directory is detected.
3500
3503
  * @default 'node_modules/.vite'
3501
3504
  */
3502
3505
  cacheDir?: string;
@@ -942,7 +942,7 @@ function CallSiteToString() {
942
942
  return addSuffix && (line += ` (${fileLocation})`), line;
943
943
  }
944
944
  function cloneCallSite(frame) {
945
- let object = {};
945
+ let object = Object.create(null);
946
946
  return Object.getOwnPropertyNames(Object.getPrototypeOf(frame)).forEach((name) => {
947
947
  let key = name;
948
948
  object[key] = /^(?:is|get)/.test(name) ? function() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "8.2.0-beta.0",
3
+ "version": "8.2.0",
4
4
  "description": "Native-ESM powered web dev build tool",
5
5
  "keywords": [
6
6
  "build-tool",
@@ -58,7 +58,7 @@
58
58
  "dependencies": {
59
59
  "lightningcss": "^1.33.0",
60
60
  "picomatch": "^4.0.5",
61
- "postcss": "^8.5.20",
61
+ "postcss": "^8.5.23",
62
62
  "rolldown": "~1.2.0",
63
63
  "tinyglobby": "^0.2.17"
64
64
  },
@@ -73,11 +73,11 @@
73
73
  "@types/escape-html": "^1.0.4",
74
74
  "@types/pnpapi": "^0.0.5",
75
75
  "@vercel/detect-agent": "^1.2.3",
76
- "@vitejs/devtools": "^0.4.1",
76
+ "@vitejs/devtools": "^0.4.8",
77
77
  "@vitest/utils": "4.1.10",
78
78
  "@voidzero-dev/vite-task-client": "^0.2.0",
79
79
  "artichokie": "^0.4.4",
80
- "baseline-browser-mapping": "^2.10.43",
80
+ "baseline-browser-mapping": "^2.11.3",
81
81
  "cac": "^7.0.0",
82
82
  "chokidar": "^3.6.0",
83
83
  "connect": "^3.7.0",
@@ -94,7 +94,7 @@
94
94
  "host-validation-middleware": "^0.1.4",
95
95
  "http-proxy-3": "^1.23.3",
96
96
  "launch-editor-middleware": "^2.14.1",
97
- "magic-string": "^1.0.0",
97
+ "magic-string": "^1.1.0",
98
98
  "mlly": "^1.8.2",
99
99
  "mrmime": "^2.0.1",
100
100
  "nanoid": "^5.1.16",
@@ -112,7 +112,7 @@
112
112
  "rolldown-plugin-dts": "^0.27.9",
113
113
  "rollup": "^4.59.0",
114
114
  "rollup-plugin-license": "^3.7.1",
115
- "sass": "^1.101.0",
115
+ "sass": "^1.102.0",
116
116
  "sass-embedded": "^1.100.0",
117
117
  "sirv": "^3.0.2",
118
118
  "strip-literal": "^3.1.0",
@@ -19,6 +19,8 @@ export interface CustomEventMap {
19
19
  'vite:forward-console': ForwardConsolePayload
20
20
  /** @internal */
21
21
  'vite:client-connected': { clientId: string }
22
+ /** @internal */
23
+ 'vite:bundled-dev:reload-needed': { reason: string }
22
24
 
23
25
  // server events
24
26
  'vite:client:connect': undefined