@rolldown/browser 1.0.0-beta.9-commit.0ec9e7d → 1.0.0-rc.2

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 (73) hide show
  1. package/dist/cli-setup.mjs +16 -0
  2. package/dist/cli.mjs +1084 -1281
  3. package/dist/config.d.mts +1 -3
  4. package/dist/config.mjs +7 -5
  5. package/dist/constructors-B8gqcrFr.js +61 -0
  6. package/dist/experimental-index.browser.mjs +225 -50
  7. package/dist/experimental-index.d.mts +164 -76
  8. package/dist/experimental-index.mjs +220 -60
  9. package/dist/experimental-runtime-types.d.ts +98 -0
  10. package/dist/filter-index.d.mts +104 -2
  11. package/dist/filter-index.mjs +123 -3
  12. package/dist/get-log-filter.d.mts +7 -0
  13. package/dist/get-log-filter.mjs +48 -0
  14. package/dist/index.browser.mjs +242 -2
  15. package/dist/index.d.mts +4 -3
  16. package/dist/index.mjs +54 -5
  17. package/dist/{shared/parse-ast-index-BHaE0ECV.cjs → normalize-string-or-regex-CL-PJZI7.js} +70 -137
  18. package/dist/parallel-plugin-worker.mjs +26 -33
  19. package/dist/parallel-plugin.d.mts +7 -7
  20. package/dist/parse-ast-index.d.mts +5 -6
  21. package/dist/parse-ast-index.mjs +1 -2
  22. package/dist/plugins-index.browser.mjs +39 -0
  23. package/dist/plugins-index.d.mts +30 -0
  24. package/dist/plugins-index.mjs +39 -0
  25. package/dist/rolldown-binding.wasi-browser.js +41 -24
  26. package/dist/rolldown-binding.wasi.cjs +62 -24
  27. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  28. package/dist/rolldown-build-BntP6Bjl.js +5063 -0
  29. package/dist/shared/bindingify-input-options-CObJx_Uj.mjs +2236 -0
  30. package/dist/shared/composable-filters-CIxSuZSM.mjs +227 -0
  31. package/dist/shared/constructors-5bt5oBhE.d.mts +28 -0
  32. package/dist/shared/constructors-BTW-c3jX.mjs +61 -0
  33. package/dist/shared/define-config-C-sO_cLw.d.mts +3679 -0
  34. package/dist/shared/define-config-Dlptvz3X.mjs +7 -0
  35. package/dist/shared/{load-config-D7UduHRZ.mjs → load-config-hx3WBhLe.mjs} +23 -33
  36. package/dist/shared/logging-RB67zQ4N.d.mts +50 -0
  37. package/dist/shared/{parse-ast-index-vu376yZ1.mjs → logs-B2CASPcx.mjs} +21 -116
  38. package/dist/shared/normalize-string-or-regex-DIwprzLy.mjs +60 -0
  39. package/dist/shared/parse-ast-index-BQpfNG1v.mjs +98 -0
  40. package/dist/shared/{prompt-CxjDC0Gn.cjs → prompt-CYPmuhh-.mjs} +301 -308
  41. package/dist/shared/rolldown-D2E0YTeB.mjs +42 -0
  42. package/dist/shared/rolldown-build-Do6WlRGM.mjs +2371 -0
  43. package/dist/shared/types-CIhJMr1h.d.mts +1300 -0
  44. package/dist/shared/utils-CqMTwlsR.d.mts +22 -0
  45. package/dist/shared/watch-BsneBCNP.mjs +378 -0
  46. package/package.json +33 -38
  47. package/dist/cli.cjs +0 -1748
  48. package/dist/config.cjs +0 -12
  49. package/dist/config.d.cts +0 -11
  50. package/dist/experimental-index.cjs +0 -129
  51. package/dist/experimental-index.d.cts +0 -96
  52. package/dist/filter-index.cjs +0 -53
  53. package/dist/filter-index.d.cts +0 -3
  54. package/dist/index.cjs +0 -9
  55. package/dist/index.d.cts +0 -3
  56. package/dist/parallel-plugin-worker.cjs +0 -33
  57. package/dist/parallel-plugin-worker.d.cts +0 -1
  58. package/dist/parallel-plugin.cjs +0 -8
  59. package/dist/parallel-plugin.d.cts +0 -14
  60. package/dist/parse-ast-index.cjs +0 -4
  61. package/dist/parse-ast-index.d.cts +0 -9
  62. package/dist/shared/chunk-DDkG_k5U.cjs +0 -39
  63. package/dist/shared/chunk-DSsiIF1Z.mjs +0 -30
  64. package/dist/shared/define-config.d-D4lKXE9V.d.cts +0 -1165
  65. package/dist/shared/define-config.d-Dm9iNdt9.d.mts +0 -1165
  66. package/dist/shared/dist-BMVjvV-v.cjs +0 -249
  67. package/dist/shared/dist-CAn6dxW6.mjs +0 -153
  68. package/dist/shared/load-config-CtKjQ8Mn.cjs +0 -125
  69. package/dist/shared/prompt-GFYxfPw7.mjs +0 -854
  70. package/dist/shared/src-D0nc44MQ.mjs +0 -4691
  71. package/dist/shared/src-s89s870G.cjs +0 -4647
  72. package/dist/src-CeWghjQt.js +0 -4329
  73. /package/dist/{cli.d.cts → cli-setup.d.mts} +0 -0
package/dist/config.d.mts CHANGED
@@ -1,11 +1,9 @@
1
- import { ConfigExport, defineConfig$1 as defineConfig } from "./shared/define-config.d-Dm9iNdt9.mjs";
1
+ import { r as defineConfig, t as ConfigExport } from "./shared/define-config-C-sO_cLw.mjs";
2
2
 
3
3
  //#region src/utils/load-config.d.ts
4
4
  declare function loadConfig(configPath: string): Promise<ConfigExport>;
5
-
6
5
  //#endregion
7
6
  //#region src/config.d.ts
8
7
  declare const VERSION: string;
9
-
10
8
  //#endregion
11
9
  export { VERSION, defineConfig, loadConfig };
package/dist/config.mjs CHANGED
@@ -1,10 +1,12 @@
1
- import { defineConfig, version } from "./shared/src-D0nc44MQ.mjs";
2
- import "./shared/dist-CAn6dxW6.mjs";
3
- import "./shared/parse-ast-index-vu376yZ1.mjs";
4
- import { init_load_config, loadConfig } from "./shared/load-config-D7UduHRZ.mjs";
1
+ import "./shared/normalize-string-or-regex-DIwprzLy.mjs";
2
+ import { w as version } from "./shared/bindingify-input-options-CObJx_Uj.mjs";
3
+ import "./shared/rolldown-build-Do6WlRGM.mjs";
4
+ import "./shared/parse-ast-index-BQpfNG1v.mjs";
5
+ import "./shared/rolldown-D2E0YTeB.mjs";
6
+ import { t as defineConfig } from "./shared/define-config-Dlptvz3X.mjs";
7
+ import { t as loadConfig } from "./shared/load-config-hx3WBhLe.mjs";
5
8
 
6
9
  //#region src/config.ts
7
- init_load_config();
8
10
  const VERSION = version;
9
11
 
10
12
  //#endregion
@@ -0,0 +1,61 @@
1
+ import { a as makeBuiltinPluginCallable, n as BuiltinPlugin, t as normalizedStringOrRegex } from "./normalize-string-or-regex-CL-PJZI7.js";
2
+
3
+ //#region src/builtin-plugin/constructors.ts
4
+ function viteModulePreloadPolyfillPlugin(config) {
5
+ return new BuiltinPlugin("builtin:vite-module-preload-polyfill", config);
6
+ }
7
+ function viteDynamicImportVarsPlugin(config) {
8
+ if (config) {
9
+ config.include = normalizedStringOrRegex(config.include);
10
+ config.exclude = normalizedStringOrRegex(config.exclude);
11
+ }
12
+ return new BuiltinPlugin("builtin:vite-dynamic-import-vars", config);
13
+ }
14
+ function viteImportGlobPlugin(config) {
15
+ return new BuiltinPlugin("builtin:vite-import-glob", config);
16
+ }
17
+ function viteReporterPlugin(config) {
18
+ return new BuiltinPlugin("builtin:vite-reporter", config);
19
+ }
20
+ function viteWasmHelperPlugin(config) {
21
+ return new BuiltinPlugin("builtin:vite-wasm-helper", config);
22
+ }
23
+ function viteWasmFallbackPlugin() {
24
+ return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:vite-wasm-fallback"));
25
+ }
26
+ function viteLoadFallbackPlugin() {
27
+ return new BuiltinPlugin("builtin:vite-load-fallback");
28
+ }
29
+ function viteJsonPlugin(config) {
30
+ return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:vite-json", config));
31
+ }
32
+ function viteBuildImportAnalysisPlugin(config) {
33
+ return new BuiltinPlugin("builtin:vite-build-import-analysis", config);
34
+ }
35
+ function viteResolvePlugin(config) {
36
+ return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:vite-resolve", {
37
+ ...config,
38
+ yarnPnp: typeof process === "object" && !!process.versions?.pnp
39
+ }));
40
+ }
41
+ function isolatedDeclarationPlugin(config) {
42
+ return new BuiltinPlugin("builtin:isolated-declaration", config);
43
+ }
44
+ function viteWebWorkerPostPlugin() {
45
+ return new BuiltinPlugin("builtin:vite-web-worker-post");
46
+ }
47
+ function esmExternalRequirePlugin(config) {
48
+ const plugin = new BuiltinPlugin("builtin:esm-external-require", config);
49
+ plugin.enforce = "pre";
50
+ return plugin;
51
+ }
52
+ function viteReactRefreshWrapperPlugin(config) {
53
+ if (config) {
54
+ config.include = normalizedStringOrRegex(config.include);
55
+ config.exclude = normalizedStringOrRegex(config.exclude);
56
+ }
57
+ return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:vite-react-refresh-wrapper", config));
58
+ }
59
+
60
+ //#endregion
61
+ export { viteImportGlobPlugin as a, viteModulePreloadPolyfillPlugin as c, viteResolvePlugin as d, viteWasmFallbackPlugin as f, viteDynamicImportVarsPlugin as i, viteReactRefreshWrapperPlugin as l, viteWebWorkerPostPlugin as m, isolatedDeclarationPlugin as n, viteJsonPlugin as o, viteWasmHelperPlugin as p, viteBuildImportAnalysisPlugin as r, viteLoadFallbackPlugin as s, esmExternalRequirePlugin as t, viteReporterPlugin as u };
@@ -1,17 +1,185 @@
1
- import { BuiltinPlugin, assetPlugin, buildImportAnalysisPlugin, composeJsPlugins, createBundler, dynamicImportVarsPlugin, handleOutputErrors, importGlobPlugin, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, normalizedStringOrRegex, reporterPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin } from "./src-CeWghjQt.js";
2
- import { ResolverFactory, isolatedDeclaration, moduleRunnerTransform, transform } from "./rolldown-binding.wasi-browser.js";
1
+ import { n as BuiltinPlugin, t as normalizedStringOrRegex } from "./normalize-string-or-regex-CL-PJZI7.js";
2
+ import { a as unwrapBindingResult, c as transformToRollupOutput, i as normalizeBindingResult, l as validateOption, n as createBundlerOptions, o as parse, s as parseSync, t as RolldownBuild, u as PluginDriver } from "./rolldown-build-BntP6Bjl.js";
3
+ import { a as viteImportGlobPlugin, c as viteModulePreloadPolyfillPlugin, d as viteResolvePlugin, f as viteWasmFallbackPlugin, i as viteDynamicImportVarsPlugin, l as viteReactRefreshWrapperPlugin, m as viteWebWorkerPostPlugin, n as isolatedDeclarationPlugin, o as viteJsonPlugin, p as viteWasmHelperPlugin, r as viteBuildImportAnalysisPlugin, s as viteLoadFallbackPlugin, u as viteReporterPlugin } from "./constructors-B8gqcrFr.js";
4
+ import * as binding from "./rolldown-binding.wasi-browser.js";
5
+ import { BindingBundler, BindingDevEngine, BindingRebuildStrategy, BindingRebuildStrategy as BindingRebuildStrategy$1, ResolverFactory, createTokioRuntime, isolatedDeclaration, isolatedDeclarationSync, minify, minifySync, moduleRunnerTransform, shutdownAsyncRuntime, startAsyncRuntime, transform, transformSync } from "./rolldown-binding.wasi-browser.js";
3
6
 
7
+ //#region src/api/dev/dev-engine.ts
8
+ var DevEngine = class DevEngine {
9
+ #inner;
10
+ #cachedBuildFinishPromise = null;
11
+ static async create(inputOptions, outputOptions = {}, devOptions = {}) {
12
+ inputOptions = await PluginDriver.callOptionsHook(inputOptions);
13
+ const options = await createBundlerOptions(inputOptions, outputOptions, false);
14
+ const userOnHmrUpdates = devOptions.onHmrUpdates;
15
+ const bindingOnHmrUpdates = userOnHmrUpdates ? function(rawResult) {
16
+ const result = normalizeBindingResult(rawResult);
17
+ if (result instanceof Error) {
18
+ userOnHmrUpdates(result);
19
+ return;
20
+ }
21
+ const [updates, changedFiles] = result;
22
+ userOnHmrUpdates({
23
+ updates,
24
+ changedFiles
25
+ });
26
+ } : void 0;
27
+ const userOnOutput = devOptions.onOutput;
28
+ const bindingDevOptions = {
29
+ onHmrUpdates: bindingOnHmrUpdates,
30
+ onOutput: userOnOutput ? function(rawResult) {
31
+ const result = normalizeBindingResult(rawResult);
32
+ if (result instanceof Error) {
33
+ userOnOutput(result);
34
+ return;
35
+ }
36
+ userOnOutput(transformToRollupOutput(result));
37
+ } : void 0,
38
+ rebuildStrategy: devOptions.rebuildStrategy ? devOptions.rebuildStrategy === "always" ? BindingRebuildStrategy$1.Always : devOptions.rebuildStrategy === "auto" ? BindingRebuildStrategy$1.Auto : BindingRebuildStrategy$1.Never : void 0,
39
+ watch: devOptions.watch && {
40
+ skipWrite: devOptions.watch.skipWrite,
41
+ usePolling: devOptions.watch.usePolling,
42
+ pollInterval: devOptions.watch.pollInterval,
43
+ useDebounce: devOptions.watch.useDebounce,
44
+ debounceDuration: devOptions.watch.debounceDuration,
45
+ compareContentsForPolling: devOptions.watch.compareContentsForPolling,
46
+ debounceTickRate: devOptions.watch.debounceTickRate
47
+ }
48
+ };
49
+ return new DevEngine(new BindingDevEngine(options.bundlerOptions, bindingDevOptions));
50
+ }
51
+ constructor(inner) {
52
+ this.#inner = inner;
53
+ }
54
+ async run() {
55
+ await this.#inner.run();
56
+ }
57
+ async ensureCurrentBuildFinish() {
58
+ if (this.#cachedBuildFinishPromise) return this.#cachedBuildFinishPromise;
59
+ const promise = this.#inner.ensureCurrentBuildFinish().then(() => {
60
+ this.#cachedBuildFinishPromise = null;
61
+ });
62
+ this.#cachedBuildFinishPromise = promise;
63
+ return promise;
64
+ }
65
+ async getBundleState() {
66
+ return this.#inner.getBundleState();
67
+ }
68
+ async ensureLatestBuildOutput() {
69
+ await this.#inner.ensureLatestBuildOutput();
70
+ }
71
+ async invalidate(file, firstInvalidatedBy) {
72
+ return this.#inner.invalidate(file, firstInvalidatedBy);
73
+ }
74
+ async registerModules(clientId, modules) {
75
+ await this.#inner.registerModules(clientId, modules);
76
+ }
77
+ async removeClient(clientId) {
78
+ await this.#inner.removeClient(clientId);
79
+ }
80
+ async close() {
81
+ await this.#inner.close();
82
+ }
83
+ /**
84
+ * Compile a lazy entry module and return HMR-style patch code.
85
+ *
86
+ * This is called when a dynamically imported module is first requested at runtime.
87
+ * The module was previously stubbed with a proxy, and now we need to compile the
88
+ * actual module and its dependencies.
89
+ *
90
+ * @param moduleId - The absolute file path of the module to compile
91
+ * @param clientId - The client ID requesting this compilation
92
+ * @returns The compiled JavaScript code as a string (HMR patch format)
93
+ */
94
+ async compileEntry(moduleId, clientId) {
95
+ return this.#inner.compileEntry(moduleId, clientId);
96
+ }
97
+ };
98
+
99
+ //#endregion
100
+ //#region src/api/dev/index.ts
101
+ const dev = (...args) => DevEngine.create(...args);
102
+
103
+ //#endregion
104
+ //#region src/types/external-memory-handle.ts
105
+ const symbolForExternalMemoryHandle = "__rolldown_external_memory_handle__";
106
+ /**
107
+ * Frees the external memory held by the given handle.
108
+ *
109
+ * This is useful when you want to manually release memory held by Rust objects
110
+ * (like `OutputChunk` or `OutputAsset`) before they are garbage collected.
111
+ *
112
+ * @param handle - The object with external memory to free
113
+ * @param keepDataAlive - If true, evaluates all lazy fields before freeing memory (default: false).
114
+ * This will take time to copy data from Rust to JavaScript, but prevents errors
115
+ * when accessing properties after the memory is freed.
116
+ * @returns Status object with `freed` boolean and optional `reason` string.
117
+ * - `{ freed: true }` if memory was successfully freed
118
+ * - `{ freed: false, reason: "..." }` if memory couldn't be freed (e.g., already freed or other references exist)
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * import { freeExternalMemory } from 'rolldown/experimental';
123
+ *
124
+ * const output = await bundle.generate();
125
+ * const chunk = output.output[0];
126
+ *
127
+ * // Use the chunk...
128
+ *
129
+ * // Manually free the memory (fast, but accessing properties after will throw)
130
+ * const status = freeExternalMemory(chunk); // { freed: true }
131
+ * const statusAgain = freeExternalMemory(chunk); // { freed: false, reason: "Memory has already been freed" }
132
+ *
133
+ * // Keep data alive before freeing (slower, but data remains accessible)
134
+ * freeExternalMemory(chunk, true); // Evaluates all lazy fields first
135
+ * console.log(chunk.code); // OK - data was copied to JavaScript before freeing
136
+ *
137
+ * // Without keepDataAlive, accessing chunk properties after freeing will throw an error
138
+ * ```
139
+ */
140
+ function freeExternalMemory(handle, keepDataAlive = false) {
141
+ return handle[symbolForExternalMemoryHandle](keepDataAlive);
142
+ }
143
+
144
+ //#endregion
4
145
  //#region src/api/experimental.ts
5
146
  /**
6
- * This is an experimental API. It's behavior may change in the future.
147
+ * This is an experimental API. Its behavior may change in the future.
7
148
  *
8
- * Calling this API will only execute the scan stage of rolldown.
149
+ * - Calling this API will only execute the `scan/build` stage of rolldown.
150
+ * - `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.
151
+ *
152
+ * @example To ensure cleanup of resources, use the returned promise to wait for the scan to complete.
153
+ * ```ts
154
+ * import { scan } from 'rolldown/api/experimental';
155
+ *
156
+ * const cleanupPromise = await scan(...);
157
+ * await cleanupPromise;
158
+ * // Now all resources have been cleaned up.
159
+ * ```
9
160
  */
10
- const experimental_scan = async (input) => {
11
- const { bundler, stopWorkers } = await createBundler(input, {});
12
- const output = await bundler.scan();
13
- handleOutputErrors(output);
14
- await stopWorkers?.();
161
+ const scan = async (rawInputOptions, rawOutputOptions = {}) => {
162
+ validateOption("input", rawInputOptions);
163
+ validateOption("output", rawOutputOptions);
164
+ const ret = await createBundlerOptions(await PluginDriver.callOptionsHook(rawInputOptions), rawOutputOptions, false);
165
+ const bundler = new BindingBundler();
166
+ if (RolldownBuild.asyncRuntimeShutdown) startAsyncRuntime();
167
+ async function cleanup() {
168
+ await bundler.close();
169
+ await ret.stopWorkers?.();
170
+ shutdownAsyncRuntime();
171
+ RolldownBuild.asyncRuntimeShutdown = true;
172
+ }
173
+ let cleanupPromise = Promise.resolve();
174
+ try {
175
+ unwrapBindingResult(await bundler.scan(ret.bundlerOptions));
176
+ } catch (err) {
177
+ await cleanup();
178
+ throw err;
179
+ } finally {
180
+ cleanupPromise = cleanup();
181
+ }
182
+ return cleanupPromise;
15
183
  };
16
184
 
17
185
  //#endregion
@@ -22,55 +190,62 @@ function defineParallelPlugin(pluginPath) {
22
190
 
23
191
  //#endregion
24
192
  //#region src/builtin-plugin/alias-plugin.ts
25
- function aliasPlugin(config) {
26
- return new BuiltinPlugin("builtin:alias", config);
27
- }
28
-
29
- //#endregion
30
- //#region src/builtin-plugin/replace-plugin.ts
31
- /**
32
- * Replaces targeted strings in files while bundling.
33
- *
34
- * @example
35
- * // Basic usage
36
- * ```js
37
- * replacePlugin({
38
- * 'process.env.NODE_ENV': JSON.stringify('production'),
39
- * __buildDate__: () => JSON.stringify(new Date()),
40
- * __buildVersion: 15
41
- * })
42
- * ```
43
- * @example
44
- * // With options
45
- * ```js
46
- * replacePlugin({
47
- * 'process.env.NODE_ENV': JSON.stringify('production'),
48
- * __buildDate__: () => JSON.stringify(new Date()),
49
- * __buildVersion: 15
50
- * }, {
51
- * preventAssignment: false,
52
- * })
53
- * ```
54
- */
55
- function replacePlugin(values = {}, options = {}) {
56
- return new BuiltinPlugin("builtin:replace", {
57
- ...options,
58
- values
59
- });
193
+ function viteAliasPlugin(config) {
194
+ return new BuiltinPlugin("builtin:vite-alias", config);
60
195
  }
61
196
 
62
197
  //#endregion
63
198
  //#region src/builtin-plugin/transform-plugin.ts
64
- function transformPlugin(config) {
65
- if (config) config = {
199
+ function viteTransformPlugin(config) {
200
+ return new BuiltinPlugin("builtin:vite-transform", {
66
201
  ...config,
67
202
  include: normalizedStringOrRegex(config.include),
68
203
  exclude: normalizedStringOrRegex(config.exclude),
69
204
  jsxRefreshInclude: normalizedStringOrRegex(config.jsxRefreshInclude),
70
- jsxRefreshExclude: normalizedStringOrRegex(config.jsxRefreshExclude)
71
- };
72
- return new BuiltinPlugin("builtin:transform", config);
205
+ jsxRefreshExclude: normalizedStringOrRegex(config.jsxRefreshExclude),
206
+ yarnPnp: typeof process === "object" && !!process.versions?.pnp
207
+ });
208
+ }
209
+
210
+ //#endregion
211
+ //#region src/builtin-plugin/vite-manifest-plugin.ts
212
+ function viteManifestPlugin(config) {
213
+ return new BuiltinPlugin("builtin:vite-manifest", config);
73
214
  }
74
215
 
75
216
  //#endregion
76
- export { ResolverFactory, aliasPlugin, assetPlugin, buildImportAnalysisPlugin, composeJsPlugins as composePlugins, defineParallelPlugin, dynamicImportVarsPlugin, importGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, moduleRunnerTransform, replacePlugin, reporterPlugin, experimental_scan as scan, transform, transformPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin };
217
+ //#region src/experimental-index.ts
218
+ /**
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
+ */
245
+ const memfs = {
246
+ fs: binding.__fs,
247
+ volume: binding.__volume
248
+ };
249
+
250
+ //#endregion
251
+ export { BindingRebuildStrategy, DevEngine, ResolverFactory, createTokioRuntime, defineParallelPlugin, dev, viteDynamicImportVarsPlugin as dynamicImportVarsPlugin, viteDynamicImportVarsPlugin, freeExternalMemory, viteImportGlobPlugin as importGlobPlugin, viteImportGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, isolatedDeclarationSync, memfs, minify, minifySync, moduleRunnerTransform, parse, parseSync, scan, transform, transformSync, viteAliasPlugin, viteBuildImportAnalysisPlugin, viteJsonPlugin, viteLoadFallbackPlugin, viteManifestPlugin, viteModulePreloadPolyfillPlugin, viteReactRefreshWrapperPlugin, viteReporterPlugin, viteResolvePlugin, viteTransformPlugin, viteWasmFallbackPlugin, viteWasmHelperPlugin, viteWebWorkerPostPlugin };
@@ -1,96 +1,184 @@
1
- import { BuiltinPlugin$1 as BuiltinPlugin, InputOptions, RolldownPlugin, assetPlugin$1 as assetPlugin, buildImportAnalysisPlugin$1 as buildImportAnalysisPlugin, defineParallelPlugin, dynamicImportVarsPlugin$1 as dynamicImportVarsPlugin, importGlobPlugin$1 as importGlobPlugin, isolatedDeclarationPlugin$1 as isolatedDeclarationPlugin, jsonPlugin$1 as jsonPlugin, loadFallbackPlugin$1 as loadFallbackPlugin, manifestPlugin$1 as manifestPlugin, moduleFederationPlugin$1 as moduleFederationPlugin, modulePreloadPolyfillPlugin$1 as modulePreloadPolyfillPlugin, reporterPlugin$1 as reporterPlugin, viteResolvePlugin$1 as viteResolvePlugin, wasmFallbackPlugin$1 as wasmFallbackPlugin, wasmHelperPlugin$1 as wasmHelperPlugin, webWorkerPostPlugin$1 as webWorkerPostPlugin } from "./shared/define-config.d-Dm9iNdt9.mjs";
2
- import { BindingReplacePluginConfig, BindingTransformPluginConfig, IsolatedDeclarationsOptions, IsolatedDeclarationsResult, NapiResolveOptions as ResolveOptions, ResolveResult, ResolverFactory, TransformOptions, TransformResult, isolatedDeclaration, moduleRunnerTransform, transform } from "./rolldown-binding.wasi.cjs";
1
+ import { Ct as NormalizedOutputOptions, Zt as OutputOptions, an as freeExternalMemory, c as InputOptions, ft as defineParallelPlugin, rn as RolldownOutput } from "./shared/define-config-C-sO_cLw.mjs";
2
+ import { t as BuiltinPlugin } from "./shared/utils-CqMTwlsR.mjs";
3
+ import { a as viteImportGlobPlugin, c as viteModulePreloadPolyfillPlugin, d as viteResolvePlugin, f as viteWasmFallbackPlugin, i as viteDynamicImportVarsPlugin, l as viteReactRefreshWrapperPlugin, m as viteWebWorkerPostPlugin, n as isolatedDeclarationPlugin, o as viteJsonPlugin, p as viteWasmHelperPlugin, r as viteBuildImportAnalysisPlugin, s as viteLoadFallbackPlugin, u as viteReporterPlugin } from "./shared/constructors-5bt5oBhE.mjs";
4
+ import { BindingViteManifestPluginConfig, BindingViteTransformPluginConfig, ParseResult as ParseResult$1, ParserOptions as ParserOptions$1 } from "../binding.cjs";
5
+ import { BindingBundleState, BindingClientHmrUpdate as BindingClientHmrUpdate$1 } from "../../binding.cjs";
6
+ import { BindingClientHmrUpdate, BindingRebuildStrategy, IsolatedDeclarationsOptions, IsolatedDeclarationsResult, MinifyOptions, MinifyResult, NapiResolveOptions as ResolveOptions, ParseResult, ParserOptions, ResolveResult, ResolverFactory, TransformOptions, TransformResult, createTokioRuntime, isolatedDeclaration, isolatedDeclarationSync, minify, minifySync, moduleRunnerTransform, transform, transformSync } from "./binding.cjs";
3
7
 
8
+ //#region src/api/dev/dev-options.d.ts
9
+ type DevOnHmrUpdates = (result: Error | {
10
+ updates: BindingClientHmrUpdate$1[];
11
+ changedFiles: string[];
12
+ }) => void | Promise<void>;
13
+ type DevOnOutput = (result: Error | RolldownOutput) => void | Promise<void>;
14
+ interface DevWatchOptions {
15
+ /**
16
+ * If `true`, files are not written to disk.
17
+ * @default false
18
+ */
19
+ skipWrite?: boolean;
20
+ /**
21
+ * If `true`, use polling instead of native file system events for watching.
22
+ * @default false
23
+ */
24
+ usePolling?: boolean;
25
+ /**
26
+ * Poll interval in milliseconds (only used when usePolling is true).
27
+ * @default 100
28
+ */
29
+ pollInterval?: number;
30
+ /**
31
+ * If `true`, use debounced watcher. If `false`, use non-debounced watcher for immediate responses.
32
+ * @default true
33
+ */
34
+ useDebounce?: boolean;
35
+ /**
36
+ * Debounce duration in milliseconds (only used when useDebounce is true).
37
+ * @default 10
38
+ */
39
+ debounceDuration?: number;
40
+ /**
41
+ * Whether to compare file contents for poll-based watchers (only used when usePolling is true).
42
+ * When enabled, poll watchers will check file contents to determine if they actually changed.
43
+ * @default false
44
+ */
45
+ compareContentsForPolling?: boolean;
46
+ /**
47
+ * Tick rate in milliseconds for debounced watchers (only used when useDebounce is true).
48
+ * Controls how frequently the debouncer checks for events to process.
49
+ * When not specified, the debouncer will auto-select an appropriate tick rate (1/4 of the debounce duration).
50
+ * @default undefined (auto-select)
51
+ */
52
+ debounceTickRate?: number;
53
+ }
54
+ interface DevOptions {
55
+ onHmrUpdates?: DevOnHmrUpdates;
56
+ onOutput?: DevOnOutput;
57
+ /**
58
+ * Strategy for triggering rebuilds after HMR updates.
59
+ * - `'always'`: Always trigger a rebuild after HMR updates
60
+ * - `'auto'`: Trigger rebuild only if HMR updates contain full reload updates
61
+ * - `'never'`: Never trigger rebuild after HMR updates (default)
62
+ * @default 'auto'
63
+ */
64
+ rebuildStrategy?: "always" | "auto" | "never";
65
+ watch?: DevWatchOptions;
66
+ }
67
+ //#endregion
68
+ //#region src/api/dev/dev-engine.d.ts
69
+ declare class DevEngine {
70
+ #private;
71
+ static create(inputOptions: InputOptions, outputOptions?: OutputOptions, devOptions?: DevOptions): Promise<DevEngine>;
72
+ private constructor();
73
+ run(): Promise<void>;
74
+ ensureCurrentBuildFinish(): Promise<void>;
75
+ getBundleState(): Promise<BindingBundleState>;
76
+ ensureLatestBuildOutput(): Promise<void>;
77
+ invalidate(file: string, firstInvalidatedBy?: string): Promise<BindingClientHmrUpdate$1[]>;
78
+ registerModules(clientId: string, modules: string[]): Promise<void>;
79
+ removeClient(clientId: string): Promise<void>;
80
+ close(): Promise<void>;
81
+ /**
82
+ * Compile a lazy entry module and return HMR-style patch code.
83
+ *
84
+ * This is called when a dynamically imported module is first requested at runtime.
85
+ * The module was previously stubbed with a proxy, and now we need to compile the
86
+ * actual module and its dependencies.
87
+ *
88
+ * @param moduleId - The absolute file path of the module to compile
89
+ * @param clientId - The client ID requesting this compilation
90
+ * @returns The compiled JavaScript code as a string (HMR patch format)
91
+ */
92
+ compileEntry(moduleId: string, clientId: string): Promise<string>;
93
+ }
94
+ //#endregion
95
+ //#region src/api/dev/index.d.ts
96
+ declare const dev: typeof DevEngine.create;
97
+ //#endregion
4
98
  //#region src/api/experimental.d.ts
5
99
  /**
6
- * This is an experimental API. It's behavior may change in the future.
100
+ * This is an experimental API. Its behavior may change in the future.
101
+ *
102
+ * - Calling this API will only execute the `scan/build` stage of rolldown.
103
+ * - `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.
104
+ *
105
+ * @example To ensure cleanup of resources, use the returned promise to wait for the scan to complete.
106
+ * ```ts
107
+ * import { scan } from 'rolldown/api/experimental';
7
108
  *
8
- * Calling this API will only execute the scan stage of rolldown.
109
+ * const cleanupPromise = await scan(...);
110
+ * await cleanupPromise;
111
+ * // Now all resources have been cleaned up.
112
+ * ```
9
113
  */
114
+ declare const scan: (rawInputOptions: InputOptions, rawOutputOptions?: {}) => Promise<Promise<void>>;
115
+ //#endregion
116
+ //#region src/utils/parse.d.ts
10
117
  /**
11
- * This is an experimental API. It's behavior may change in the future.
118
+ * Parse asynchronously.
12
119
  *
13
- * Calling this API will only execute the scan stage of rolldown.
120
+ * Note: This function can be slower than `parseSync` due to the overhead of spawning a thread.
14
121
  */
15
- declare const experimental_scan: (input: InputOptions) => Promise<void>;
16
-
17
- //#endregion
18
- //#region src/utils/compose-js-plugins.d.ts
19
- declare function composeJsPlugins(plugins: RolldownPlugin[]): RolldownPlugin[];
20
-
122
+ declare function parse(filename: string, sourceText: string, options?: ParserOptions$1 | null): Promise<ParseResult$1>;
123
+ /** Parse synchronously. */
124
+ declare function parseSync(filename: string, sourceText: string, options?: ParserOptions$1 | null): ParseResult$1;
21
125
  //#endregion
22
126
  //#region src/builtin-plugin/alias-plugin.d.ts
23
- type AliasPluginAlias = {
24
- find: string | RegExp
25
- replacement: string
127
+ type ViteAliasPluginConfig = {
128
+ entries: {
129
+ find: string | RegExp;
130
+ replacement: string;
131
+ }[];
26
132
  };
27
- type AliasPluginConfig = {
28
- entries: AliasPluginAlias[]
133
+ declare function viteAliasPlugin(config: ViteAliasPluginConfig): BuiltinPlugin;
134
+ //#endregion
135
+ //#region src/builtin-plugin/transform-plugin.d.ts
136
+ type TransformPattern = string | RegExp | readonly (RegExp | string)[];
137
+ type TransformPluginConfig = Omit<BindingViteTransformPluginConfig, "include" | "exclude" | "jsxRefreshInclude" | "jsxRefreshExclude" | "yarnPnp"> & {
138
+ include?: TransformPattern;
139
+ exclude?: TransformPattern;
140
+ jsxRefreshInclude?: TransformPattern;
141
+ jsxRefreshExclude?: TransformPattern;
29
142
  };
30
- declare function aliasPlugin(config: AliasPluginConfig): BuiltinPlugin;
31
-
143
+ declare function viteTransformPlugin(config: TransformPluginConfig): BuiltinPlugin;
32
144
  //#endregion
33
- //#region src/builtin-plugin/replace-plugin.d.ts
145
+ //#region src/builtin-plugin/vite-manifest-plugin.d.ts
146
+ type ViteManifestPluginConfig = Omit<BindingViteManifestPluginConfig, "isLegacy"> & {
147
+ isOutputOptionsForLegacyChunks?: (outputOptions: NormalizedOutputOptions) => boolean;
148
+ };
149
+ declare function viteManifestPlugin(config: ViteManifestPluginConfig): BuiltinPlugin;
150
+ //#endregion
151
+ //#region src/experimental-index.d.ts
34
152
  /**
35
- * Replaces targeted strings in files while bundling.
153
+ * In-memory file system for browser builds.
36
154
  *
37
- * @example
38
- * // Basic usage
39
- * ```js
40
- * replacePlugin({
41
- * 'process.env.NODE_ENV': JSON.stringify('production'),
42
- * __buildDate__: () => JSON.stringify(new Date()),
43
- * __buildVersion: 15
44
- * })
45
- * ```
46
- * @example
47
- * // With options
48
- * ```js
49
- * replacePlugin({
50
- * 'process.env.NODE_ENV': JSON.stringify('production'),
51
- * __buildDate__: () => JSON.stringify(new Date()),
52
- * __buildVersion: 15
53
- * }, {
54
- * preventAssignment: false,
55
- * })
56
- * ```
57
- */
58
- /**
59
- * Replaces targeted strings in files while bundling.
155
+ * This is a re-export of the {@link https://github.com/streamich/memfs | memfs} package used by the WASI runtime.
156
+ * It allows you to read and write files to a virtual filesystem when using rolldown in browser environments.
157
+ *
158
+ * - `fs`: A Node.js-compatible filesystem API (`IFs` from memfs)
159
+ * - `volume`: The underlying `Volume` instance that stores the filesystem state
160
+ *
161
+ * Returns `undefined` in Node.js builds (only available in browser builds via `@rolldown/browser`).
60
162
  *
61
163
  * @example
62
- * // Basic usage
63
- * ```js
64
- * replacePlugin({
65
- * 'process.env.NODE_ENV': JSON.stringify('production'),
66
- * __buildDate__: () => JSON.stringify(new Date()),
67
- * __buildVersion: 15
68
- * })
69
- * ```
70
- * @example
71
- * // With options
72
- * ```js
73
- * replacePlugin({
74
- * 'process.env.NODE_ENV': JSON.stringify('production'),
75
- * __buildDate__: () => JSON.stringify(new Date()),
76
- * __buildVersion: 15
77
- * }, {
78
- * preventAssignment: false,
79
- * })
164
+ * ```typescript
165
+ * import { memfs } from 'rolldown/experimental';
166
+ *
167
+ * // Write files to virtual filesystem before bundling
168
+ * memfs?.volume.fromJSON({
169
+ * '/src/index.js': 'export const foo = 42;',
170
+ * '/package.json': '{"name": "my-app"}'
171
+ * });
172
+ *
173
+ * // Read files from the virtual filesystem
174
+ * const content = memfs?.fs.readFileSync('/src/index.js', 'utf8');
80
175
  * ```
176
+ *
177
+ * @see {@link https://github.com/streamich/memfs} for more information on the memfs API.
81
178
  */
82
- declare function replacePlugin(values?: BindingReplacePluginConfig["values"], options?: Omit<BindingReplacePluginConfig, "values">): BuiltinPlugin;
83
-
84
- //#endregion
85
- //#region src/builtin-plugin/transform-plugin.d.ts
86
- type TransformPattern = string | RegExp | readonly (RegExp | string)[];
87
- type TransformPluginConfig = Omit<BindingTransformPluginConfig, "include" | "exclude" | "jsxRefreshInclude" | "jsxRefreshExclude"> & {
88
- include?: TransformPattern
89
- exclude?: TransformPattern
90
- jsxRefreshInclude?: TransformPattern
91
- jsxRefreshExclude?: TransformPattern
92
- };
93
- declare function transformPlugin(config?: TransformPluginConfig): BuiltinPlugin;
94
-
179
+ declare const memfs: {
180
+ fs: any;
181
+ volume: any;
182
+ } | undefined;
95
183
  //#endregion
96
- export { IsolatedDeclarationsOptions, IsolatedDeclarationsResult, ResolveOptions, ResolveResult, ResolverFactory, TransformOptions, TransformResult, aliasPlugin, assetPlugin, buildImportAnalysisPlugin, composeJsPlugins as composePlugins, defineParallelPlugin, dynamicImportVarsPlugin, importGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, moduleRunnerTransform, replacePlugin, reporterPlugin, experimental_scan as scan, transform, transformPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin };
184
+ export { type BindingClientHmrUpdate, BindingRebuildStrategy, DevEngine, type DevOptions, type DevWatchOptions, type IsolatedDeclarationsOptions, type IsolatedDeclarationsResult, type MinifyOptions, type MinifyResult, type ParseResult, type ParserOptions, type ResolveOptions, type ResolveResult, ResolverFactory, type TransformOptions, type TransformResult, createTokioRuntime, defineParallelPlugin, dev, viteDynamicImportVarsPlugin as dynamicImportVarsPlugin, viteDynamicImportVarsPlugin, freeExternalMemory, viteImportGlobPlugin as importGlobPlugin, viteImportGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, isolatedDeclarationSync, memfs, minify, minifySync, moduleRunnerTransform, parse, parseSync, scan, transform, transformSync, viteAliasPlugin, viteBuildImportAnalysisPlugin, viteJsonPlugin, viteLoadFallbackPlugin, viteManifestPlugin, viteModulePreloadPolyfillPlugin, viteReactRefreshWrapperPlugin, viteReporterPlugin, viteResolvePlugin, viteTransformPlugin, viteWasmFallbackPlugin, viteWasmHelperPlugin, viteWebWorkerPostPlugin };