rolldown 1.1.5 → 1.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.
Files changed (49) hide show
  1. package/THIRD-PARTY-LICENSE +33 -0
  2. package/dist/cli.mjs +9 -10
  3. package/dist/config.d.mts +16 -17
  4. package/dist/config.mjs +2 -2
  5. package/dist/experimental-default-runtime.mjs +116 -0
  6. package/dist/experimental-index.d.mts +170 -155
  7. package/dist/experimental-index.mjs +47 -22
  8. package/dist/experimental-runtime-base.mjs +95 -0
  9. package/dist/experimental-runtime-types.d.ts +111 -41
  10. package/dist/experimental-runtime.d.ts +177 -0
  11. package/dist/experimental-runtime.mjs +257 -0
  12. package/dist/filter-index.d.mts +6 -5
  13. package/dist/filter-index.mjs +1 -3
  14. package/dist/get-log-filter.d.mts +2 -2
  15. package/dist/index.d.mts +4 -4
  16. package/dist/index.mjs +4 -4
  17. package/dist/parallel-plugin-worker.mjs +2 -2
  18. package/dist/parallel-plugin.d.mts +3 -4
  19. package/dist/parse-ast-index.d.mts +19 -20
  20. package/dist/parse-ast-index.mjs +2 -2
  21. package/dist/plugins-index.d.mts +27 -28
  22. package/dist/plugins-index.mjs +2 -2
  23. package/dist/shared/{binding-D26QphWG.d.mts → binding-CVtkJvyl.d.mts} +48 -25
  24. package/dist/shared/{binding-TuFFIE_J.mjs → binding-Cv62mM1i.mjs} +124 -50
  25. package/dist/shared/{bindingify-input-options-XPJLJOD0.mjs → bindingify-input-options-EnUlEF0T.mjs} +209 -252
  26. package/dist/shared/{constructors-BbWPse2X.d.mts → constructors-ALilxAii.d.mts} +9 -10
  27. package/dist/shared/{constructors-D_3i7dpX.mjs → constructors-CuqzPFxJ.mjs} +10 -6
  28. package/dist/shared/{rolldown-build-CtPvmZgJ.mjs → create-bundler-option-4QtiLLuz.mjs} +39 -156
  29. package/dist/shared/define-config-DSMNXceb.d.mts +4066 -0
  30. package/dist/shared/{error-BHRSI0R7.mjs → error-BgfXq0Tb.mjs} +1 -1
  31. package/dist/shared/get-log-filter-AjBknEEO.d.mts +34 -0
  32. package/dist/shared/{load-config-BL_FI6dc.mjs → load-config-DsMzOVzu.mjs} +2 -2
  33. package/dist/shared/{logging-BSNejiLS.d.mts → logging-xuHO4mAy.d.mts} +6 -6
  34. package/dist/shared/{logs-ZGEh6uhb.mjs → logs-DmYCAKcW.mjs} +8 -1
  35. package/dist/shared/{misc-CoQm4NHO.mjs → misc-DOSKtd97.mjs} +9 -1
  36. package/dist/shared/{normalize-string-or-regex-dnh67V_w.mjs → normalize-string-or-regex-BVNGzRe4.mjs} +2 -2
  37. package/dist/shared/{parse-D4dtlfWy.mjs → parse-DQIYJwT4.mjs} +2 -2
  38. package/dist/shared/{prompt--dNycKSZ.mjs → prompt-CH6TK0bC.mjs} +2 -6
  39. package/dist/shared/{resolve-tsconfig-DxqIJB3x.mjs → resolve-tsconfig-CQndqeLj.mjs} +2 -2
  40. package/dist/shared/rolldown-DP_p9pd3.mjs +178 -0
  41. package/dist/shared/transform-WmU_cI8e.d.mts +148 -0
  42. package/dist/shared/{watch-B1b0gmVh.mjs → watch-Cwq-cFUy.mjs} +16 -13
  43. package/dist/utils-index.d.mts +29 -30
  44. package/dist/utils-index.mjs +6 -8
  45. package/package.json +32 -25
  46. package/dist/shared/define-config-BhJ90aEv.d.mts +0 -3978
  47. package/dist/shared/get-log-filter-BpNVNJ5-.d.mts +0 -35
  48. package/dist/shared/rolldown-ChpIlMRm.mjs +0 -40
  49. package/dist/shared/transform-BPrUvqEZ.d.mts +0 -149
@@ -1,17 +1,18 @@
1
- import { n as __toESM, t as require_binding } from "./shared/binding-TuFFIE_J.mjs";
2
- import { n as BuiltinPlugin, t as normalizedStringOrRegex } from "./shared/normalize-string-or-regex-dnh67V_w.mjs";
3
- import { o as transformToRollupOutput } from "./shared/bindingify-input-options-XPJLJOD0.mjs";
4
- import { c as validateOption, n as createBundlerOptions, t as RolldownBuild, u as PluginDriver } from "./shared/rolldown-build-CtPvmZgJ.mjs";
5
- import { i as unwrapBindingResult, r as normalizeBindingResult } from "./shared/error-BHRSI0R7.mjs";
6
- import { n as parseSync$1, t as parse$1 } from "./shared/parse-D4dtlfWy.mjs";
7
- import { a as viteDynamicImportVarsPlugin, c as viteLoadFallbackPlugin, d as viteReporterPlugin, f as viteResolvePlugin, i as viteBuildImportAnalysisPlugin, l as viteModulePreloadPolyfillPlugin, n as isolatedDeclarationPlugin, o as viteImportGlobPlugin, p as viteWebWorkerPostPlugin, r as oxcRuntimePlugin, s as viteJsonPlugin, u as viteReactRefreshWrapperPlugin } from "./shared/constructors-D_3i7dpX.mjs";
8
- import { a as minify$1, i as transformSync$1, n as resolveTsconfig, o as minifySync$1, r as transform$1, t as TsconfigCache$1 } from "./shared/resolve-tsconfig-DxqIJB3x.mjs";
1
+ import { n as __toESM, t as require_binding } from "./shared/binding-Cv62mM1i.mjs";
2
+ import { n as BuiltinPlugin, t as normalizedStringOrRegex } from "./shared/normalize-string-or-regex-BVNGzRe4.mjs";
3
+ import { o as transformToRollupOutput } from "./shared/bindingify-input-options-EnUlEF0T.mjs";
4
+ import { l as PluginDriver, s as validateOption, t as createBundlerOptions } from "./shared/create-bundler-option-4QtiLLuz.mjs";
5
+ import { i as unwrapBindingResult, r as normalizeBindingResult } from "./shared/error-BgfXq0Tb.mjs";
6
+ import { n as parseSync$1, t as parse$1 } from "./shared/parse-DQIYJwT4.mjs";
7
+ import { a as viteDynamicImportVarsPlugin, c as viteLoadFallbackPlugin, d as viteReporterPlugin, f as viteResolvePlugin, i as viteBuildImportAnalysisPlugin, l as viteModulePreloadPolyfillPlugin, n as isolatedDeclarationPlugin, o as viteImportGlobPlugin, p as viteWebWorkerPostPlugin, r as oxcRuntimePlugin, s as viteJsonPlugin, u as viteReactRefreshWrapperPlugin } from "./shared/constructors-CuqzPFxJ.mjs";
8
+ import { a as minify$1, i as transformSync$1, n as resolveTsconfig, o as minifySync$1, r as transform$1, t as TsconfigCache$1 } from "./shared/resolve-tsconfig-CQndqeLj.mjs";
9
9
  import { pathToFileURL } from "node:url";
10
10
  //#region src/api/dev/dev-engine.ts
11
11
  var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
12
12
  var DevEngine = class DevEngine {
13
13
  #inner;
14
14
  #cachedBuildFinishPromise = null;
15
+ #asyncRuntimeReleased = false;
15
16
  static async create(inputOptions, outputOptions = {}, devOptions = {}) {
16
17
  inputOptions = await PluginDriver.callOptionsHook(inputOptions);
17
18
  const options = await createBundlerOptions(inputOptions, outputOptions, false);
@@ -44,8 +45,9 @@ var DevEngine = class DevEngine {
44
45
  onAdditionalAssets: userOnAdditionalAssets ? function(output) {
45
46
  userOnAdditionalAssets(transformToRollupOutput(output));
46
47
  } : void 0,
47
- rebuildStrategy: devOptions.rebuildStrategy ? devOptions.rebuildStrategy === "always" ? import_binding.BindingRebuildStrategy.Always : devOptions.rebuildStrategy === "auto" ? import_binding.BindingRebuildStrategy.Auto : import_binding.BindingRebuildStrategy.Never : void 0,
48
+ rebuildStrategy: devOptions.rebuildStrategy ? devOptions.rebuildStrategy === "always" ? import_binding.BindingRebuildStrategy.Always : import_binding.BindingRebuildStrategy.Never : void 0,
48
49
  watch: devOptions.watch && {
50
+ enabled: devOptions.watch.enabled,
49
51
  skipWrite: devOptions.watch.skipWrite,
50
52
  usePolling: devOptions.watch.usePolling,
51
53
  pollInterval: devOptions.watch.pollInterval,
@@ -58,6 +60,7 @@ var DevEngine = class DevEngine {
58
60
  }
59
61
  };
60
62
  const inner = new import_binding.BindingDevEngine(options.bundlerOptions, bindingDevOptions);
63
+ (0, import_binding.startAsyncRuntime)();
61
64
  return new DevEngine(inner);
62
65
  }
63
66
  constructor(inner) {
@@ -83,17 +86,31 @@ var DevEngine = class DevEngine {
83
86
  triggerFullBuild() {
84
87
  this.#inner.triggerFullBuild();
85
88
  }
86
- async invalidate(file, firstInvalidatedBy) {
87
- return unwrapBindingResult(await this.#inner.invalidate(file, firstInvalidatedBy));
89
+ /**
90
+ * Client-connect signal (the clientId hello): creates the per-client session
91
+ * with an empty ship map. Reconnects arrive as fresh clientIds.
92
+ */
93
+ async registerClient(clientId) {
94
+ await this.#inner.registerClient(clientId);
88
95
  }
89
- async registerModules(clientId, modules) {
90
- await this.#inner.registerModules(clientId, modules);
96
+ /**
97
+ * Delivery notification from the serving middleware: the response for
98
+ * `filename` completed, so record its modules as shipped to that client.
99
+ */
100
+ async notifyPayloadDelivered(filename) {
101
+ await this.#inner.notifyPayloadDelivered(filename);
91
102
  }
92
103
  async removeClient(clientId) {
93
104
  await this.#inner.removeClient(clientId);
94
105
  }
95
106
  async close() {
96
- await this.#inner.close();
107
+ const shouldRelease = !this.#asyncRuntimeReleased;
108
+ this.#asyncRuntimeReleased = true;
109
+ try {
110
+ await this.#inner.close();
111
+ } finally {
112
+ if (shouldRelease) (0, import_binding.shutdownAsyncRuntime)();
113
+ }
97
114
  }
98
115
  /**
99
116
  * Compile a lazy entry module and return HMR-style patch code.
@@ -104,7 +121,8 @@ var DevEngine = class DevEngine {
104
121
  *
105
122
  * @param moduleId - The absolute file path of the module to compile
106
123
  * @param clientId - The client ID requesting this compilation
107
- * @returns The compiled JavaScript code as a string (HMR patch format)
124
+ * @returns The compiled chunk: its code plus the filename whose delivery the
125
+ * serving middleware reports via {@link notifyPayloadDelivered}
108
126
  */
109
127
  async compileEntry(moduleId, clientId) {
110
128
  return this.#inner.compileEntry(moduleId, clientId);
@@ -173,18 +191,25 @@ function freeExternalMemory(handle, keepDataAlive = false) {
173
191
  const scan = async (rawInputOptions, rawOutputOptions = {}) => {
174
192
  validateOption("input", rawInputOptions);
175
193
  validateOption("output", rawOutputOptions);
176
- const ret = await createBundlerOptions(await PluginDriver.callOptionsHook(rawInputOptions), rawOutputOptions, false);
194
+ const inputOptions = await PluginDriver.callOptionsHook(rawInputOptions);
195
+ const ret = await createBundlerOptions(inputOptions, rawOutputOptions, false);
177
196
  const bundler = new import_binding.BindingBundler();
178
- if (RolldownBuild.asyncRuntimeShutdown) (0, import_binding.startAsyncRuntime)();
197
+ (0, import_binding.startAsyncRuntime)();
198
+ let cleanedUp = false;
179
199
  async function cleanup() {
180
- await bundler.close();
181
- await ret.stopWorkers?.();
182
- (0, import_binding.shutdownAsyncRuntime)();
183
- RolldownBuild.asyncRuntimeShutdown = true;
200
+ if (cleanedUp) return;
201
+ cleanedUp = true;
202
+ try {
203
+ await bundler.close();
204
+ await ret.stopWorkers?.();
205
+ } finally {
206
+ (0, import_binding.shutdownAsyncRuntime)();
207
+ }
184
208
  }
185
209
  let cleanupPromise = Promise.resolve();
186
210
  try {
187
- unwrapBindingResult(await bundler.scan(ret.bundlerOptions));
211
+ const result = await bundler.scan(ret.bundlerOptions);
212
+ unwrapBindingResult(result);
188
213
  } catch (err) {
189
214
  await cleanup();
190
215
  throw err;
@@ -0,0 +1,95 @@
1
+ export var __create = Object.create;
2
+ export var __defProp = Object.defineProperty;
3
+ export var __name = (target, value) => __defProp(target, 'name', { value, configurable: true });
4
+ export var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ export var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ export var __getProtoOf = Object.getPrototypeOf;
7
+ export var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ export var __esm = (fn, res, err) =>
9
+ function () {
10
+ if (err) throw err[0];
11
+ try {
12
+ return (fn && (res = (0, fn[__getOwnPropNames(fn)[0]])((fn = 0))), res);
13
+ } catch (e) {
14
+ throw ((err = [e]), e);
15
+ }
16
+ };
17
+ export var __esmMin = (fn, res, err) => () => {
18
+ if (err) throw err[0];
19
+ try {
20
+ return (fn && (res = fn((fn = 0))), res);
21
+ } catch (e) {
22
+ throw ((err = [e]), e);
23
+ }
24
+ };
25
+ export var __commonJS = (cb, mod) =>
26
+ function () {
27
+ return (
28
+ mod || ((0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), cb = null), mod.exports
29
+ );
30
+ };
31
+ export var __commonJSMin = (cb, mod) => () => (
32
+ mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports
33
+ );
34
+ export var __exportAll = (all, no_symbols) => {
35
+ let target = {};
36
+ for (var name in all) {
37
+ __defProp(target, name, { get: all[name], enumerable: true });
38
+ }
39
+ if (!no_symbols) {
40
+ __defProp(target, Symbol.toStringTag, { value: 'Module' });
41
+ }
42
+ return target;
43
+ };
44
+ export var __copyProps = (to, from, except, desc) => {
45
+ if ((from && typeof from === 'object') || typeof from === 'function') {
46
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
47
+ key = keys[i];
48
+ if (!__hasOwnProp.call(to, key) && key !== except) {
49
+ __defProp(to, key, {
50
+ get: ((k) => from[k]).bind(null, key),
51
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
52
+ });
53
+ }
54
+ }
55
+ }
56
+ return to;
57
+ };
58
+ export var __reExport = (target, mod, secondTarget) => (
59
+ __copyProps(target, mod, 'default'), secondTarget && __copyProps(secondTarget, mod, 'default')
60
+ );
61
+ export var __toESM = (mod, isNodeMode, target) => (
62
+ (target = mod != null ? __create(__getProtoOf(mod)) : {}),
63
+ __copyProps(
64
+ // `__esModule` alone is not enough: the module must own a `default` (#10360).
65
+ isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, 'default')
66
+ ? __defProp(target, 'default', { value: mod, enumerable: true })
67
+ : target,
68
+ mod,
69
+ )
70
+ );
71
+ export var __toCommonJS = (mod) =>
72
+ __hasOwnProp.call(mod, 'module.exports')
73
+ ? mod['module.exports']
74
+ : __copyProps(__defProp({}, '__esModule', { value: true }), mod);
75
+ export var __toBinaryNode = (base64) => new Uint8Array(Buffer.from(base64, 'base64'));
76
+ export var __toBinary = /* @__PURE__ */ (() => {
77
+ var table = new Uint8Array(128);
78
+ for (var i = 0; i < 64; i++) {
79
+ table[i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i * 4 - 205] = i;
80
+ }
81
+ return (base64) => {
82
+ var n = base64.length,
83
+ bytes = new Uint8Array((((n - (base64[n - 1] == '=') - (base64[n - 2] == '=')) * 3) / 4) | 0);
84
+ for (var i = 0, j = 0; i < n; ) {
85
+ var c0 = table[base64.charCodeAt(i++)],
86
+ c1 = table[base64.charCodeAt(i++)];
87
+ var c2 = table[base64.charCodeAt(i++)],
88
+ c3 = table[base64.charCodeAt(i++)];
89
+ bytes[j++] = (c0 << 2) | (c1 >> 4);
90
+ bytes[j++] = (c1 << 4) | (c2 >> 2);
91
+ bytes[j++] = (c2 << 6) | c3;
92
+ }
93
+ return bytes;
94
+ };
95
+ })();
@@ -1,31 +1,87 @@
1
1
  /**
2
- * @typedef {{ type: 'hmr:module-registered', modules: string[] }} DevRuntimeMessage
3
- * @typedef {{ send(message: DevRuntimeMessage): void }} Messenger
2
+ * Compiler-emitted module-graph delta pure topology (static + dynamic edges).
3
+ * `ids[0, localCount)` are the modules this payload carries; `ids[localCount, …)` are foreign edge targets.
4
+ * `edges[i]` / `dynamicEdges[i]` are the static / dynamic-`import()` out-edges of `ids[i]`.
5
+ * @typedef {{ ids: string[], localCount: number, edges: number[][], dynamicEdges?: number[][] }} ModuleGraphDelta
6
+ * @typedef {{ createModuleHotContext(moduleId: string): any, onModuleCacheRemoval(moduleId: string): void }} DevRuntimeHooks
4
7
  */
8
+ export class MissingFactoryError {
9
+ /**
10
+ * @param {string} id
11
+ */
12
+ constructor(id: string);
13
+ id: string;
14
+ }
5
15
  export class DevRuntime {
6
16
  /**
7
- * @param {Messenger} messenger
8
17
  * @param {string} clientId
9
18
  */
10
- constructor(messenger: Messenger, clientId: string);
19
+ constructor(clientId: string);
11
20
  /**
12
21
  * Client ID generated at runtime initialization, used for lazy compilation requests.
13
22
  * @type {string}
14
23
  */
15
24
  clientId: string;
16
- messenger: Messenger;
17
25
  /**
18
- * @type {Record<string, Module>}
26
+ * Static import edges from `registerGraph` — entries persist across `removeModuleCache`
27
+ * and change only by replacement from a newer payload (last write wins).
28
+ * @type {Map<string, { edges: string[] }>}
19
29
  */
20
- modules: Record<string, Module>;
30
+ staticImports: Map<string, {
31
+ edges: string[];
32
+ }>;
21
33
  /**
22
- * @param {string} _moduleId
34
+ * Reverse index over the static imports.
35
+ * @type {Map<string, Set<string>>}
23
36
  */
24
- createModuleHotContext(_moduleId: string): void;
37
+ importers: Map<string, Set<string>>;
25
38
  /**
26
- * @param {[string, string][]} _boundaries
39
+ * Dynamic `import()` edges from `registerGraph`, keyed by importer — mirror of
40
+ * `staticImports` for the dynamic reverse index.
41
+ * @type {Map<string, { edges: string[] }>}
27
42
  */
28
- applyUpdates(_boundaries: [string, string][]): void;
43
+ dynamicImports: Map<string, {
44
+ edges: string[];
45
+ }>;
46
+ /**
47
+ * Reverse index over the dynamic imports.
48
+ * @type {Map<string, Set<string>>}
49
+ */
50
+ dynamicImporters: Map<string, Set<string>>;
51
+ /**
52
+ * The module cache. Membership means "this module's side effects ran in this tab" —
53
+ * registration is emitted ahead of every module body, and nothing un-registers on
54
+ * unwind, so a factory that throws mid-body stays registered. A `Map` rather than a
55
+ * plain object: HMR eviction deletes entries, and a `delete` on an object drops V8
56
+ * into dictionary mode, taxing every later lookup on the hottest read path.
57
+ * @type {Map<string, Module>}
58
+ */
59
+ moduleCache: Map<string, Module>;
60
+ /**
61
+ * Re-runnable factories from HMR patches and lazy chunks. The initial bundle stays
62
+ * scope-hoisted and contributes none.
63
+ * @type {Map<string, { kind: 'esm' | 'cjs', fn: (id: string) => void }>}
64
+ */
65
+ factories: Map<string, {
66
+ kind: "esm" | "cjs";
67
+ fn: (id: string) => void;
68
+ }>;
69
+ /**
70
+ * Installed by the dev client at boot. The runtime is a store + executor and makes
71
+ * no HMR decisions; accepting, disposing, and reloading live behind these hooks.
72
+ * @type {DevRuntimeHooks | null}
73
+ */
74
+ hooks: DevRuntimeHooks | null;
75
+ /**
76
+ * @param {ModuleGraphDelta} delta
77
+ */
78
+ registerGraph(delta: ModuleGraphDelta): void;
79
+ /**
80
+ * @param {string} id
81
+ * @param {'esm' | 'cjs'} kind
82
+ * @param {(id: string) => void} fn
83
+ */
84
+ registerFactory(id: string, kind: "esm" | "cjs", fn: (id: string) => void): void;
29
85
  /**
30
86
  * @param {string} id
31
87
  * @param {{ exports: any }} exportsHolder
@@ -35,35 +91,37 @@ export class DevRuntime {
35
91
  }): void;
36
92
  /**
37
93
  * @param {string} id
94
+ * @returns {string[]}
38
95
  */
39
- loadExports(id: string): any;
96
+ getImporters(id: string): string[];
40
97
  /**
41
- * __esmMin
42
- *
43
- * When `dedup` is truthy and `id` is already registered on the runtime,
44
- * skip the factory: another lazy blob got there first. HMR patches pass
45
- * no `dedup` so they always re-run the factory and replace the registered
46
- * exports.
47
- *
48
- * @type {<T>(id: string, fn: any, dedup: any, res: T) => () => T}
49
- * @internal
98
+ * @param {string} id
50
99
  */
51
- createEsmInitializer: <T>(id: string, fn: any, dedup: any, res: T) => () => T;
100
+ isExecuted(id: string): any;
52
101
  /**
53
- * __commonJSMin
54
- *
55
- * Same dedup gate as createEsmInitializer. With `dedup` truthy and `id`
56
- * registered, reuse the registered exports object; otherwise run the
57
- * factory.
58
- *
59
- * @type {<T extends { exports: any }>(id: string, cb: any, dedup: any, mod: { exports: any }, registered: any) => () => T}
60
- * @internal
102
+ * @param {string} id
61
103
  */
62
- createCjsInitializer: <T extends {
63
- exports: any;
64
- }>(id: string, cb: any, dedup: any, mod: {
65
- exports: any;
66
- }, registered: any) => () => T;
104
+ hasFactory(id: string): any;
105
+ /**
106
+ * Module-cache delete only static imports and factories persist. Removal is what
107
+ * re-arms a cache-gated factory for `initModule`.
108
+ * @param {string} id
109
+ */
110
+ removeModuleCache(id: string): void;
111
+ /**
112
+ * The one re-execution gate: registered → return the live exports; otherwise run the
113
+ * mapped factory (which registers itself first, then runs the body).
114
+ * @param {string} id
115
+ */
116
+ initModule(id: string): any;
117
+ /**
118
+ * @param {string} id
119
+ */
120
+ loadExports(id: string): any;
121
+ /**
122
+ * @param {string} moduleId
123
+ */
124
+ createModuleHotContext(moduleId: string): any;
67
125
  /** @internal */
68
126
  __toESM: any;
69
127
  /** @internal */
@@ -78,14 +136,26 @@ export class DevRuntime {
78
136
  __toDynamicImportESM: (isNodeMode?: boolean) => (mod: any) => any;
79
137
  /** @internal */
80
138
  __reExport: any;
81
- sendModuleRegisteredMessage: (module: string) => void;
82
139
  }
83
- export type DevRuntimeMessage = {
84
- type: "hmr:module-registered";
85
- modules: string[];
140
+ /**
141
+ * Compiler-emitted module-graph delta — pure topology (static + dynamic edges).
142
+ * `ids[0, localCount)` are the modules this payload carries; `ids[localCount, …)` are foreign edge targets.
143
+ * `edges[i]` / `dynamicEdges[i]` are the static / dynamic-`import()` out-edges of `ids[i]`.
144
+ */
145
+ export type ModuleGraphDelta = {
146
+ ids: string[];
147
+ localCount: number;
148
+ edges: number[][];
149
+ dynamicEdges?: number[][];
86
150
  };
87
- export type Messenger = {
88
- send(message: DevRuntimeMessage): void;
151
+ /**
152
+ * Compiler-emitted module-graph delta — pure topology (static + dynamic edges).
153
+ * `ids[0, localCount)` are the modules this payload carries; `ids[localCount, …)` are foreign edge targets.
154
+ * `edges[i]` / `dynamicEdges[i]` are the static / dynamic-`import()` out-edges of `ids[i]`.
155
+ */
156
+ export type DevRuntimeHooks = {
157
+ createModuleHotContext(moduleId: string): any;
158
+ onModuleCacheRemoval(moduleId: string): void;
89
159
  };
90
160
  declare class Module {
91
161
  /**
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Compiler-emitted module-graph delta — pure topology (static + dynamic edges).
3
+ * `ids[0, localCount)` are the modules this payload carries; `ids[localCount, …)` are foreign edge targets.
4
+ * `edges[i]` / `dynamicEdges[i]` are the static / dynamic-`import()` out-edges of `ids[i]`.
5
+ * @typedef {{ ids: string[], localCount: number, edges: number[][], dynamicEdges?: number[][] }} ModuleGraphDelta
6
+ * @typedef {{ createModuleHotContext(moduleId: string): any, onModuleCacheRemoval(moduleId: string): void }} DevRuntimeHooks
7
+ */
8
+ export class MissingFactoryError {
9
+ /**
10
+ * @param {string} id
11
+ */
12
+ constructor(id: string);
13
+ id: string;
14
+ }
15
+ export class DevRuntime {
16
+ /**
17
+ * @param {string} clientId
18
+ */
19
+ constructor(clientId: string);
20
+ /**
21
+ * Client ID generated at runtime initialization, used for lazy compilation requests.
22
+ * @type {string}
23
+ */
24
+ clientId: string;
25
+ /**
26
+ * Static import edges from `registerGraph` — entries persist across `removeModuleCache`
27
+ * and change only by replacement from a newer payload (last write wins).
28
+ * @type {Map<string, { edges: string[] }>}
29
+ */
30
+ staticImports: Map<string, {
31
+ edges: string[];
32
+ }>;
33
+ /**
34
+ * Reverse index over the static imports.
35
+ * @type {Map<string, Set<string>>}
36
+ */
37
+ importers: Map<string, Set<string>>;
38
+ /**
39
+ * Dynamic `import()` edges from `registerGraph`, keyed by importer — mirror of
40
+ * `staticImports` for the dynamic reverse index.
41
+ * @type {Map<string, { edges: string[] }>}
42
+ */
43
+ dynamicImports: Map<string, {
44
+ edges: string[];
45
+ }>;
46
+ /**
47
+ * Reverse index over the dynamic imports.
48
+ * @type {Map<string, Set<string>>}
49
+ */
50
+ dynamicImporters: Map<string, Set<string>>;
51
+ /**
52
+ * The module cache. Membership means "this module's side effects ran in this tab" —
53
+ * registration is emitted ahead of every module body, and nothing un-registers on
54
+ * unwind, so a factory that throws mid-body stays registered. A `Map` rather than a
55
+ * plain object: HMR eviction deletes entries, and a `delete` on an object drops V8
56
+ * into dictionary mode, taxing every later lookup on the hottest read path.
57
+ * @type {Map<string, Module>}
58
+ */
59
+ moduleCache: Map<string, Module>;
60
+ /**
61
+ * Re-runnable factories from HMR patches and lazy chunks. The initial bundle stays
62
+ * scope-hoisted and contributes none.
63
+ * @type {Map<string, { kind: 'esm' | 'cjs', fn: (id: string) => void }>}
64
+ */
65
+ factories: Map<string, {
66
+ kind: "esm" | "cjs";
67
+ fn: (id: string) => void;
68
+ }>;
69
+ /**
70
+ * Installed by the dev client at boot. The runtime is a store + executor and makes
71
+ * no HMR decisions; accepting, disposing, and reloading live behind these hooks.
72
+ * @type {DevRuntimeHooks | null}
73
+ */
74
+ hooks: DevRuntimeHooks | null;
75
+ /**
76
+ * @param {ModuleGraphDelta} delta
77
+ */
78
+ registerGraph(delta: ModuleGraphDelta): void;
79
+ /**
80
+ * @param {string} id
81
+ * @param {'esm' | 'cjs'} kind
82
+ * @param {(id: string) => void} fn
83
+ */
84
+ registerFactory(id: string, kind: "esm" | "cjs", fn: (id: string) => void): void;
85
+ /**
86
+ * @param {string} id
87
+ * @param {{ exports: any }} exportsHolder
88
+ */
89
+ registerModule(id: string, exportsHolder: {
90
+ exports: any;
91
+ }): void;
92
+ /**
93
+ * @param {string} id
94
+ * @returns {string[]}
95
+ */
96
+ getImporters(id: string): string[];
97
+ /**
98
+ * @param {string} id
99
+ */
100
+ isExecuted(id: string): any;
101
+ /**
102
+ * @param {string} id
103
+ */
104
+ hasFactory(id: string): any;
105
+ /**
106
+ * Module-cache delete only — static imports and factories persist. Removal is what
107
+ * re-arms a cache-gated factory for `initModule`.
108
+ * @param {string} id
109
+ */
110
+ removeModuleCache(id: string): void;
111
+ /**
112
+ * The one re-execution gate: registered → return the live exports; otherwise run the
113
+ * mapped factory (which registers itself first, then runs the body).
114
+ * @param {string} id
115
+ */
116
+ initModule(id: string): any;
117
+ /**
118
+ * @param {string} id
119
+ */
120
+ loadExports(id: string): any;
121
+ /**
122
+ * @param {string} moduleId
123
+ */
124
+ createModuleHotContext(moduleId: string): any;
125
+ /** @internal */
126
+ __toESM: any;
127
+ /** @internal */
128
+ __toCommonJS: any;
129
+ /** @internal */
130
+ __exportAll: any;
131
+ /**
132
+ * @param {boolean} [isNodeMode]
133
+ * @returns {(mod: any) => any}
134
+ * @internal
135
+ */
136
+ __toDynamicImportESM: (isNodeMode?: boolean) => (mod: any) => any;
137
+ /** @internal */
138
+ __reExport: any;
139
+ }
140
+ /**
141
+ * Compiler-emitted module-graph delta — pure topology (static + dynamic edges).
142
+ * `ids[0, localCount)` are the modules this payload carries; `ids[localCount, …)` are foreign edge targets.
143
+ * `edges[i]` / `dynamicEdges[i]` are the static / dynamic-`import()` out-edges of `ids[i]`.
144
+ */
145
+ export type ModuleGraphDelta = {
146
+ ids: string[];
147
+ localCount: number;
148
+ edges: number[][];
149
+ dynamicEdges?: number[][];
150
+ };
151
+ /**
152
+ * Compiler-emitted module-graph delta — pure topology (static + dynamic edges).
153
+ * `ids[0, localCount)` are the modules this payload carries; `ids[localCount, …)` are foreign edge targets.
154
+ * `edges[i]` / `dynamicEdges[i]` are the static / dynamic-`import()` out-edges of `ids[i]`.
155
+ */
156
+ export type DevRuntimeHooks = {
157
+ createModuleHotContext(moduleId: string): any;
158
+ onModuleCacheRemoval(moduleId: string): void;
159
+ };
160
+ declare class Module {
161
+ /**
162
+ * @param {string} id
163
+ */
164
+ constructor(id: string);
165
+ /**
166
+ * @type {{ exports: any }}
167
+ */
168
+ exportsHolder: {
169
+ exports: any;
170
+ };
171
+ /**
172
+ * @type {string}
173
+ */
174
+ id: string;
175
+ get exports(): any;
176
+ }
177
+ export {};