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
@@ -0,0 +1,33 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 [these people](https://github.com/rollup/rollup/graphs/contributors)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10
+
11
+ ---
12
+
13
+ MIT License
14
+
15
+ Copyright (c) 2020 Evan Wallace
16
+
17
+ Permission is hereby granted, free of charge, to any person obtaining a copy
18
+ of this software and associated documentation files (the "Software"), to deal
19
+ in the Software without restriction, including without limitation the rights
20
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
+ copies of the Software, and to permit persons to whom the Software is
22
+ furnished to do so, subject to the following conditions:
23
+
24
+ The above copyright notice and this permission notice shall be included in all
25
+ copies or substantial portions of the Software.
26
+
27
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
+ SOFTWARE.
package/dist/cli.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { n as onExit, t as watch } from "./shared/watch-B1b0gmVh.mjs";
2
- import { S as version, x as description } from "./shared/bindingify-input-options-XPJLJOD0.mjs";
3
- import { t as arraify } from "./shared/misc-CoQm4NHO.mjs";
4
- import { a as getInputCliKeys, i as getCliSchemaInfo, l as styleText, o as getOutputCliKeys, r as logger, s as validateCliOptions } from "./shared/rolldown-build-CtPvmZgJ.mjs";
5
- import { t as rolldown } from "./shared/rolldown-ChpIlMRm.mjs";
6
- import { t as loadConfig } from "./shared/load-config-BL_FI6dc.mjs";
1
+ import { n as onExit, t as watch } from "./shared/watch-Cwq-cFUy.mjs";
2
+ import { C as version, S as description } from "./shared/bindingify-input-options-EnUlEF0T.mjs";
3
+ import { t as arraify } from "./shared/misc-DOSKtd97.mjs";
4
+ import { a as getOutputCliKeys, c as styleText, i as getInputCliKeys, n as logger, o as validateCliOptions, r as getCliSchemaInfo } from "./shared/create-bundler-option-4QtiLLuz.mjs";
5
+ import { t as rolldown } from "./shared/rolldown-DP_p9pd3.mjs";
6
+ import { t as loadConfig } from "./shared/load-config-DsMzOVzu.mjs";
7
7
  import path from "node:path";
8
8
  import g$1 from "node:process";
9
9
  import { performance } from "node:perf_hooks";
@@ -862,7 +862,7 @@ function getClearScreenFunction(options) {
862
862
  };
863
863
  }
864
864
  //#endregion
865
- //#region \0@oxc-project+runtime@0.139.0/helpers/esm/usingCtx.js
865
+ //#region \0@oxc-project+runtime@0.142.0/helpers/esm/usingCtx.js
866
866
  function _usingCtx() {
867
867
  var r = "function" == typeof SuppressedError ? SuppressedError : function(r, e) {
868
868
  var n = Error();
@@ -947,7 +947,8 @@ async function bundleWithCliOptions(cliOptions) {
947
947
  const { output: outputs } = await _usingCtx$1.a(await rolldown(cliOptions.input)).generate(cliOptions.output);
948
948
  if (outputs.length === 0) {
949
949
  logger.error("No output generated");
950
- process.exit(1);
950
+ process.exitCode = 1;
951
+ return;
951
952
  }
952
953
  for (const file of outputs) {
953
954
  if (outputs.length > 1) logger.log(`\n${styleText(["cyan", "bold"], `|→ ${file.fileName}:`)}\n`);
@@ -1000,8 +1001,6 @@ async function watchInner(config, cliOptions) {
1000
1001
  case "ERROR":
1001
1002
  await event.result.close();
1002
1003
  logger.error(event.error);
1003
- break;
1004
- default: break;
1005
1004
  }
1006
1005
  });
1007
1006
  logger.log(`Waiting for changes...`);
package/dist/config.d.mts CHANGED
@@ -1,27 +1,26 @@
1
- import { L as VERSION, r as defineConfig, t as ConfigExport } from "./shared/define-config-BhJ90aEv.mjs";
2
-
1
+ import { R as VERSION, r as defineConfig, t as ConfigExport } from "./shared/define-config-DSMNXceb.mjs";
3
2
  //#region src/utils/load-config.d.ts
4
3
  type ConfigLoader = "bundle" | "native";
5
4
  interface LoadConfigOptions {
6
5
  /**
7
- * How to load the config file.
8
- * - `'bundle'` (default): bundle the config with Rolldown, then import it.
9
- * - `'native'`: import the config directly, delegating TypeScript/loader
10
- * handling to the runtime. Faster, but requires runtime support.
11
- *
12
- * @default 'bundle'
13
- */
6
+ * How to load the config file.
7
+ * - `'bundle'` (default): bundle the config with Rolldown, then import it.
8
+ * - `'native'`: import the config directly, delegating TypeScript/loader
9
+ * handling to the runtime. Faster, but requires runtime support.
10
+ *
11
+ * @default 'bundle'
12
+ */
14
13
  configLoader?: ConfigLoader;
15
14
  }
16
15
  /**
17
- * Load config from a file in a way that Rolldown does.
18
- *
19
- * @param configPath The path to the config file. If empty, it will look for `rolldown.config` with supported extensions in the current working directory.
20
- * @param options Loading options. `configLoader` selects `'bundle'` (default) or `'native'`.
21
- * @returns The loaded config export
22
- *
23
- * @category Config
24
- */
16
+ * Load config from a file in a way that Rolldown does.
17
+ *
18
+ * @param configPath The path to the config file. If empty, it will look for `rolldown.config` with supported extensions in the current working directory.
19
+ * @param options Loading options. `configLoader` selects `'bundle'` (default) or `'native'`.
20
+ * @returns The loaded config export
21
+ *
22
+ * @category Config
23
+ */
25
24
  declare function loadConfig(configPath: string, options?: LoadConfigOptions): Promise<ConfigExport>;
26
25
  //#endregion
27
26
  export { VERSION, defineConfig, loadConfig };
package/dist/config.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { b as VERSION } from "./shared/bindingify-input-options-XPJLJOD0.mjs";
1
+ import { x as VERSION } from "./shared/bindingify-input-options-EnUlEF0T.mjs";
2
2
  import { t as defineConfig } from "./shared/define-config-Demdg3_4.mjs";
3
- import { t as loadConfig } from "./shared/load-config-BL_FI6dc.mjs";
3
+ import { t as loadConfig } from "./shared/load-config-DsMzOVzu.mjs";
4
4
  export { VERSION, defineConfig, loadConfig };
@@ -0,0 +1,116 @@
1
+ // @ts-check
2
+
3
+ /** @import { DevRuntime } from './runtime-extra-dev-common.js' */
4
+
5
+ /** @type {typeof DevRuntime} */
6
+ // @ts-expect-error -- there's no way to declare a variable by JSDoc
7
+ var BaseDevRuntime = DevRuntime;
8
+
9
+ class ModuleHotContext {
10
+ /**
11
+ * @type {{ deps: [string], fn: (moduleExports: Record<string, any>[]) => void }[]}
12
+ */
13
+ acceptCallbacks = [];
14
+ /**
15
+ * @param {string} moduleId
16
+ * @param {InstanceType<BaseDevRuntime>} devRuntime
17
+ */
18
+ constructor(moduleId, devRuntime) {
19
+ this.moduleId = moduleId;
20
+ this.devRuntime = devRuntime;
21
+ }
22
+
23
+ /**
24
+ * @overload
25
+ * @param {(mod: Record<string, any>) => void} cb
26
+ * @returns {void}
27
+ */
28
+ /**
29
+ * @param {...any} args
30
+ * @returns {void}
31
+ */
32
+ accept(...args) {
33
+ if (args.length === 1) {
34
+ const [cb] = /** @type {[(mod: Record<string, any>) => void]} */ (args);
35
+ const acceptingPath = this.moduleId;
36
+ this.acceptCallbacks.push({
37
+ deps: [acceptingPath],
38
+ fn: cb,
39
+ });
40
+ } else if (args.length === 0) {}
41
+ else {
42
+ throw new Error('Invalid arguments for `import.meta.hot.accept`');
43
+ }
44
+ }
45
+
46
+ invalidate() {
47
+ socket.send(JSON.stringify({
48
+ type: 'hmr:invalidate',
49
+ moduleId: this.moduleId,
50
+ }));
51
+ }
52
+ }
53
+
54
+ class DefaultDevRuntime extends BaseDevRuntime {
55
+ /**
56
+ * @type {Map<string, ModuleHotContext>}
57
+ */
58
+ moduleHotContexts = new Map();
59
+ /**
60
+ * @override
61
+ * @param {string} moduleId
62
+ */
63
+ createModuleHotContext(moduleId) {
64
+ const hotContext = new ModuleHotContext(moduleId, this);
65
+ this.moduleHotContexts.set(moduleId, hotContext);
66
+ return hotContext;
67
+ }
68
+ }
69
+
70
+ /** @param {string} url */
71
+ function loadScript(url) {
72
+ var script = document.createElement('script');
73
+ script.src = url;
74
+ script.type = 'module';
75
+ script.onerror = function() {
76
+ console.error('Failed to load script: ' + url);
77
+ };
78
+ document.body.appendChild(script);
79
+ }
80
+
81
+ console.debug('HMR runtime loaded', '$ADDR');
82
+ // Generate client ID immediately at runtime initialization
83
+ // This ensures the client ID is available before any lazy imports
84
+ const clientId = crypto.randomUUID();
85
+ const addr = new URL('ws://$ADDR');
86
+ addr.searchParams.set('clientId', clientId);
87
+
88
+ const socket = new WebSocket(addr);
89
+
90
+ (/** @type {any} */ (globalThis)).__rolldown_runtime__ ??=
91
+ new DefaultDevRuntime(clientId);
92
+
93
+ /** @param {MessageEvent} event */
94
+ socket.onmessage = function(event) {
95
+ const data = JSON.parse(event.data);
96
+ console.debug('Received message:', data);
97
+ if (data.type === 'connected') {
98
+ // Server acknowledged the connection
99
+ console.debug('[hmr]: Connection established with server');
100
+ } else if (data.type === 'hmr:update') {
101
+ if (typeof process === 'object') {
102
+ import(data.path);
103
+ console.debug(`[hmr]: Importing HMR patch: ${data.path}`);
104
+ } else {
105
+ console.debug(`[hmr]: Loading HMR patch: ${data.path}`);
106
+ loadScript(data.url);
107
+ }
108
+ } else if (data.type === 'hmr:reload') {
109
+ console.log('[hmr]: Full reload required, reloading page');
110
+ if (typeof location !== 'undefined') {
111
+ location.reload();
112
+ } else {
113
+ console.log('[hmr]: location is undefined, cannot reload page');
114
+ }
115
+ }
116
+ };
@@ -1,8 +1,7 @@
1
- import { B as ResolveResult, C as BindingViteManifestPluginConfig, G as isolatedDeclaration, I as NapiResolveOptions, K as isolatedDeclarationSync, M as IsolatedDeclarationsResult, O as BindingViteTransformPluginConfig, V as ResolverFactory, _ as BindingTsconfigRawOptions, f as BindingRebuildStrategy, g as BindingTsconfigCompilerOptions, i as BindingClientHmrUpdate, j as IsolatedDeclarationsOptions, n as BindingBundleAnalyzerPluginConfig, q as moduleRunnerTransform, r as BindingBundleState } from "./shared/binding-D26QphWG.mjs";
2
- import { Bt as OutputOptions, F as BuiltinPlugin, Q as defineParallelPlugin, Wt as StringOrRegExp, Yt as RolldownOutput, Zt as freeExternalMemory, l as InputOptions, lt as NormalizedOutputOptions } from "./shared/define-config-BhJ90aEv.mjs";
3
- import { a as MinifyOptions$1, c as minifySync$1, d as parse$1, f as parseSync$1, i as transformSync$1, l as ParseResult$1, m as resolveTsconfig, n as TransformResult$1, o as MinifyResult$1, p as TsconfigCache$1, r as transform$1, s as minify$1, t as TransformOptions$1, u as ParserOptions$1 } from "./shared/transform-BPrUvqEZ.mjs";
4
- 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-BbWPse2X.mjs";
5
-
1
+ import { H as ResolverFactory, J as moduleRunnerTransform, K as isolatedDeclaration, L as NapiResolveOptions, M as IsolatedDeclarationsOptions, N as IsolatedDeclarationsResult, V as ResolveResult, _ as BindingTsconfigCompilerOptions, i as BindingClientHmrUpdate, k as BindingViteTransformPluginConfig, n as BindingBundleAnalyzerPluginConfig, p as BindingRebuildStrategy, q as isolatedDeclarationSync, r as BindingBundleState, u as BindingLazyChunkOutput, v as BindingTsconfigRawOptions, w as BindingViteManifestPluginConfig } from "./shared/binding-CVtkJvyl.mjs";
2
+ import { $ as defineParallelPlugin, Gt as StringOrRegExp, I as BuiltinPlugin, Qt as freeExternalMemory, Vt as OutputOptions, Xt as RolldownOutput, l as InputOptions, ut as NormalizedOutputOptions } from "./shared/define-config-DSMNXceb.mjs";
3
+ import { a as MinifyOptions$1, c as minifySync$1, d as parse$1, f as parseSync$1, i as transformSync$1, l as ParseResult$1, m as resolveTsconfig, n as TransformResult$1, o as MinifyResult$1, p as TsconfigCache$1, r as transform$1, s as minify$1, t as TransformOptions$1, u as ParserOptions$1 } from "./shared/transform-WmU_cI8e.mjs";
4
+ 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-ALilxAii.mjs";
6
5
  //#region src/api/dev/dev-options.d.ts
7
6
  type DevOnHmrUpdates = (result: Error | {
8
7
  updates: BindingClientHmrUpdate[];
@@ -12,80 +11,87 @@ type DevOnOutput = (result: Error | RolldownOutput) => void | Promise<void>;
12
11
  type DevOnAdditionalAssets = (output: RolldownOutput) => void | Promise<void>;
13
12
  interface DevWatchOptions {
14
13
  /**
15
- * If `true`, files are not written to disk.
16
- * @default false
17
- */
14
+ * If `false`, no file system watcher is started, so file changes are never
15
+ * picked up and no rebuild or HMR update is triggered on their own.
16
+ * @default true
17
+ */
18
+ enabled?: boolean;
19
+ /**
20
+ * If `true`, files are not written to disk.
21
+ * @default false
22
+ */
18
23
  skipWrite?: boolean;
19
24
  /**
20
- * If `true`, use polling instead of native file system events for watching.
21
- * @default false
22
- */
25
+ * If `true`, use polling instead of native file system events for watching.
26
+ * @default false
27
+ */
23
28
  usePolling?: boolean;
24
29
  /**
25
- * Poll interval in milliseconds (only used when usePolling is true).
26
- * @default 100
27
- */
30
+ * Poll interval in milliseconds (only used when usePolling is true).
31
+ * @default 100
32
+ */
28
33
  pollInterval?: number;
29
34
  /**
30
- * If `true`, use debounced watcher. If `false`, use non-debounced watcher for immediate responses.
31
- * @default true
32
- */
35
+ * If `true`, use debounced watcher. If `false`, use non-debounced watcher for immediate responses.
36
+ * @default true
37
+ */
33
38
  useDebounce?: boolean;
34
39
  /**
35
- * Debounce duration in milliseconds (only used when useDebounce is true).
36
- * @default 10
37
- */
40
+ * Debounce duration in milliseconds (only used when useDebounce is true).
41
+ * @default 10
42
+ */
38
43
  debounceDuration?: number;
39
44
  /**
40
- * Whether to compare file contents for poll-based watchers (only used when usePolling is true).
41
- * When enabled, poll watchers will check file contents to determine if they actually changed.
42
- * @default false
43
- */
45
+ * Whether to compare file contents for poll-based watchers (only used when usePolling is true).
46
+ * When enabled, poll watchers will check file contents to determine if they actually changed.
47
+ * @default false
48
+ */
44
49
  compareContentsForPolling?: boolean;
45
50
  /**
46
- * Tick rate in milliseconds for debounced watchers (only used when useDebounce is true).
47
- * Controls how frequently the debouncer checks for events to process.
48
- * When not specified, the debouncer will auto-select an appropriate tick rate (1/4 of the debounce duration).
49
- * @default undefined (auto-select)
50
- */
51
+ * Tick rate in milliseconds for debounced watchers (only used when useDebounce is true).
52
+ * Controls how frequently the debouncer checks for events to process.
53
+ * When not specified, the debouncer will auto-select an appropriate tick rate (1/4 of the debounce duration).
54
+ * @default undefined (auto-select)
55
+ */
51
56
  debounceTickRate?: number;
52
57
  /**
53
- * Filter to limit which discovered files are registered with the file watcher.
54
- *
55
- * Strings are treated as glob patterns.
56
- *
57
- * @default []
58
- */
58
+ * Filter to limit which discovered files are registered with the file watcher.
59
+ *
60
+ * Strings are treated as glob patterns.
61
+ *
62
+ * @default []
63
+ */
59
64
  include?: StringOrRegExp | StringOrRegExp[];
60
65
  /**
61
- * Filter to prevent discovered files from being registered with the file watcher.
62
- *
63
- * Strings are treated as glob patterns.
64
- *
65
- * @default []
66
- */
66
+ * Filter to prevent discovered files from being registered with the file watcher.
67
+ *
68
+ * Strings are treated as glob patterns.
69
+ *
70
+ * @default []
71
+ */
67
72
  exclude?: StringOrRegExp | StringOrRegExp[];
68
73
  }
69
74
  interface DevOptions {
70
75
  onHmrUpdates?: DevOnHmrUpdates;
71
76
  onOutput?: DevOnOutput;
72
77
  /**
73
- * Called with assets emitted while generating an HMR patch or compiling a
74
- * lazy entry (e.g. an image newly imported by the changed/lazy module).
75
- *
76
- * These never go through {@link onOutput}, so a consumer that serves built
77
- * files (e.g. Vite's bundled dev server) must register this to receive them
78
- * and write them to its in-memory file store before the client requests them.
79
- */
78
+ * Called with assets emitted while generating an HMR patch or compiling a
79
+ * lazy entry (e.g. an image newly imported by the changed/lazy module).
80
+ *
81
+ * These never go through {@link onOutput}, so a consumer that serves built
82
+ * files (e.g. Vite's bundled dev server) must register this to receive them
83
+ * and write them to its in-memory file store before the client requests them.
84
+ */
80
85
  onAdditionalAssets?: DevOnAdditionalAssets;
81
86
  /**
82
- * Strategy for triggering rebuilds after HMR updates.
83
- * - `'always'`: Always trigger a rebuild after HMR updates
84
- * - `'auto'`: Trigger rebuild only if HMR updates contain full reload updates
85
- * - `'never'`: Never trigger rebuild after HMR updates (default)
86
- * @default 'auto'
87
- */
88
- rebuildStrategy?: "always" | "auto" | "never";
87
+ * Strategy for triggering rebuilds after HMR updates.
88
+ * - `'always'`: Always trigger a rebuild after HMR updates
89
+ * - `'never'`: Never trigger rebuild after HMR updates. The server no longer
90
+ * decides full reloads, so there is no `'auto'` upgrade anymore; pull fresh
91
+ * bundle output explicitly (e.g. `ensureLatestBuildOutput`) when needed.
92
+ * @default 'never'
93
+ */
94
+ rebuildStrategy?: "always" | "never";
89
95
  watch?: DevWatchOptions;
90
96
  }
91
97
  //#endregion
@@ -99,22 +105,31 @@ declare class DevEngine {
99
105
  getBundleState(): Promise<BindingBundleState>;
100
106
  ensureLatestBuildOutput(): Promise<void>;
101
107
  triggerFullBuild(): void;
102
- invalidate(file: string, firstInvalidatedBy?: string): Promise<BindingClientHmrUpdate[]>;
103
- registerModules(clientId: string, modules: string[]): Promise<void>;
108
+ /**
109
+ * Client-connect signal (the clientId hello): creates the per-client session
110
+ * with an empty ship map. Reconnects arrive as fresh clientIds.
111
+ */
112
+ registerClient(clientId: string): Promise<void>;
113
+ /**
114
+ * Delivery notification from the serving middleware: the response for
115
+ * `filename` completed, so record its modules as shipped to that client.
116
+ */
117
+ notifyPayloadDelivered(filename: string): Promise<void>;
104
118
  removeClient(clientId: string): Promise<void>;
105
119
  close(): Promise<void>;
106
120
  /**
107
- * Compile a lazy entry module and return HMR-style patch code.
108
- *
109
- * This is called when a dynamically imported module is first requested at runtime.
110
- * The module was previously stubbed with a proxy, and now we need to compile the
111
- * actual module and its dependencies.
112
- *
113
- * @param moduleId - The absolute file path of the module to compile
114
- * @param clientId - The client ID requesting this compilation
115
- * @returns The compiled JavaScript code as a string (HMR patch format)
116
- */
117
- compileEntry(moduleId: string, clientId: string): Promise<string>;
121
+ * Compile a lazy entry module and return HMR-style patch code.
122
+ *
123
+ * This is called when a dynamically imported module is first requested at runtime.
124
+ * The module was previously stubbed with a proxy, and now we need to compile the
125
+ * actual module and its dependencies.
126
+ *
127
+ * @param moduleId - The absolute file path of the module to compile
128
+ * @param clientId - The client ID requesting this compilation
129
+ * @returns The compiled chunk: its code plus the filename whose delivery the
130
+ * serving middleware reports via {@link notifyPayloadDelivered}
131
+ */
132
+ compileEntry(moduleId: string, clientId: string): Promise<BindingLazyChunkOutput>;
118
133
  }
119
134
  //#endregion
120
135
  //#region src/api/dev/index.d.ts
@@ -122,20 +137,20 @@ declare const dev: typeof DevEngine.create;
122
137
  //#endregion
123
138
  //#region src/api/experimental.d.ts
124
139
  /**
125
- * This is an experimental API. Its behavior may change in the future.
126
- *
127
- * - Calling this API will only execute the `scan/build` stage of rolldown.
128
- * - `scan` will clean up all resources automatically, but if you want to ensure timely cleanup, you need to wait for the returned promise to resolve.
129
- *
130
- * @example To ensure cleanup of resources, use the returned promise to wait for the scan to complete.
131
- * ```ts
132
- * import { scan } from 'rolldown/api/experimental';
133
- *
134
- * const cleanupPromise = await scan(...);
135
- * await cleanupPromise;
136
- * // Now all resources have been cleaned up.
137
- * ```
138
- */
140
+ * This is an experimental API. Its behavior may change in the future.
141
+ *
142
+ * - Calling this API will only execute the `scan/build` stage of rolldown.
143
+ * - `scan` will clean up all resources automatically, but if you want to ensure timely cleanup, you need to wait for the returned promise to resolve.
144
+ *
145
+ * @example To ensure cleanup of resources, use the returned promise to wait for the scan to complete.
146
+ * ```ts
147
+ * import { scan } from 'rolldown/api/experimental';
148
+ *
149
+ * const cleanupPromise = await scan(...);
150
+ * await cleanupPromise;
151
+ * // Now all resources have been cleaned up.
152
+ * ```
153
+ */
139
154
  declare const scan: (rawInputOptions: InputOptions, rawOutputOptions?: {}) => Promise<Promise<void>>;
140
155
  //#endregion
141
156
  //#region src/builtin-plugin/alias-plugin.d.ts
@@ -149,53 +164,53 @@ declare function viteAliasPlugin(config: ViteAliasPluginConfig): BuiltinPlugin;
149
164
  //#endregion
150
165
  //#region src/builtin-plugin/bundle-analyzer-plugin.d.ts
151
166
  /**
152
- * A plugin that analyzes bundle composition and generates detailed reports.
153
- *
154
- * The plugin outputs a file containing detailed information about:
155
- * - All chunks and their relationships
156
- * - Modules bundled in each chunk
157
- * - Import dependencies between chunks
158
- * - Reachable modules from each entry point
159
- *
160
- * @example
161
- * ```js
162
- * import { bundleAnalyzerPlugin } from 'rolldown/experimental';
163
- *
164
- * export default {
165
- * plugins: [
166
- * bundleAnalyzerPlugin()
167
- * ]
168
- * }
169
- * ```
170
- *
171
- * @example
172
- * **Custom filename**
173
- * ```js
174
- * import { bundleAnalyzerPlugin } from 'rolldown/experimental';
175
- *
176
- * export default {
177
- * plugins: [
178
- * bundleAnalyzerPlugin({
179
- * fileName: 'bundle-analysis.json'
180
- * })
181
- * ]
182
- * }
183
- * ```
184
- *
185
- * @example
186
- * **LLM-friendly markdown output**
187
- * ```js
188
- * import { bundleAnalyzerPlugin } from 'rolldown/experimental';
189
- *
190
- * export default {
191
- * plugins: [
192
- * bundleAnalyzerPlugin({
193
- * format: 'md'
194
- * })
195
- * ]
196
- * }
197
- * ```
198
- */
167
+ * A plugin that analyzes bundle composition and generates detailed reports.
168
+ *
169
+ * The plugin outputs a file containing detailed information about:
170
+ * - All chunks and their relationships
171
+ * - Modules bundled in each chunk
172
+ * - Import dependencies between chunks
173
+ * - Reachable modules from each entry point
174
+ *
175
+ * @example
176
+ * ```js
177
+ * import { bundleAnalyzerPlugin } from 'rolldown/experimental';
178
+ *
179
+ * export default {
180
+ * plugins: [
181
+ * bundleAnalyzerPlugin()
182
+ * ]
183
+ * }
184
+ * ```
185
+ *
186
+ * @example
187
+ * **Custom filename**
188
+ * ```js
189
+ * import { bundleAnalyzerPlugin } from 'rolldown/experimental';
190
+ *
191
+ * export default {
192
+ * plugins: [
193
+ * bundleAnalyzerPlugin({
194
+ * fileName: 'bundle-analysis.json'
195
+ * })
196
+ * ]
197
+ * }
198
+ * ```
199
+ *
200
+ * @example
201
+ * **LLM-friendly markdown output**
202
+ * ```js
203
+ * import { bundleAnalyzerPlugin } from 'rolldown/experimental';
204
+ *
205
+ * export default {
206
+ * plugins: [
207
+ * bundleAnalyzerPlugin({
208
+ * format: 'md'
209
+ * })
210
+ * ]
211
+ * }
212
+ * ```
213
+ */
199
214
  declare function bundleAnalyzerPlugin(config?: BindingBundleAnalyzerPluginConfig): BuiltinPlugin;
200
215
  //#endregion
201
216
  //#region src/builtin-plugin/transform-plugin.d.ts
@@ -216,32 +231,32 @@ declare function viteManifestPlugin(config: ViteManifestPluginConfig): BuiltinPl
216
231
  //#endregion
217
232
  //#region src/experimental-index.d.ts
218
233
  /**
219
- * In-memory file system for browser builds.
220
- *
221
- * This is a re-export of the {@link https://github.com/streamich/memfs | memfs} package used by the WASI runtime.
222
- * It allows you to read and write files to a virtual filesystem when using rolldown in browser environments.
223
- *
224
- * - `fs`: A Node.js-compatible filesystem API (`IFs` from memfs)
225
- * - `volume`: The underlying `Volume` instance that stores the filesystem state
226
- *
227
- * Returns `undefined` in Node.js builds (only available in browser builds via `@rolldown/browser`).
228
- *
229
- * @example
230
- * ```typescript
231
- * import { memfs } from 'rolldown/experimental';
232
- *
233
- * // Write files to virtual filesystem before bundling
234
- * memfs?.volume.fromJSON({
235
- * '/src/index.js': 'export const foo = 42;',
236
- * '/package.json': '{"name": "my-app"}'
237
- * });
238
- *
239
- * // Read files from the virtual filesystem
240
- * const content = memfs?.fs.readFileSync('/src/index.js', 'utf8');
241
- * ```
242
- *
243
- * @see {@link https://github.com/streamich/memfs} for more information on the memfs API.
244
- */
234
+ * In-memory file system for browser builds.
235
+ *
236
+ * This is a re-export of the {@link https://github.com/streamich/memfs | memfs} package used by the WASI runtime.
237
+ * It allows you to read and write files to a virtual filesystem when using rolldown in browser environments.
238
+ *
239
+ * - `fs`: A Node.js-compatible filesystem API (`IFs` from memfs)
240
+ * - `volume`: The underlying `Volume` instance that stores the filesystem state
241
+ *
242
+ * Returns `undefined` in Node.js builds (only available in browser builds via `@rolldown/browser`).
243
+ *
244
+ * @example
245
+ * ```typescript
246
+ * import { memfs } from 'rolldown/experimental';
247
+ *
248
+ * // Write files to virtual filesystem before bundling
249
+ * memfs?.volume.fromJSON({
250
+ * '/src/index.js': 'export const foo = 42;',
251
+ * '/package.json': '{"name": "my-app"}'
252
+ * });
253
+ *
254
+ * // Read files from the virtual filesystem
255
+ * const content = memfs?.fs.readFileSync('/src/index.js', 'utf8');
256
+ * ```
257
+ *
258
+ * @see {@link https://github.com/streamich/memfs} for more information on the memfs API.
259
+ */
245
260
  declare const memfs: {
246
261
  fs: any;
247
262
  volume: any;