@rolldown/browser 1.0.0-beta.47 → 1.0.0-beta.48

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 (37) hide show
  1. package/dist/cli.mjs +22 -9
  2. package/dist/config.d.mts +3 -2
  3. package/dist/config.mjs +6 -4
  4. package/dist/constructors-EhfoQfqh.js +68 -0
  5. package/dist/experimental-index.browser.mjs +36 -106
  6. package/dist/experimental-index.d.mts +18 -58
  7. package/dist/experimental-index.mjs +39 -108
  8. package/dist/filter-index.d.mts +3 -2
  9. package/dist/filter-index.mjs +1 -1
  10. package/dist/index.browser.mjs +2 -1
  11. package/dist/index.d.mts +3 -2
  12. package/dist/index.mjs +5 -3
  13. package/dist/{shared/parse-ast-index-BiBzSGZe.mjs → normalize-string-or-regex-d47jXr3r.js} +38 -109
  14. package/dist/parallel-plugin-worker.mjs +5 -3
  15. package/dist/parallel-plugin.d.mts +3 -2
  16. package/dist/parse-ast-index.d.mts +1 -1
  17. package/dist/parse-ast-index.mjs +2 -1
  18. package/dist/plugins-index.browser.mjs +39 -0
  19. package/dist/plugins-index.d.mts +31 -0
  20. package/dist/plugins-index.mjs +40 -0
  21. package/dist/rolldown-binding.wasi-browser.js +1 -1
  22. package/dist/rolldown-binding.wasi.cjs +1 -1
  23. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  24. package/dist/shared/{binding-CRSqCQIK.d.mts → binding-B4uTNiw2.d.mts} +19 -49
  25. package/dist/shared/constructors-CaN9lKj2.d.mts +32 -0
  26. package/dist/shared/constructors-DcEzB0nc.mjs +68 -0
  27. package/dist/shared/{define-config-pfDd6Le4.d.mts → define-config-Dv3i4cxM.d.mts} +4 -62
  28. package/dist/shared/{load-config-D508WsWM.mjs → load-config-B-QIvCpC.mjs} +1 -1
  29. package/dist/shared/logs-CPsamAuj.mjs +181 -0
  30. package/dist/shared/normalize-string-or-regex-CbDij6KB.mjs +46 -0
  31. package/dist/shared/parse-ast-index-D9jH_38U.mjs +81 -0
  32. package/dist/shared/{prompt-BDwA3jSr.mjs → prompt-Ckjl2FdJ.mjs} +1 -1
  33. package/dist/shared/{src-DE7RBSfl.mjs → src-CvsuRKGv.mjs} +218 -191
  34. package/dist/shared/utils-CduIqa7h.d.mts +18 -0
  35. package/dist/{src-Deywlnh0.js → src-DLQqj5Wo.js} +203 -405
  36. package/package.json +1 -1
  37. /package/dist/shared/{composable-filters-D_PY7Qa7.mjs → composable-filters-CBpK2Fbc.mjs} +0 -0
package/dist/cli.mjs CHANGED
@@ -1,9 +1,11 @@
1
- import { C as version, S as description, _ as getOutputCliKeys, g as getInputCliKeys, h as getCliSchemaInfo, i as watch, o as rolldown, v as validateCliOptions, w as onExit } from "./shared/src-DE7RBSfl.mjs";
2
- import { h as styleText$1 } from "./shared/parse-ast-index-BiBzSGZe.mjs";
3
- import { d as arraify } from "./shared/composable-filters-D_PY7Qa7.mjs";
4
- import { t as loadConfig } from "./shared/load-config-D508WsWM.mjs";
5
- import { formatWithOptions, parseArgs } from "node:util";
1
+ import { C as version, S as description, _ as getOutputCliKeys, b as styleText$1, g as getInputCliKeys, h as getCliSchemaInfo, i as watch, o as rolldown, v as validateCliOptions, w as onExit } from "./shared/src-CvsuRKGv.mjs";
2
+ import "./shared/logs-CPsamAuj.mjs";
3
+ import "./shared/normalize-string-or-regex-CbDij6KB.mjs";
4
+ import { d as arraify } from "./shared/composable-filters-CBpK2Fbc.mjs";
5
+ import "./shared/parse-ast-index-D9jH_38U.mjs";
6
+ import { t as loadConfig } from "./shared/load-config-B-QIvCpC.mjs";
6
7
  import path, { sep } from "node:path";
8
+ import { formatWithOptions, parseArgs } from "node:util";
7
9
  import process$1 from "node:process";
8
10
  import * as tty from "node:tty";
9
11
  import { performance } from "node:perf_hooks";
@@ -946,7 +948,7 @@ function createConsola(options$1 = {}) {
946
948
  defaults: { level },
947
949
  stdout: process.stdout,
948
950
  stderr: process.stderr,
949
- prompt: (...args) => import("./shared/prompt-BDwA3jSr.mjs").then((m) => m.prompt(...args)),
951
+ prompt: (...args) => import("./shared/prompt-Ckjl2FdJ.mjs").then((m) => m.prompt(...args)),
950
952
  reporters: options$1.reporters || [options$1.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()],
951
953
  ...options$1
952
954
  });
@@ -1053,7 +1055,18 @@ function kebabCaseToCamelCase(str) {
1053
1055
  //#endregion
1054
1056
  //#region src/cli/arguments/normalize.ts
1055
1057
  function normalizeCliOptions(cliOptions, positionals) {
1056
- const [data, errors] = validateCliOptions(cliOptions);
1058
+ const prototypePollutionKeys = [
1059
+ "__proto__",
1060
+ "constructor",
1061
+ "prototype"
1062
+ ];
1063
+ const unflattenedCliOptions = {};
1064
+ for (let [key, value] of Object.entries(cliOptions)) if (prototypePollutionKeys.includes(key)) {} else if (key.includes(".")) {
1065
+ const [parentKey] = key.split(".");
1066
+ unflattenedCliOptions[parentKey] ??= {};
1067
+ setNestedProperty(unflattenedCliOptions, key, value);
1068
+ } else unflattenedCliOptions[key] = value;
1069
+ const [data, errors] = validateCliOptions(unflattenedCliOptions);
1057
1070
  if (errors?.length) {
1058
1071
  errors.forEach((error) => {
1059
1072
  logger.error(`${error}. You can use \`rolldown -h\` to see the help.`);
@@ -1377,8 +1390,8 @@ async function bundleInner(config, cliOptions) {
1377
1390
  ...config$1,
1378
1391
  ...cliOptions.input
1379
1392
  });
1380
- for (const output of outputList) try {
1381
- result.push(await build.write({
1393
+ try {
1394
+ for (const output of outputList) result.push(await build.write({
1382
1395
  ...output,
1383
1396
  ...cliOptions.output
1384
1397
  }));
package/dist/config.d.mts CHANGED
@@ -1,5 +1,6 @@
1
- import { n as ConfigExport, t as defineConfig } from "./shared/define-config-pfDd6Le4.mjs";
2
- import "./shared/binding-CRSqCQIK.mjs";
1
+ import { n as ConfigExport, t as defineConfig } from "./shared/define-config-Dv3i4cxM.mjs";
2
+ import "./shared/binding-B4uTNiw2.mjs";
3
+ import "./shared/utils-CduIqa7h.mjs";
3
4
 
4
5
  //#region src/utils/load-config.d.ts
5
6
  declare function loadConfig(configPath: string): Promise<ConfigExport>;
package/dist/config.mjs CHANGED
@@ -1,7 +1,9 @@
1
- import { C as version, r as defineConfig } from "./shared/src-DE7RBSfl.mjs";
2
- import "./shared/parse-ast-index-BiBzSGZe.mjs";
3
- import "./shared/composable-filters-D_PY7Qa7.mjs";
4
- import { t as loadConfig } from "./shared/load-config-D508WsWM.mjs";
1
+ import { C as version, r as defineConfig } from "./shared/src-CvsuRKGv.mjs";
2
+ import "./shared/logs-CPsamAuj.mjs";
3
+ import "./shared/normalize-string-or-regex-CbDij6KB.mjs";
4
+ import "./shared/composable-filters-CBpK2Fbc.mjs";
5
+ import "./shared/parse-ast-index-D9jH_38U.mjs";
6
+ import { t as loadConfig } from "./shared/load-config-B-QIvCpC.mjs";
5
7
 
6
8
  //#region src/config.ts
7
9
  const VERSION = version;
@@ -0,0 +1,68 @@
1
+ import { i as makeBuiltinPluginCallable, n as BuiltinPlugin, t as normalizedStringOrRegex } from "./normalize-string-or-regex-d47jXr3r.js";
2
+
3
+ //#region src/builtin-plugin/constructors.ts
4
+ function modulePreloadPolyfillPlugin(config) {
5
+ return new BuiltinPlugin("builtin:module-preload-polyfill", config);
6
+ }
7
+ function dynamicImportVarsPlugin(config) {
8
+ if (config) {
9
+ config.include = normalizedStringOrRegex(config.include);
10
+ config.exclude = normalizedStringOrRegex(config.exclude);
11
+ }
12
+ return new BuiltinPlugin("builtin:dynamic-import-vars", config);
13
+ }
14
+ function importGlobPlugin(config) {
15
+ return new BuiltinPlugin("builtin:import-glob", config);
16
+ }
17
+ function reporterPlugin(config) {
18
+ return new BuiltinPlugin("builtin:reporter", config);
19
+ }
20
+ function manifestPlugin(config) {
21
+ return new BuiltinPlugin("builtin:manifest", config);
22
+ }
23
+ function wasmHelperPlugin(config) {
24
+ return new BuiltinPlugin("builtin:wasm-helper", config);
25
+ }
26
+ function wasmFallbackPlugin() {
27
+ return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:wasm-fallback"));
28
+ }
29
+ function loadFallbackPlugin() {
30
+ return new BuiltinPlugin("builtin:load-fallback");
31
+ }
32
+ function jsonPlugin(config) {
33
+ return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:json", config));
34
+ }
35
+ function buildImportAnalysisPlugin(config) {
36
+ return new BuiltinPlugin("builtin:build-import-analysis", config);
37
+ }
38
+ function viteResolvePlugin(config) {
39
+ return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:vite-resolve", config));
40
+ }
41
+ function isolatedDeclarationPlugin(config) {
42
+ return new BuiltinPlugin("builtin:isolated-declaration", config);
43
+ }
44
+ function webWorkerPostPlugin() {
45
+ return new BuiltinPlugin("builtin:web-worker-post");
46
+ }
47
+ function esmExternalRequirePlugin(config) {
48
+ return new BuiltinPlugin("builtin:esm-external-require", config);
49
+ }
50
+ function reactRefreshWrapperPlugin(config) {
51
+ if (config) {
52
+ config.include = normalizedStringOrRegex(config.include);
53
+ config.exclude = normalizedStringOrRegex(config.exclude);
54
+ }
55
+ return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:react-refresh-wrapper", config));
56
+ }
57
+ function viteCSSPostPlugin(config) {
58
+ return new BuiltinPlugin("builtin:vite-css-post", config);
59
+ }
60
+ function viteHtmlPlugin(config) {
61
+ return new BuiltinPlugin("builtin:vite-html", config);
62
+ }
63
+ function htmlInlineProxyPlugin() {
64
+ return new BuiltinPlugin("builtin:html-inline-proxy");
65
+ }
66
+
67
+ //#endregion
68
+ export { wasmHelperPlugin as _, importGlobPlugin as a, loadFallbackPlugin as c, reactRefreshWrapperPlugin as d, reporterPlugin as f, wasmFallbackPlugin as g, viteResolvePlugin as h, htmlInlineProxyPlugin as i, manifestPlugin as l, viteHtmlPlugin as m, dynamicImportVarsPlugin as n, isolatedDeclarationPlugin as o, viteCSSPostPlugin as p, esmExternalRequirePlugin as r, jsonPlugin as s, buildImportAnalysisPlugin as t, modulePreloadPolyfillPlugin as u, webWorkerPostPlugin as v };
@@ -1,5 +1,7 @@
1
- import { c as createBundlerOptions, d as transformToRollupOutput, f as bindingifySourcemap, h as makeBuiltinPluginCallable, l as normalizedStringOrRegex, m as BuiltinPlugin, p as PluginDriver, s as RolldownBuild, u as normalizeBindingResult } from "./src-Deywlnh0.js";
2
- import { BindingDevEngine, BindingRebuildStrategy, BindingRebuildStrategy as BindingRebuildStrategy$1, ResolverFactory, isolatedDeclaration, minify, moduleRunnerTransform, transform } from "./rolldown-binding.wasi-browser.js";
1
+ import { c as createBundlerOptions, d as transformToRollupOutput, f as bindingifySourcemap, l as normalizeBindingResult, m as PluginDriver, p as validateOption, s as RolldownBuild, u as unwrapBindingResult } from "./src-DLQqj5Wo.js";
2
+ import { n as BuiltinPlugin, t as normalizedStringOrRegex } from "./normalize-string-or-regex-d47jXr3r.js";
3
+ import { _ as wasmHelperPlugin, a as importGlobPlugin, c as loadFallbackPlugin, d as reactRefreshWrapperPlugin, f as reporterPlugin, g as wasmFallbackPlugin, h as viteResolvePlugin, i as htmlInlineProxyPlugin, l as manifestPlugin, m as viteHtmlPlugin, n as dynamicImportVarsPlugin, o as isolatedDeclarationPlugin, p as viteCSSPostPlugin, s as jsonPlugin, t as buildImportAnalysisPlugin, u as modulePreloadPolyfillPlugin, v as webWorkerPostPlugin } from "./constructors-EhfoQfqh.js";
4
+ import { BindingBundler, BindingDevEngine, BindingRebuildStrategy, BindingRebuildStrategy as BindingRebuildStrategy$1, ResolverFactory, isolatedDeclaration, minify, moduleRunnerTransform, parseAsync, parseSync, shutdownAsyncRuntime, startAsyncRuntime, transform } from "./rolldown-binding.wasi-browser.js";
3
5
 
4
6
  //#region src/api/dev/dev-engine.ts
5
7
  var DevEngine = class DevEngine {
@@ -127,17 +129,42 @@ function freeExternalMemory(handle, keepDataAlive = false) {
127
129
  //#endregion
128
130
  //#region src/api/experimental.ts
129
131
  /**
130
- * This is an experimental API. It's behavior may change in the future.
132
+ * This is an experimental API. Its behavior may change in the future.
131
133
  *
132
- * Calling this API will only execute the scan stage of rolldown.
134
+ * - Calling this API will only execute the `scan/build` stage of rolldown.
135
+ * - `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.
136
+ *
137
+ * @example To ensure cleanup of resources, use the returned promise to wait for the scan to complete.
138
+ * ```ts
139
+ * import { scan } from 'rolldown/api/experimental';
140
+ *
141
+ * const cleanupPromise = await scan(...);
142
+ * await cleanupPromise;
143
+ * // Now all resources have been cleaned up.
144
+ * ```
133
145
  */
134
- const scan = async (input) => {
135
- const build = new RolldownBuild(await PluginDriver.callOptionsHook(input));
146
+ const scan = async (rawInputOptions, rawOutputOptions = {}) => {
147
+ validateOption("input", rawInputOptions);
148
+ validateOption("output", rawOutputOptions);
149
+ const ret = await createBundlerOptions(await PluginDriver.callOptionsHook(rawInputOptions), rawOutputOptions, false);
150
+ const bundler = new BindingBundler();
151
+ if (RolldownBuild.asyncRuntimeShutdown) startAsyncRuntime();
152
+ async function cleanup() {
153
+ await bundler.close();
154
+ await ret.stopWorkers?.();
155
+ shutdownAsyncRuntime();
156
+ RolldownBuild.asyncRuntimeShutdown = true;
157
+ }
158
+ let cleanupPromise = Promise.resolve();
136
159
  try {
137
- await build.scan();
160
+ unwrapBindingResult(await bundler.scan(ret.bundlerOptions));
161
+ } catch (err) {
162
+ await cleanup();
163
+ throw err;
138
164
  } finally {
139
- await build.close();
165
+ cleanupPromise = cleanup();
140
166
  }
167
+ return cleanupPromise;
141
168
  };
142
169
 
143
170
  //#endregion
@@ -146,68 +173,6 @@ function defineParallelPlugin(pluginPath) {
146
173
  throw new Error("`defineParallelPlugin` is not supported in browser build");
147
174
  }
148
175
 
149
- //#endregion
150
- //#region src/builtin-plugin/constructors.ts
151
- function modulePreloadPolyfillPlugin(config) {
152
- return new BuiltinPlugin("builtin:module-preload-polyfill", config);
153
- }
154
- function dynamicImportVarsPlugin(config) {
155
- if (config) {
156
- config.include = normalizedStringOrRegex(config.include);
157
- config.exclude = normalizedStringOrRegex(config.exclude);
158
- }
159
- return new BuiltinPlugin("builtin:dynamic-import-vars", config);
160
- }
161
- function importGlobPlugin(config) {
162
- return new BuiltinPlugin("builtin:import-glob", config);
163
- }
164
- function reporterPlugin(config) {
165
- return new BuiltinPlugin("builtin:reporter", config);
166
- }
167
- function manifestPlugin(config) {
168
- return new BuiltinPlugin("builtin:manifest", config);
169
- }
170
- function wasmHelperPlugin(config) {
171
- return new BuiltinPlugin("builtin:wasm-helper", config);
172
- }
173
- function wasmFallbackPlugin() {
174
- return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:wasm-fallback"));
175
- }
176
- function loadFallbackPlugin() {
177
- return new BuiltinPlugin("builtin:load-fallback");
178
- }
179
- function jsonPlugin(config) {
180
- return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:json", config));
181
- }
182
- function buildImportAnalysisPlugin(config) {
183
- return new BuiltinPlugin("builtin:build-import-analysis", config);
184
- }
185
- function viteResolvePlugin(config) {
186
- return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:vite-resolve", config));
187
- }
188
- function isolatedDeclarationPlugin(config) {
189
- return new BuiltinPlugin("builtin:isolated-declaration", config);
190
- }
191
- function webWorkerPostPlugin() {
192
- return new BuiltinPlugin("builtin:web-worker-post");
193
- }
194
- function esmExternalRequirePlugin(config) {
195
- return new BuiltinPlugin("builtin:esm-external-require", config);
196
- }
197
- function reactRefreshWrapperPlugin(config) {
198
- if (config) {
199
- config.include = normalizedStringOrRegex(config.include);
200
- config.exclude = normalizedStringOrRegex(config.exclude);
201
- }
202
- return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:react-refresh-wrapper", config));
203
- }
204
- function viteCSSPostPlugin(config) {
205
- return new BuiltinPlugin("builtin:vite-css-post", config);
206
- }
207
- function viteHtmlPlugin(config) {
208
- return new BuiltinPlugin("builtin:vite-html", config);
209
- }
210
-
211
176
  //#endregion
212
177
  //#region src/builtin-plugin/alias-plugin.ts
213
178
  function aliasPlugin(config) {
@@ -220,41 +185,6 @@ function assetPlugin(config) {
220
185
  return new BuiltinPlugin("builtin:asset", config);
221
186
  }
222
187
 
223
- //#endregion
224
- //#region src/builtin-plugin/replace-plugin.ts
225
- /**
226
- * Replaces targeted strings in files while bundling.
227
- *
228
- * @example
229
- * // Basic usage
230
- * ```js
231
- * replacePlugin({
232
- * 'process.env.NODE_ENV': JSON.stringify('production'),
233
- * __buildVersion: 15
234
- * })
235
- * ```
236
- * @example
237
- * // With options
238
- * ```js
239
- * replacePlugin({
240
- * 'process.env.NODE_ENV': JSON.stringify('production'),
241
- * __buildVersion: 15
242
- * }, {
243
- * preventAssignment: false,
244
- * })
245
- * ```
246
- */
247
- function replacePlugin(values = {}, options = {}) {
248
- Object.keys(values).forEach((key) => {
249
- const value = values[key];
250
- if (typeof value !== "string") values[key] = String(value);
251
- });
252
- return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:replace", {
253
- ...options,
254
- values
255
- }));
256
- }
257
-
258
188
  //#endregion
259
189
  //#region src/builtin-plugin/transform-plugin.ts
260
190
  function transformPlugin(config) {
@@ -284,4 +214,4 @@ function viteCSSPlugin(config) {
284
214
  }
285
215
 
286
216
  //#endregion
287
- export { BindingRebuildStrategy, DevEngine, ResolverFactory, aliasPlugin, assetPlugin, buildImportAnalysisPlugin, defineParallelPlugin, dev, dynamicImportVarsPlugin, esmExternalRequirePlugin, freeExternalMemory, importGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, minify, modulePreloadPolyfillPlugin, moduleRunnerTransform, reactRefreshWrapperPlugin, replacePlugin, reporterPlugin, scan, transform, transformPlugin, viteCSSPlugin, viteCSSPostPlugin, viteHtmlPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin };
217
+ export { BindingRebuildStrategy, DevEngine, ResolverFactory, aliasPlugin, assetPlugin, buildImportAnalysisPlugin, defineParallelPlugin, dev, dynamicImportVarsPlugin, freeExternalMemory, htmlInlineProxyPlugin, importGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, minify, modulePreloadPolyfillPlugin, moduleRunnerTransform, parseAsync, parseSync, reactRefreshWrapperPlugin, reporterPlugin, scan, transform, transformPlugin, viteCSSPlugin, viteCSSPostPlugin, viteHtmlPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin };
@@ -1,5 +1,7 @@
1
- import { A as BuiltinPlugin, N as SourceMapInput, U as defineParallelPlugin, bt as OutputOptions, jt as freeExternalMemory, kt as RolldownOutput, o as InputOptions, wt as StringOrRegExp } from "./shared/define-config-pfDd6Le4.mjs";
2
- import { A as IsolatedDeclarationsOptions, B as ResolverFactory, C as BindingViteCssPluginConfig, D as BindingWasmHelperPluginConfig, E as BindingViteResolvePluginConfig, F as NapiResolveOptions, G as moduleRunnerTransform, H as TransformResult, K as transform, N as MinifyOptions, P as MinifyResult, S as BindingUrlResolver, T as BindingViteHtmlPluginConfig, U as isolatedDeclaration, V as TransformOptions, W as minify, a as BindingClientHmrUpdate, d as BindingJsonPluginConfig, g as BindingRebuildStrategy, h as BindingReactRefreshWrapperPluginConfig, j as IsolatedDeclarationsResult, l as BindingImportGlobPluginConfig, m as BindingModulePreloadPolyfillPluginConfig, n as BindingBuildImportAnalysisPluginConfig, o as BindingDynamicImportVarsPluginConfig, p as BindingManifestPluginConfig, s as BindingEsmExternalRequirePluginConfig, t as BindingAssetPluginConfig, u as BindingIsolatedDeclarationPluginConfig, v as BindingReplacePluginConfig, w as BindingViteCssPostPluginConfig, x as BindingTransformPluginConfig, y as BindingReporterPluginConfig, z as ResolveResult } from "./shared/binding-CRSqCQIK.mjs";
1
+ import { Dt as freeExternalMemory, H as defineParallelPlugin, M as SourceMapInput, Tt as RolldownOutput, o as InputOptions, yt as OutputOptions } from "./shared/define-config-Dv3i4cxM.mjs";
2
+ import { A as IsolatedDeclarationsOptions, B as ResolverFactory, F as NapiResolveOptions, G as moduleRunnerTransform, H as TransformResult, I as ParseResult, J as transform, K as parseAsync, L as ParserOptions, N as MinifyOptions, P as MinifyResult, S as BindingViteCssPluginConfig, U as isolatedDeclaration, V as TransformOptions, W as minify, b as BindingTransformPluginConfig, h as BindingRebuildStrategy, i as BindingClientHmrUpdate, j as IsolatedDeclarationsResult, q as parseSync, t as BindingAssetPluginConfig, x as BindingUrlResolver, z as ResolveResult } from "./shared/binding-B4uTNiw2.mjs";
3
+ import { t as BuiltinPlugin } from "./shared/utils-CduIqa7h.mjs";
4
+ import { _ as wasmHelperPlugin, a as importGlobPlugin, c as loadFallbackPlugin, d as reactRefreshWrapperPlugin, f as reporterPlugin, g as wasmFallbackPlugin, h as viteResolvePlugin, i as htmlInlineProxyPlugin, l as manifestPlugin, m as viteHtmlPlugin, n as dynamicImportVarsPlugin, o as isolatedDeclarationPlugin, p as viteCSSPostPlugin, s as jsonPlugin, t as buildImportAnalysisPlugin, u as modulePreloadPolyfillPlugin, v as webWorkerPostPlugin } from "./shared/constructors-CaN9lKj2.mjs";
3
5
 
4
6
  //#region src/api/dev/dev-options.d.ts
5
7
  type DevOnHmrUpdates = (result: Error | {
@@ -81,38 +83,21 @@ declare const dev: typeof DevEngine.create;
81
83
  //#endregion
82
84
  //#region src/api/experimental.d.ts
83
85
  /**
84
- * This is an experimental API. It's behavior may change in the future.
86
+ * This is an experimental API. Its behavior may change in the future.
85
87
  *
86
- * Calling this API will only execute the scan stage of rolldown.
88
+ * - Calling this API will only execute the `scan/build` stage of rolldown.
89
+ * - `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.
90
+ *
91
+ * @example To ensure cleanup of resources, use the returned promise to wait for the scan to complete.
92
+ * ```ts
93
+ * import { scan } from 'rolldown/api/experimental';
94
+ *
95
+ * const cleanupPromise = await scan(...);
96
+ * await cleanupPromise;
97
+ * // Now all resources have been cleaned up.
98
+ * ```
87
99
  */
88
- declare const scan: (input: InputOptions) => Promise<void>;
89
- //#endregion
90
- //#region src/builtin-plugin/constructors.d.ts
91
- declare function modulePreloadPolyfillPlugin(config?: BindingModulePreloadPolyfillPluginConfig): BuiltinPlugin;
92
- type DynamicImportVarsPluginConfig = Omit<BindingDynamicImportVarsPluginConfig, "include" | "exclude"> & {
93
- include?: StringOrRegExp | StringOrRegExp[];
94
- exclude?: StringOrRegExp | StringOrRegExp[];
95
- };
96
- declare function dynamicImportVarsPlugin(config?: DynamicImportVarsPluginConfig): BuiltinPlugin;
97
- declare function importGlobPlugin(config?: BindingImportGlobPluginConfig): BuiltinPlugin;
98
- declare function reporterPlugin(config?: BindingReporterPluginConfig): BuiltinPlugin;
99
- declare function manifestPlugin(config?: BindingManifestPluginConfig): BuiltinPlugin;
100
- declare function wasmHelperPlugin(config?: BindingWasmHelperPluginConfig): BuiltinPlugin;
101
- declare function wasmFallbackPlugin(): BuiltinPlugin;
102
- declare function loadFallbackPlugin(): BuiltinPlugin;
103
- declare function jsonPlugin(config?: BindingJsonPluginConfig): BuiltinPlugin;
104
- declare function buildImportAnalysisPlugin(config: BindingBuildImportAnalysisPluginConfig): BuiltinPlugin;
105
- declare function viteResolvePlugin(config: BindingViteResolvePluginConfig): BuiltinPlugin;
106
- declare function isolatedDeclarationPlugin(config?: BindingIsolatedDeclarationPluginConfig): BuiltinPlugin;
107
- declare function webWorkerPostPlugin(): BuiltinPlugin;
108
- declare function esmExternalRequirePlugin(config?: BindingEsmExternalRequirePluginConfig): BuiltinPlugin;
109
- type ReactRefreshWrapperPluginConfig = Omit<BindingReactRefreshWrapperPluginConfig, "include" | "exclude"> & {
110
- include?: StringOrRegExp | StringOrRegExp[];
111
- exclude?: StringOrRegExp | StringOrRegExp[];
112
- };
113
- declare function reactRefreshWrapperPlugin(config: ReactRefreshWrapperPluginConfig): BuiltinPlugin;
114
- declare function viteCSSPostPlugin(config?: BindingViteCssPostPluginConfig): BuiltinPlugin;
115
- declare function viteHtmlPlugin(config?: BindingViteHtmlPluginConfig): BuiltinPlugin;
100
+ declare const scan: (rawInputOptions: InputOptions, rawOutputOptions?: {}) => Promise<Promise<void>>;
116
101
  //#endregion
117
102
  //#region src/builtin-plugin/alias-plugin.d.ts
118
103
  type AliasPluginAlias = {
@@ -127,31 +112,6 @@ declare function aliasPlugin(config: AliasPluginConfig): BuiltinPlugin;
127
112
  //#region src/builtin-plugin/asset-plugin.d.ts
128
113
  declare function assetPlugin(config: BindingAssetPluginConfig): BuiltinPlugin;
129
114
  //#endregion
130
- //#region src/builtin-plugin/replace-plugin.d.ts
131
- /**
132
- * Replaces targeted strings in files while bundling.
133
- *
134
- * @example
135
- * // Basic usage
136
- * ```js
137
- * replacePlugin({
138
- * 'process.env.NODE_ENV': JSON.stringify('production'),
139
- * __buildVersion: 15
140
- * })
141
- * ```
142
- * @example
143
- * // With options
144
- * ```js
145
- * replacePlugin({
146
- * 'process.env.NODE_ENV': JSON.stringify('production'),
147
- * __buildVersion: 15
148
- * }, {
149
- * preventAssignment: false,
150
- * })
151
- * ```
152
- */
153
- declare function replacePlugin(values?: BindingReplacePluginConfig["values"], options?: Omit<BindingReplacePluginConfig, "values">): BuiltinPlugin;
154
- //#endregion
155
115
  //#region src/builtin-plugin/transform-plugin.d.ts
156
116
  type TransformPattern = string | RegExp | readonly (RegExp | string)[];
157
117
  type TransformPluginConfig = Omit<BindingTransformPluginConfig, "include" | "exclude" | "jsxRefreshInclude" | "jsxRefreshExclude"> & {
@@ -173,4 +133,4 @@ type ViteCssPluginConfig = Omit<BindingViteCssPluginConfig, "compileCSS"> & {
173
133
  };
174
134
  declare function viteCSSPlugin(config?: ViteCssPluginConfig): BuiltinPlugin;
175
135
  //#endregion
176
- export { type BindingClientHmrUpdate, BindingRebuildStrategy, DevEngine, type DevOptions, type DevWatchOptions, type IsolatedDeclarationsOptions, type IsolatedDeclarationsResult, type MinifyOptions, type MinifyResult, type NapiResolveOptions as ResolveOptions, type ResolveResult, ResolverFactory, type TransformOptions, type TransformResult, aliasPlugin, assetPlugin, buildImportAnalysisPlugin, defineParallelPlugin, dev, dynamicImportVarsPlugin, esmExternalRequirePlugin, freeExternalMemory, importGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, minify, modulePreloadPolyfillPlugin, moduleRunnerTransform, reactRefreshWrapperPlugin, replacePlugin, reporterPlugin, scan, transform, transformPlugin, viteCSSPlugin, viteCSSPostPlugin, viteHtmlPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin };
136
+ export { type BindingClientHmrUpdate, BindingRebuildStrategy, DevEngine, type DevOptions, type DevWatchOptions, type IsolatedDeclarationsOptions, type IsolatedDeclarationsResult, type MinifyOptions, type MinifyResult, type ParseResult, type ParserOptions, type NapiResolveOptions as ResolveOptions, type ResolveResult, ResolverFactory, type TransformOptions, type TransformResult, aliasPlugin, assetPlugin, buildImportAnalysisPlugin, defineParallelPlugin, dev, dynamicImportVarsPlugin, freeExternalMemory, htmlInlineProxyPlugin, importGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, minify, modulePreloadPolyfillPlugin, moduleRunnerTransform, parseAsync, parseSync, reactRefreshWrapperPlugin, reporterPlugin, scan, transform, transformPlugin, viteCSSPlugin, viteCSSPostPlugin, viteHtmlPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin };
@@ -1,7 +1,10 @@
1
- import { b as BuiltinPlugin, c as createBundlerOptions, f as normalizeBindingResult, l as normalizedStringOrRegex, m as bindingifySourcemap, p as transformToRollupOutput, s as RolldownBuild, x as makeBuiltinPluginCallable, y as PluginDriver } from "./shared/src-DE7RBSfl.mjs";
2
- import "./shared/parse-ast-index-BiBzSGZe.mjs";
3
- import "./shared/composable-filters-D_PY7Qa7.mjs";
4
- import { BindingDevEngine, BindingRebuildStrategy, BindingRebuildStrategy as BindingRebuildStrategy$1, ResolverFactory, isolatedDeclaration, minify, moduleRunnerTransform, transform } from "./rolldown-binding.wasi.cjs";
1
+ import { c as createBundlerOptions, d as normalizeBindingResult, f as unwrapBindingResult, m as bindingifySourcemap, p as transformToRollupOutput, s as RolldownBuild, x as PluginDriver, y as validateOption } from "./shared/src-CvsuRKGv.mjs";
2
+ import "./shared/logs-CPsamAuj.mjs";
3
+ import { n as BuiltinPlugin, t as normalizedStringOrRegex } from "./shared/normalize-string-or-regex-CbDij6KB.mjs";
4
+ import "./shared/composable-filters-CBpK2Fbc.mjs";
5
+ import "./shared/parse-ast-index-D9jH_38U.mjs";
6
+ import { _ as wasmHelperPlugin, a as importGlobPlugin, c as loadFallbackPlugin, d as reactRefreshWrapperPlugin, f as reporterPlugin, g as wasmFallbackPlugin, h as viteResolvePlugin, i as htmlInlineProxyPlugin, l as manifestPlugin, m as viteHtmlPlugin, n as dynamicImportVarsPlugin, o as isolatedDeclarationPlugin, p as viteCSSPostPlugin, s as jsonPlugin, t as buildImportAnalysisPlugin, u as modulePreloadPolyfillPlugin, v as webWorkerPostPlugin } from "./shared/constructors-DcEzB0nc.mjs";
7
+ import { BindingBundler, BindingDevEngine, BindingRebuildStrategy, BindingRebuildStrategy as BindingRebuildStrategy$1, ResolverFactory, isolatedDeclaration, minify, moduleRunnerTransform, parseAsync, parseSync, shutdownAsyncRuntime, startAsyncRuntime, transform } from "./rolldown-binding.wasi.cjs";
5
8
  import { pathToFileURL } from "node:url";
6
9
 
7
10
  //#region src/api/dev/dev-engine.ts
@@ -130,17 +133,42 @@ function freeExternalMemory(handle, keepDataAlive = false) {
130
133
  //#endregion
131
134
  //#region src/api/experimental.ts
132
135
  /**
133
- * This is an experimental API. It's behavior may change in the future.
136
+ * This is an experimental API. Its behavior may change in the future.
134
137
  *
135
- * Calling this API will only execute the scan stage of rolldown.
138
+ * - Calling this API will only execute the `scan/build` stage of rolldown.
139
+ * - `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.
140
+ *
141
+ * @example To ensure cleanup of resources, use the returned promise to wait for the scan to complete.
142
+ * ```ts
143
+ * import { scan } from 'rolldown/api/experimental';
144
+ *
145
+ * const cleanupPromise = await scan(...);
146
+ * await cleanupPromise;
147
+ * // Now all resources have been cleaned up.
148
+ * ```
136
149
  */
137
- const scan = async (input) => {
138
- const build = new RolldownBuild(await PluginDriver.callOptionsHook(input));
150
+ const scan = async (rawInputOptions, rawOutputOptions = {}) => {
151
+ validateOption("input", rawInputOptions);
152
+ validateOption("output", rawOutputOptions);
153
+ const ret = await createBundlerOptions(await PluginDriver.callOptionsHook(rawInputOptions), rawOutputOptions, false);
154
+ const bundler = new BindingBundler();
155
+ if (RolldownBuild.asyncRuntimeShutdown) startAsyncRuntime();
156
+ async function cleanup() {
157
+ await bundler.close();
158
+ await ret.stopWorkers?.();
159
+ shutdownAsyncRuntime();
160
+ RolldownBuild.asyncRuntimeShutdown = true;
161
+ }
162
+ let cleanupPromise = Promise.resolve();
139
163
  try {
140
- await build.scan();
164
+ unwrapBindingResult(await bundler.scan(ret.bundlerOptions));
165
+ } catch (err) {
166
+ await cleanup();
167
+ throw err;
141
168
  } finally {
142
- await build.close();
169
+ cleanupPromise = cleanup();
143
170
  }
171
+ return cleanupPromise;
144
172
  };
145
173
 
146
174
  //#endregion
@@ -154,68 +182,6 @@ function defineParallelPlugin(pluginPath) {
154
182
  };
155
183
  }
156
184
 
157
- //#endregion
158
- //#region src/builtin-plugin/constructors.ts
159
- function modulePreloadPolyfillPlugin(config) {
160
- return new BuiltinPlugin("builtin:module-preload-polyfill", config);
161
- }
162
- function dynamicImportVarsPlugin(config) {
163
- if (config) {
164
- config.include = normalizedStringOrRegex(config.include);
165
- config.exclude = normalizedStringOrRegex(config.exclude);
166
- }
167
- return new BuiltinPlugin("builtin:dynamic-import-vars", config);
168
- }
169
- function importGlobPlugin(config) {
170
- return new BuiltinPlugin("builtin:import-glob", config);
171
- }
172
- function reporterPlugin(config) {
173
- return new BuiltinPlugin("builtin:reporter", config);
174
- }
175
- function manifestPlugin(config) {
176
- return new BuiltinPlugin("builtin:manifest", config);
177
- }
178
- function wasmHelperPlugin(config) {
179
- return new BuiltinPlugin("builtin:wasm-helper", config);
180
- }
181
- function wasmFallbackPlugin() {
182
- return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:wasm-fallback"));
183
- }
184
- function loadFallbackPlugin() {
185
- return new BuiltinPlugin("builtin:load-fallback");
186
- }
187
- function jsonPlugin(config) {
188
- return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:json", config));
189
- }
190
- function buildImportAnalysisPlugin(config) {
191
- return new BuiltinPlugin("builtin:build-import-analysis", config);
192
- }
193
- function viteResolvePlugin(config) {
194
- return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:vite-resolve", config));
195
- }
196
- function isolatedDeclarationPlugin(config) {
197
- return new BuiltinPlugin("builtin:isolated-declaration", config);
198
- }
199
- function webWorkerPostPlugin() {
200
- return new BuiltinPlugin("builtin:web-worker-post");
201
- }
202
- function esmExternalRequirePlugin(config) {
203
- return new BuiltinPlugin("builtin:esm-external-require", config);
204
- }
205
- function reactRefreshWrapperPlugin(config) {
206
- if (config) {
207
- config.include = normalizedStringOrRegex(config.include);
208
- config.exclude = normalizedStringOrRegex(config.exclude);
209
- }
210
- return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:react-refresh-wrapper", config));
211
- }
212
- function viteCSSPostPlugin(config) {
213
- return new BuiltinPlugin("builtin:vite-css-post", config);
214
- }
215
- function viteHtmlPlugin(config) {
216
- return new BuiltinPlugin("builtin:vite-html", config);
217
- }
218
-
219
185
  //#endregion
220
186
  //#region src/builtin-plugin/alias-plugin.ts
221
187
  function aliasPlugin(config) {
@@ -228,41 +194,6 @@ function assetPlugin(config) {
228
194
  return new BuiltinPlugin("builtin:asset", config);
229
195
  }
230
196
 
231
- //#endregion
232
- //#region src/builtin-plugin/replace-plugin.ts
233
- /**
234
- * Replaces targeted strings in files while bundling.
235
- *
236
- * @example
237
- * // Basic usage
238
- * ```js
239
- * replacePlugin({
240
- * 'process.env.NODE_ENV': JSON.stringify('production'),
241
- * __buildVersion: 15
242
- * })
243
- * ```
244
- * @example
245
- * // With options
246
- * ```js
247
- * replacePlugin({
248
- * 'process.env.NODE_ENV': JSON.stringify('production'),
249
- * __buildVersion: 15
250
- * }, {
251
- * preventAssignment: false,
252
- * })
253
- * ```
254
- */
255
- function replacePlugin(values = {}, options = {}) {
256
- Object.keys(values).forEach((key) => {
257
- const value = values[key];
258
- if (typeof value !== "string") values[key] = String(value);
259
- });
260
- return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:replace", {
261
- ...options,
262
- values
263
- }));
264
- }
265
-
266
197
  //#endregion
267
198
  //#region src/builtin-plugin/transform-plugin.ts
268
199
  function transformPlugin(config) {
@@ -292,4 +223,4 @@ function viteCSSPlugin(config) {
292
223
  }
293
224
 
294
225
  //#endregion
295
- export { BindingRebuildStrategy, DevEngine, ResolverFactory, aliasPlugin, assetPlugin, buildImportAnalysisPlugin, defineParallelPlugin, dev, dynamicImportVarsPlugin, esmExternalRequirePlugin, freeExternalMemory, importGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, minify, modulePreloadPolyfillPlugin, moduleRunnerTransform, reactRefreshWrapperPlugin, replacePlugin, reporterPlugin, scan, transform, transformPlugin, viteCSSPlugin, viteCSSPostPlugin, viteHtmlPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin };
226
+ export { BindingRebuildStrategy, DevEngine, ResolverFactory, aliasPlugin, assetPlugin, buildImportAnalysisPlugin, defineParallelPlugin, dev, dynamicImportVarsPlugin, freeExternalMemory, htmlInlineProxyPlugin, importGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, minify, modulePreloadPolyfillPlugin, moduleRunnerTransform, parseAsync, parseSync, reactRefreshWrapperPlugin, reporterPlugin, scan, transform, transformPlugin, viteCSSPlugin, viteCSSPostPlugin, viteHtmlPlugin, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, webWorkerPostPlugin };
@@ -1,4 +1,5 @@
1
- import { k as withFilter } from "./shared/define-config-pfDd6Le4.mjs";
2
- import "./shared/binding-CRSqCQIK.mjs";
1
+ import { k as withFilter } from "./shared/define-config-Dv3i4cxM.mjs";
2
+ import "./shared/binding-B4uTNiw2.mjs";
3
+ import "./shared/utils-CduIqa7h.mjs";
3
4
  import { and, code, exclude, id, include, moduleType, not, or, queries, query } from "@rolldown/pluginutils";
4
5
  export { and, code, exclude, id, include, moduleType, not, or, queries, query, withFilter };
@@ -1,4 +1,4 @@
1
- import { a as include, c as or, d as arraify, f as isPromiseLike, i as id, l as queries, n as code, o as moduleType, r as exclude, s as not, t as and, u as query } from "./shared/composable-filters-D_PY7Qa7.mjs";
1
+ import { a as include, c as or, d as arraify, f as isPromiseLike, i as id, l as queries, n as code, o as moduleType, r as exclude, s as not, t as and, u as query } from "./shared/composable-filters-CBpK2Fbc.mjs";
2
2
 
3
3
  //#region src/plugin/with-filter.ts
4
4
  function withFilterImpl(pluginOption, filterObjectList) {
@@ -1,3 +1,4 @@
1
- import { a as build, i as watch, n as VERSION, o as rolldown, r as defineConfig, t as BindingMagicString } from "./src-Deywlnh0.js";
1
+ import { a as build, i as watch, n as VERSION, o as rolldown, r as defineConfig, t as BindingMagicString } from "./src-DLQqj5Wo.js";
2
+ import "./normalize-string-or-regex-d47jXr3r.js";
2
3
 
3
4
  export { BindingMagicString, VERSION, build, defineConfig, rolldown, watch };