@voidzero-dev/vite-plus-core 0.3.1 → 0.3.3

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.
Files changed (68) hide show
  1. package/LICENSE +0 -29
  2. package/dist/rolldown/cli.mjs +6 -6
  3. package/dist/rolldown/config.d.mts +1 -1
  4. package/dist/rolldown/config.mjs +2 -2
  5. package/dist/rolldown/experimental-index.d.mts +9 -4
  6. package/dist/rolldown/experimental-index.mjs +10 -9
  7. package/dist/rolldown/experimental-runtime-types.d.ts +19 -0
  8. package/dist/rolldown/experimental-runtime.d.ts +19 -0
  9. package/dist/rolldown/experimental-runtime.mjs +42 -0
  10. package/dist/rolldown/filter-index.d.mts +1 -1
  11. package/dist/rolldown/index.d.mts +2 -2
  12. package/dist/rolldown/index.mjs +4 -4
  13. package/dist/rolldown/parallel-plugin-worker.mjs +2 -2
  14. package/dist/rolldown/parallel-plugin.d.mts +1 -1
  15. package/dist/rolldown/parse-ast-index.d.mts +1 -1
  16. package/dist/rolldown/parse-ast-index.mjs +1 -1
  17. package/dist/rolldown/plugins-index.d.mts +3 -3
  18. package/dist/rolldown/plugins-index.mjs +2 -2
  19. package/dist/rolldown/shared/{binding-DZuNHVw4.d.mts → binding-BTa6BPQe.d.mts} +23 -36
  20. package/dist/rolldown/shared/{binding-DmImI4pj.mjs → binding-BbrDfv1x.mjs} +53 -28
  21. package/dist/rolldown/shared/{bindingify-input-options-BYClWKnj.mjs → bindingify-input-options-CbBAjvu6.mjs} +9 -8
  22. package/dist/rolldown/shared/{constructors-BM20b11r.d.mts → constructors-CmDKpWIU.d.mts} +2 -2
  23. package/dist/rolldown/shared/{constructors-mRbcbLyX.mjs → constructors-D9jwEbE4.mjs} +1 -1
  24. package/dist/rolldown/shared/{create-bundler-option-CHTBktos.mjs → create-bundler-option-wxuQPB7F.mjs} +120 -160
  25. package/dist/rolldown/shared/{define-config-DNX0WekP.d.mts → define-config-BFdLpVut.d.mts} +10 -1
  26. package/dist/rolldown/shared/{error-BP8lJHle.mjs → error-CGhV1ebk.mjs} +1 -1
  27. package/dist/rolldown/shared/{load-config-Cx5fx_8Q.mjs → load-config-DOMKIWz0.mjs} +1 -1
  28. package/dist/rolldown/shared/{normalize-string-or-regex-Dm69lpQ-.mjs → normalize-string-or-regex-zc1bUto6.mjs} +1 -1
  29. package/dist/rolldown/shared/{parse-8sr82jSR.mjs → parse-B-7jgDap.mjs} +2 -2
  30. package/dist/rolldown/shared/{resolve-tsconfig-BlNGaH3Y.mjs → resolve-tsconfig-Bf6oL9fm.mjs} +2 -2
  31. package/dist/rolldown/shared/{rolldown-CaX_Wmqc.mjs → rolldown-DZGaRc5R.mjs} +4 -4
  32. package/dist/rolldown/shared/{transform-CVse9_mH.d.mts → transform-DK_nCt9j.d.mts} +1 -1
  33. package/dist/rolldown/shared/{watch-YKfJgIxz.mjs → watch-CUKYWzxY.mjs} +4 -4
  34. package/dist/rolldown/utils-index.d.mts +3 -3
  35. package/dist/rolldown/utils-index.mjs +5 -5
  36. package/dist/tsdown/{build-JVmLFaZt-kqQJ2U7s.js → build-JVmLFaZt-BN9yuB6k.js} +13 -426
  37. package/dist/tsdown/{debug-CpC4hV25-tvH_Dsg5.js → debug-CpC4hV25-BeCITV83.js} +4 -90
  38. package/dist/tsdown/{detect-Bg-d8iUV-KfbO7neP.js → detect-Bg-d8iUV-Cr_BRLVW.js} +1 -1
  39. package/dist/tsdown/{dist-Cuw3Ngo4.js → dist-ByW_jJfv.js} +5 -5
  40. package/dist/tsdown/index-types.d.ts +52 -52
  41. package/dist/tsdown/index.js +4 -4
  42. package/dist/tsdown/internal-DTYQdXId.js +3 -0
  43. package/dist/tsdown/{main-CyNcZUzu.js → main-bgV9NlwM.js} +88 -3
  44. package/dist/tsdown/{resolver-DE0_sy8o-ZQqHQjRu.js → resolver-DE0_sy8o-UMsN-SXx.js} +2 -2
  45. package/dist/tsdown/run.js +4 -4
  46. package/dist/tsdown/{src-BWidcM5N.js → src-D5xv98Iu.js} +4 -4
  47. package/dist/tsdown/target-DgdLrXba-DaJJ11xX.js +586 -0
  48. package/dist/tsdown/{tsc-ChjRhsoQ.js → tsc-BFDF_Im9.js} +3 -3
  49. package/dist/tsdown/tsdown-css.js +5 -3
  50. package/dist/tsdown/tsdown-exe.js +4 -15
  51. package/dist/vite/client/bundledDevClient.mjs +105 -40
  52. package/dist/vite/client/client.mjs +288 -260
  53. package/dist/vite/node/chunks/build.js +19 -19
  54. package/dist/vite/node/chunks/node.js +32770 -32305
  55. package/dist/vite/node/chunks/postcss-import.js +10 -10
  56. package/dist/vite/node/cli.js +12 -8
  57. package/dist/vite/node/index.d.ts +1568 -1577
  58. package/dist/vite/node/index.js +1 -1
  59. package/dist/vite/node/module-runner.d.ts +1 -1
  60. package/dist/vite/node/module-runner.js +199 -200
  61. package/dist/vite/types/customEvent.d.ts +2 -0
  62. package/dist/vite/types/hmrPayload.d.ts +2 -0
  63. package/dist/vite/types/internal/cssPreprocessorOptions.d.ts +2 -2
  64. package/dist/vite/types/internal/devtoolsOptions.d.ts +9 -0
  65. package/package.json +23 -26
  66. package/dist/tsdown/internal-D-JfB5uT.js +0 -29
  67. package/dist/tsdown/internal-lhH-5yya.js +0 -62
  68. package/dist/tsdown/version-CQ98ZBpL-Obdnv4J7.js +0 -141
@@ -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.148.0/helpers/esm/typeof.js
44
+ //#region \0@oxc-project+runtime@0.150.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.148.0/helpers/esm/toPrimitive.js
54
+ //#region \0@oxc-project+runtime@0.150.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.148.0/helpers/esm/toPropertyKey.js
66
+ //#region \0@oxc-project+runtime@0.150.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.148.0/helpers/esm/defineProperty.js
72
+ //#region \0@oxc-project+runtime@0.150.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,
@@ -208,6 +208,12 @@ var DevRuntime = class {
208
208
  "hooks",
209
209
  null
210
210
  );
211
+ _defineProperty(
212
+ this,
213
+ /** @type {Map<string, Promise<any>>} */
214
+ "lazyRequests",
215
+ /* @__PURE__ */ new Map()
216
+ );
211
217
  _defineProperty(
212
218
  this,
213
219
  /** @internal */
@@ -322,6 +328,7 @@ var DevRuntime = class {
322
328
  */
323
329
  removeModuleCache(id) {
324
330
  this.moduleCache.delete(id);
331
+ this.lazyRequests.delete(id);
325
332
  this.hooks?.onModuleCacheRemoval(id);
326
333
  }
327
334
  /**
@@ -348,6 +355,29 @@ var DevRuntime = class {
348
355
  }
349
356
  }
350
357
  /**
358
+ * The entry point for a lazy `import()`. `id` is the module the boundary stands for; the
359
+ * boundary's own id appears only inside `fetchChunk`'s URL.
360
+ *
361
+ * Nothing is registered under the boundary id, deliberately. A cache entry with no factory
362
+ * behind it reads as "executed" to the HMR boundary walk, and `applyUpdate` turns an
363
+ * updated-but-factory-less module into a full page reload.
364
+ *
365
+ * A rejection is memoized like any other outcome, matching `import()` of a module that
366
+ * threw. Retrying could not work anyway: a factory registers its module before running its
367
+ * body, so re-running `initModule` would return half-initialized exports as success.
368
+ *
369
+ * @param {string} id
370
+ * @param {() => Promise<unknown>} fetchChunk
371
+ * @returns {Promise<any>}
372
+ */
373
+ requestLazy(id, fetchChunk) {
374
+ const pending = this.lazyRequests.get(id);
375
+ if (pending) return pending;
376
+ const promise = this.moduleCache.has(id) || this.factories.has(id) ? Promise.resolve().then(() => this.initModule(id)) : Promise.resolve().then(fetchChunk).then(() => this.initModule(id));
377
+ this.lazyRequests.set(id, promise);
378
+ return promise;
379
+ }
380
+ /**
351
381
  * @param {string} moduleId
352
382
  */
353
383
  createModuleHotContext(moduleId) {
@@ -632,14 +662,14 @@ var BundledDevHMRClient = class extends HMRClient {
632
662
  if (importerIndex > -1) {
633
663
  const importChain = [
634
664
  importer,
635
- ...[...currentChain].reverse(),
665
+ ...currentChain.toReversed(),
636
666
  ...nodeChain.slice(importerIndex, -1).reverse()
637
667
  ];
638
668
  this.logger.debug(`circular imports detected: ${importChain.join(" -> ")}`);
639
669
  return true;
640
670
  }
641
671
  if (!currentChain.includes(importer)) {
642
- const result = this.isNodeWithinCircularImports(importer, nodeChain, currentChain.concat(importer), traversedModules);
672
+ const result = this.isNodeWithinCircularImports(importer, nodeChain, [...currentChain, importer], traversedModules);
643
673
  if (result) return result;
644
674
  }
645
675
  }
@@ -782,9 +812,33 @@ var BundledDevHMRContext = class extends HMRContext {
782
812
  };
783
813
  //#endregion
784
814
  //#region ../../vite/packages/vite/src/shared/constants.ts
815
+ /**
816
+ * Prefix for resolved Ids that are not valid browser import specifiers
817
+ */
818
+ const VALID_ID_PREFIX = `/@id/`;
819
+ /**
820
+ * Plugins that use 'virtual modules' (e.g. for helper functions), prefix the
821
+ * module ID with `\0`, a convention from the rollup ecosystem.
822
+ * This prevents other plugins from trying to process the id (like node resolution),
823
+ * and core features like sourcemaps can use this info to differentiate between
824
+ * virtual modules and regular files.
825
+ * `\0` is not a permitted char in import URLs so we have to replace them during
826
+ * import analysis. The id will be decoded back before entering the plugins pipeline.
827
+ * These encoded virtual ids are also prefixed by the VALID_ID_PREFIX, so virtual
828
+ * modules in the browser end up encoded as `/@id/__x00__{id}`
829
+ */
830
+ const NULL_BYTE_PLACEHOLDER = `__x00__`;
785
831
  let SOURCEMAPPING_URL = "sourceMa";
786
832
  SOURCEMAPPING_URL += "ppingURL";
787
833
  typeof process !== "undefined" && process.platform;
834
+ /**
835
+ * Prepend `/@id/` and replace null byte so the id is URL-safe.
836
+ * This is prepended to resolved ids that are not valid browser
837
+ * import specifiers by the importAnalysis plugin.
838
+ */
839
+ function wrapId(id) {
840
+ return id.startsWith(VALID_ID_PREFIX) ? id : VALID_ID_PREFIX + id.replace("\0", NULL_BYTE_PLACEHOLDER);
841
+ }
788
842
  (async function() {}).constructor;
789
843
  function promiseWithResolvers() {
790
844
  let resolve;
@@ -1002,39 +1056,6 @@ const createWebSocketModuleRunnerTransport = (options) => {
1002
1056
  };
1003
1057
  };
1004
1058
  //#endregion
1005
- //#region ../../vite/packages/vite/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
1059
  //#region ../../vite/packages/vite/src/shared/forwardConsole.ts
1039
1060
  function setupForwardConsoleHandler(transport, options, console = globalThis.console) {
1040
1061
  if (!options.enabled) return;
@@ -1163,6 +1184,39 @@ function stringifyConsoleArg(value) {
1163
1184
  }
1164
1185
  }
1165
1186
  //#endregion
1187
+ //#region ../../vite/packages/vite/src/shared/hmrHandler.ts
1188
+ function createHMRHandler(handler) {
1189
+ const queue = new Queue();
1190
+ return (payload) => queue.enqueue(() => handler(payload));
1191
+ }
1192
+ var Queue = class {
1193
+ constructor() {
1194
+ _defineProperty(this, "queue", []);
1195
+ _defineProperty(this, "pending", false);
1196
+ }
1197
+ enqueue(promise) {
1198
+ return new Promise((resolve, reject) => {
1199
+ this.queue.push({
1200
+ promise,
1201
+ resolve,
1202
+ reject
1203
+ });
1204
+ this.dequeue();
1205
+ });
1206
+ }
1207
+ dequeue() {
1208
+ if (this.pending) return false;
1209
+ const item = this.queue.shift();
1210
+ if (!item) return false;
1211
+ this.pending = true;
1212
+ item.promise().then(item.resolve).catch(item.reject).finally(() => {
1213
+ this.pending = false;
1214
+ this.dequeue();
1215
+ });
1216
+ return true;
1217
+ }
1218
+ };
1219
+ //#endregion
1166
1220
  //#region ../../vite/packages/vite/src/client/overlay.ts
1167
1221
  const hmrConfigName = __HMR_CONFIG_NAME__;
1168
1222
  const base$1 = __BASE__ || "/";
@@ -1482,14 +1536,18 @@ const debounceReload = (time) => {
1482
1536
  };
1483
1537
  };
1484
1538
  const pageReload = debounceReload(20);
1539
+ function wrapIdIfNeeded(id) {
1540
+ return id[0] === "." || id[0] === "/" ? id : wrapId(id);
1541
+ }
1485
1542
  const hmrClient = new HMRClient({
1486
1543
  error: (err) => console.error("[vite]", err),
1487
1544
  debug: (...msg) => console.debug("[vite]", ...msg)
1488
1545
  }, transport, async function importUpdatedModule({ acceptedPath, timestamp, explicitImportRequired, isWithinCircularImport }) {
1489
1546
  const [acceptedPathWithoutQuery, query] = acceptedPath.split(`?`);
1547
+ const browserPath = wrapIdIfNeeded(acceptedPathWithoutQuery);
1490
1548
  const importPromise = import(
1491
1549
  /* @vite-ignore */
1492
- base + acceptedPathWithoutQuery.slice(1) + `?${explicitImportRequired ? "import&" : ""}t=${timestamp}${query ? `&${query}` : ""}`
1550
+ base + browserPath.slice(1) + `?${explicitImportRequired ? "import&" : ""}t=${timestamp}${query ? `&${query}` : ""}`
1493
1551
  );
1494
1552
  if (isWithinCircularImport) importPromise.catch(() => {
1495
1553
  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.`);
@@ -1798,6 +1856,13 @@ function injectQuery(url, queryToInject) {
1798
1856
  if (typeof DevRuntime !== "undefined") {
1799
1857
  var _ref;
1800
1858
  class ViteDevRuntime extends DevRuntime {
1859
+ payloadDelivered(filename) {
1860
+ transport.send({
1861
+ type: "custom",
1862
+ event: "vite:bundled-dev:payload-delivered",
1863
+ data: { filename }
1864
+ });
1865
+ }
1801
1866
  createModuleHotContext(moduleId) {
1802
1867
  const ctx = new BundledDevHMRContext(bundledDevHmrClient, moduleId);
1803
1868
  ctx._internal = {