rolldown 1.0.0-beta.47 → 1.0.0-beta.49

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 (30) hide show
  1. package/dist/cli-setup.mjs +2 -2
  2. package/dist/cli.mjs +23 -10
  3. package/dist/config.d.mts +3 -2
  4. package/dist/config.mjs +7 -5
  5. package/dist/experimental-index.d.mts +18 -58
  6. package/dist/experimental-index.mjs +46 -112
  7. package/dist/filter-index.d.mts +3 -2
  8. package/dist/filter-index.mjs +1 -1
  9. package/dist/index.d.mts +3 -2
  10. package/dist/index.mjs +6 -4
  11. package/dist/parallel-plugin-worker.mjs +7 -5
  12. package/dist/parallel-plugin.d.mts +3 -2
  13. package/dist/parse-ast-index.d.mts +1 -1
  14. package/dist/parse-ast-index.mjs +3 -2
  15. package/dist/plugins-index.d.mts +31 -0
  16. package/dist/plugins-index.mjs +41 -0
  17. package/dist/shared/{binding-DBWhurrz.mjs → binding-Byz_-zMd.mjs} +28 -47
  18. package/dist/shared/{binding-BHtM7anm.d.mts → binding-TAvxYaaL.d.mts} +19 -49
  19. package/dist/shared/constructors-DLBJKpBt.mjs +68 -0
  20. package/dist/shared/constructors-DlLr_UMo.d.mts +32 -0
  21. package/dist/shared/{define-config-DdWK1ZyG.d.mts → define-config-CYc9_msm.d.mts} +7 -64
  22. package/dist/shared/{load-config-CQKld1Y8.mjs → load-config-DZSqgTtd.mjs} +1 -1
  23. package/dist/shared/{parse-ast-index-B4DJl5-M.mjs → logs-CSQ_UMWp.mjs} +2 -124
  24. package/dist/shared/normalize-string-or-regex-DpeiLkum.mjs +47 -0
  25. package/dist/shared/parse-ast-index-C3nalU1P.mjs +82 -0
  26. package/dist/shared/{prompt-YGfbLmz5.mjs → prompt-sxF8x3Tv.mjs} +1 -1
  27. package/dist/shared/{src-BwxUhqZU.mjs → src-CmBhXIUZ.mjs} +227 -201
  28. package/dist/shared/utils-CzdPrevI.d.mts +18 -0
  29. package/package.json +20 -19
  30. /package/dist/shared/{misc-usdOVIou.mjs → misc-DpQNcSw4.mjs} +0 -0
@@ -1,7 +1,7 @@
1
- import { n as __toESM, t as require_binding } from "./shared/binding-DBWhurrz.mjs";
1
+ import { t as require_binding } from "./shared/binding-Byz_-zMd.mjs";
2
2
 
3
3
  //#region src/cli/setup-index.ts
4
- var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
4
+ var import_binding = require_binding();
5
5
  let isWatchMode = false;
6
6
  for (let i = 0; i < process.argv.length; i++) {
7
7
  const arg = process.argv[i];
package/dist/cli.mjs CHANGED
@@ -1,10 +1,12 @@
1
- import "./shared/binding-DBWhurrz.mjs";
2
- 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-BwxUhqZU.mjs";
3
- import { h as styleText$1 } from "./shared/parse-ast-index-B4DJl5-M.mjs";
4
- import { t as arraify } from "./shared/misc-usdOVIou.mjs";
5
- import { t as loadConfig } from "./shared/load-config-CQKld1Y8.mjs";
6
- import { formatWithOptions, parseArgs } from "node:util";
1
+ import "./shared/binding-Byz_-zMd.mjs";
2
+ 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-CmBhXIUZ.mjs";
3
+ import "./shared/logs-CSQ_UMWp.mjs";
4
+ import "./shared/normalize-string-or-regex-DpeiLkum.mjs";
5
+ import { t as arraify } from "./shared/misc-DpQNcSw4.mjs";
6
+ import "./shared/parse-ast-index-C3nalU1P.mjs";
7
+ import { t as loadConfig } from "./shared/load-config-DZSqgTtd.mjs";
7
8
  import path, { sep } from "node:path";
9
+ import { formatWithOptions, parseArgs } from "node:util";
8
10
  import process$1 from "node:process";
9
11
  import * as tty from "node:tty";
10
12
  import { performance } from "node:perf_hooks";
@@ -947,7 +949,7 @@ function createConsola(options$1 = {}) {
947
949
  defaults: { level },
948
950
  stdout: process.stdout,
949
951
  stderr: process.stderr,
950
- prompt: (...args) => import("./shared/prompt-YGfbLmz5.mjs").then((m) => m.prompt(...args)),
952
+ prompt: (...args) => import("./shared/prompt-sxF8x3Tv.mjs").then((m) => m.prompt(...args)),
951
953
  reporters: options$1.reporters || [options$1.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()],
952
954
  ...options$1
953
955
  });
@@ -1054,7 +1056,18 @@ function kebabCaseToCamelCase(str) {
1054
1056
  //#endregion
1055
1057
  //#region src/cli/arguments/normalize.ts
1056
1058
  function normalizeCliOptions(cliOptions, positionals) {
1057
- const [data, errors] = validateCliOptions(cliOptions);
1059
+ const prototypePollutionKeys = [
1060
+ "__proto__",
1061
+ "constructor",
1062
+ "prototype"
1063
+ ];
1064
+ const unflattenedCliOptions = {};
1065
+ for (let [key, value] of Object.entries(cliOptions)) if (prototypePollutionKeys.includes(key)) {} else if (key.includes(".")) {
1066
+ const [parentKey] = key.split(".");
1067
+ unflattenedCliOptions[parentKey] ??= {};
1068
+ setNestedProperty(unflattenedCliOptions, key, value);
1069
+ } else unflattenedCliOptions[key] = value;
1070
+ const [data, errors] = validateCliOptions(unflattenedCliOptions);
1058
1071
  if (errors?.length) {
1059
1072
  errors.forEach((error) => {
1060
1073
  logger.error(`${error}. You can use \`rolldown -h\` to see the help.`);
@@ -1378,8 +1391,8 @@ async function bundleInner(config, cliOptions) {
1378
1391
  ...config$1,
1379
1392
  ...cliOptions.input
1380
1393
  });
1381
- for (const output of outputList) try {
1382
- result.push(await build.write({
1394
+ try {
1395
+ for (const output of outputList) result.push(await build.write({
1383
1396
  ...output,
1384
1397
  ...cliOptions.output
1385
1398
  }));
package/dist/config.d.mts CHANGED
@@ -1,5 +1,6 @@
1
- import { n as ConfigExport, t as defineConfig } from "./shared/define-config-DdWK1ZyG.mjs";
2
- import "./shared/binding-BHtM7anm.mjs";
1
+ import { n as ConfigExport, t as defineConfig } from "./shared/define-config-CYc9_msm.mjs";
2
+ import "./shared/binding-TAvxYaaL.mjs";
3
+ import "./shared/utils-CzdPrevI.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,8 +1,10 @@
1
- import "./shared/binding-DBWhurrz.mjs";
2
- import { C as version, r as defineConfig } from "./shared/src-BwxUhqZU.mjs";
3
- import "./shared/parse-ast-index-B4DJl5-M.mjs";
4
- import "./shared/misc-usdOVIou.mjs";
5
- import { t as loadConfig } from "./shared/load-config-CQKld1Y8.mjs";
1
+ import "./shared/binding-Byz_-zMd.mjs";
2
+ import { C as version, r as defineConfig } from "./shared/src-CmBhXIUZ.mjs";
3
+ import "./shared/logs-CSQ_UMWp.mjs";
4
+ import "./shared/normalize-string-or-regex-DpeiLkum.mjs";
5
+ import "./shared/misc-DpQNcSw4.mjs";
6
+ import "./shared/parse-ast-index-C3nalU1P.mjs";
7
+ import { t as loadConfig } from "./shared/load-config-DZSqgTtd.mjs";
6
8
 
7
9
  //#region src/config.ts
8
10
  const VERSION = version;
@@ -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-DdWK1ZyG.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-BHtM7anm.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-CYc9_msm.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-TAvxYaaL.mjs";
3
+ import { t as BuiltinPlugin } from "./shared/utils-CzdPrevI.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-DlLr_UMo.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,11 +1,14 @@
1
- import { n as __toESM, t as require_binding } from "./shared/binding-DBWhurrz.mjs";
2
- 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-BwxUhqZU.mjs";
3
- import "./shared/parse-ast-index-B4DJl5-M.mjs";
4
- import "./shared/misc-usdOVIou.mjs";
1
+ import { t as require_binding } from "./shared/binding-Byz_-zMd.mjs";
2
+ 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-CmBhXIUZ.mjs";
3
+ import "./shared/logs-CSQ_UMWp.mjs";
4
+ import { n as BuiltinPlugin, t as normalizedStringOrRegex } from "./shared/normalize-string-or-regex-DpeiLkum.mjs";
5
+ import "./shared/misc-DpQNcSw4.mjs";
6
+ import "./shared/parse-ast-index-C3nalU1P.mjs";
7
+ 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-DLBJKpBt.mjs";
5
8
  import { pathToFileURL } from "node:url";
6
9
 
7
10
  //#region src/api/dev/dev-engine.ts
8
- var import_binding$1 = /* @__PURE__ */ __toESM(require_binding(), 1);
11
+ var import_binding$2 = require_binding();
9
12
  var DevEngine = class DevEngine {
10
13
  #inner;
11
14
  #cachedBuildFinishPromise = null;
@@ -36,7 +39,7 @@ var DevEngine = class DevEngine {
36
39
  }
37
40
  userOnOutput(transformToRollupOutput(result));
38
41
  } : void 0,
39
- rebuildStrategy: devOptions.rebuildStrategy ? devOptions.rebuildStrategy === "always" ? import_binding$1.BindingRebuildStrategy.Always : devOptions.rebuildStrategy === "auto" ? import_binding$1.BindingRebuildStrategy.Auto : import_binding$1.BindingRebuildStrategy.Never : void 0,
42
+ rebuildStrategy: devOptions.rebuildStrategy ? devOptions.rebuildStrategy === "always" ? import_binding$2.BindingRebuildStrategy.Always : devOptions.rebuildStrategy === "auto" ? import_binding$2.BindingRebuildStrategy.Auto : import_binding$2.BindingRebuildStrategy.Never : void 0,
40
43
  watch: devOptions.watch && {
41
44
  skipWrite: devOptions.watch.skipWrite,
42
45
  usePolling: devOptions.watch.usePolling,
@@ -47,7 +50,7 @@ var DevEngine = class DevEngine {
47
50
  debounceTickRate: devOptions.watch.debounceTickRate
48
51
  }
49
52
  };
50
- return new DevEngine(new import_binding$1.BindingDevEngine(options.bundlerOptions, bindingDevOptions));
53
+ return new DevEngine(new import_binding$2.BindingDevEngine(options.bundlerOptions, bindingDevOptions));
51
54
  }
52
55
  constructor(inner) {
53
56
  this.#inner = inner;
@@ -130,18 +133,44 @@ function freeExternalMemory(handle, keepDataAlive = false) {
130
133
 
131
134
  //#endregion
132
135
  //#region src/api/experimental.ts
136
+ var import_binding$1 = require_binding();
133
137
  /**
134
- * This is an experimental API. It's behavior may change in the future.
138
+ * This is an experimental API. Its behavior may change in the future.
135
139
  *
136
- * Calling this API will only execute the scan stage of rolldown.
140
+ * - Calling this API will only execute the `scan/build` stage of rolldown.
141
+ * - `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.
142
+ *
143
+ * @example To ensure cleanup of resources, use the returned promise to wait for the scan to complete.
144
+ * ```ts
145
+ * import { scan } from 'rolldown/api/experimental';
146
+ *
147
+ * const cleanupPromise = await scan(...);
148
+ * await cleanupPromise;
149
+ * // Now all resources have been cleaned up.
150
+ * ```
137
151
  */
138
- const scan = async (input) => {
139
- const build = new RolldownBuild(await PluginDriver.callOptionsHook(input));
152
+ const scan = async (rawInputOptions, rawOutputOptions = {}) => {
153
+ validateOption("input", rawInputOptions);
154
+ validateOption("output", rawOutputOptions);
155
+ const ret = await createBundlerOptions(await PluginDriver.callOptionsHook(rawInputOptions), rawOutputOptions, false);
156
+ const bundler = new import_binding$1.BindingBundler();
157
+ if (RolldownBuild.asyncRuntimeShutdown) (0, import_binding$1.startAsyncRuntime)();
158
+ async function cleanup() {
159
+ await bundler.close();
160
+ await ret.stopWorkers?.();
161
+ (0, import_binding$1.shutdownAsyncRuntime)();
162
+ RolldownBuild.asyncRuntimeShutdown = true;
163
+ }
164
+ let cleanupPromise = Promise.resolve();
140
165
  try {
141
- await build.scan();
166
+ unwrapBindingResult(await bundler.scan(ret.bundlerOptions));
167
+ } catch (err) {
168
+ await cleanup();
169
+ throw err;
142
170
  } finally {
143
- await build.close();
171
+ cleanupPromise = cleanup();
144
172
  }
173
+ return cleanupPromise;
145
174
  };
146
175
 
147
176
  //#endregion
@@ -155,68 +184,6 @@ function defineParallelPlugin(pluginPath) {
155
184
  };
156
185
  }
157
186
 
158
- //#endregion
159
- //#region src/builtin-plugin/constructors.ts
160
- function modulePreloadPolyfillPlugin(config) {
161
- return new BuiltinPlugin("builtin:module-preload-polyfill", config);
162
- }
163
- function dynamicImportVarsPlugin(config) {
164
- if (config) {
165
- config.include = normalizedStringOrRegex(config.include);
166
- config.exclude = normalizedStringOrRegex(config.exclude);
167
- }
168
- return new BuiltinPlugin("builtin:dynamic-import-vars", config);
169
- }
170
- function importGlobPlugin(config) {
171
- return new BuiltinPlugin("builtin:import-glob", config);
172
- }
173
- function reporterPlugin(config) {
174
- return new BuiltinPlugin("builtin:reporter", config);
175
- }
176
- function manifestPlugin(config) {
177
- return new BuiltinPlugin("builtin:manifest", config);
178
- }
179
- function wasmHelperPlugin(config) {
180
- return new BuiltinPlugin("builtin:wasm-helper", config);
181
- }
182
- function wasmFallbackPlugin() {
183
- return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:wasm-fallback"));
184
- }
185
- function loadFallbackPlugin() {
186
- return new BuiltinPlugin("builtin:load-fallback");
187
- }
188
- function jsonPlugin(config) {
189
- return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:json", config));
190
- }
191
- function buildImportAnalysisPlugin(config) {
192
- return new BuiltinPlugin("builtin:build-import-analysis", config);
193
- }
194
- function viteResolvePlugin(config) {
195
- return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:vite-resolve", config));
196
- }
197
- function isolatedDeclarationPlugin(config) {
198
- return new BuiltinPlugin("builtin:isolated-declaration", config);
199
- }
200
- function webWorkerPostPlugin() {
201
- return new BuiltinPlugin("builtin:web-worker-post");
202
- }
203
- function esmExternalRequirePlugin(config) {
204
- return new BuiltinPlugin("builtin:esm-external-require", config);
205
- }
206
- function reactRefreshWrapperPlugin(config) {
207
- if (config) {
208
- config.include = normalizedStringOrRegex(config.include);
209
- config.exclude = normalizedStringOrRegex(config.exclude);
210
- }
211
- return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:react-refresh-wrapper", config));
212
- }
213
- function viteCSSPostPlugin(config) {
214
- return new BuiltinPlugin("builtin:vite-css-post", config);
215
- }
216
- function viteHtmlPlugin(config) {
217
- return new BuiltinPlugin("builtin:vite-html", config);
218
- }
219
-
220
187
  //#endregion
221
188
  //#region src/builtin-plugin/alias-plugin.ts
222
189
  function aliasPlugin(config) {
@@ -229,41 +196,6 @@ function assetPlugin(config) {
229
196
  return new BuiltinPlugin("builtin:asset", config);
230
197
  }
231
198
 
232
- //#endregion
233
- //#region src/builtin-plugin/replace-plugin.ts
234
- /**
235
- * Replaces targeted strings in files while bundling.
236
- *
237
- * @example
238
- * // Basic usage
239
- * ```js
240
- * replacePlugin({
241
- * 'process.env.NODE_ENV': JSON.stringify('production'),
242
- * __buildVersion: 15
243
- * })
244
- * ```
245
- * @example
246
- * // With options
247
- * ```js
248
- * replacePlugin({
249
- * 'process.env.NODE_ENV': JSON.stringify('production'),
250
- * __buildVersion: 15
251
- * }, {
252
- * preventAssignment: false,
253
- * })
254
- * ```
255
- */
256
- function replacePlugin(values = {}, options = {}) {
257
- Object.keys(values).forEach((key) => {
258
- const value = values[key];
259
- if (typeof value !== "string") values[key] = String(value);
260
- });
261
- return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:replace", {
262
- ...options,
263
- values
264
- }));
265
- }
266
-
267
199
  //#endregion
268
200
  //#region src/builtin-plugin/transform-plugin.ts
269
201
  function transformPlugin(config) {
@@ -294,7 +226,7 @@ function viteCSSPlugin(config) {
294
226
 
295
227
  //#endregion
296
228
  //#region src/experimental-index.ts
297
- var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
229
+ var import_binding = require_binding();
298
230
 
299
231
  //#endregion
300
232
  var BindingRebuildStrategy = import_binding.BindingRebuildStrategy;
@@ -302,5 +234,7 @@ var ResolverFactory = import_binding.ResolverFactory;
302
234
  var isolatedDeclaration = import_binding.isolatedDeclaration;
303
235
  var minify = import_binding.minify;
304
236
  var moduleRunnerTransform = import_binding.moduleRunnerTransform;
237
+ var parseAsync = import_binding.parseAsync;
238
+ var parseSync = import_binding.parseSync;
305
239
  var transform = import_binding.transform;
306
- 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 };
240
+ 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-DdWK1ZyG.mjs";
2
- import "./shared/binding-BHtM7anm.mjs";
1
+ import { k as withFilter } from "./shared/define-config-CYc9_msm.mjs";
2
+ import "./shared/binding-TAvxYaaL.mjs";
3
+ import "./shared/utils-CzdPrevI.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 { n as isPromiseLike, t as arraify } from "./shared/misc-usdOVIou.mjs";
1
+ import { n as isPromiseLike, t as arraify } from "./shared/misc-DpQNcSw4.mjs";
2
2
  import { and, code, exclude, id, include, moduleType, not, or, queries, query } from "@rolldown/pluginutils";
3
3
 
4
4
  //#region src/plugin/with-filter.ts
package/dist/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
- import { $ as InternalModuleFormat, At as SourceMap, B as GetModuleInfo, C as ResolveIdResult, Ct as PartialNull, D as SourceDescription, Dt as RenderedChunk, E as RolldownPluginOption, Et as OutputChunk, F as OutputBundle, Ft as LogLevelOption, G as PluginContextMeta, H as DefineParallelPluginResult, I as TreeshakingOptions, It as LogOrStringHandler, J as ModuleTypeFilter, K as GeneralHookFilter, L as TransformPluginContext, Lt as RollupError, M as ExistingRawSourceMap, Mt as ModuleInfo, N as SourceMapInput, Nt as SourcemapIgnoreListOption, O as TransformResult, Ot as RenderedModule, P as RolldownOptionsFunction, Pt as LogLevel, Q as RolldownFsModule, R as EmittedAsset, Rt as RollupLog, S as ResolveIdExtraOptions, T as RolldownPlugin, Tt as OutputAsset, V as PluginContext, W as MinimalPluginContext, X as RolldownDirectoryEntry, Y as BufferEncoding, Z as RolldownFileStats, _ as ModuleType, _t as GlobalsFunction, a as InputOption, at as RolldownWatcher, b as PartialResolvedId, bt as OutputOptions, c as OptimizationOptions, ct as rolldown, d as CustomPluginOptions, dt as build, et as NormalizedOutputOptions, f as FunctionPluginHooks, ft as AddonFunction, g as ModuleOptions, gt as GeneratedCodePreset, h as LoadResult, ht as GeneratedCodeOptions, i as ExternalOption, it as watch, j as VERSION, kt as RolldownOutput, l as WatcherOptions, lt as RolldownBuild, m as ImportKind, mt as ChunkingContext, n as ConfigExport, nt as LoggingFunction, o as InputOptions, ot as RolldownWatcherEvent, p as HookFilterExtension, pt as ChunkFileNamesFunction, q as HookFilter, r as RolldownOptions, rt as WarningHandlerWithDefault, s as ModuleTypes, st as WatchOptions, t as defineConfig, tt as NormalizedInputOptions, u as AsyncPluginHooks, ut as BuildOptions, v as ObjectHook, vt as MinifyOptions, w as ResolvedId, x as Plugin, xt as PreRenderedAsset, y as ParallelPluginHooks, yt as ModuleFormat, z as EmittedFile, zt as RollupLogWithString } from "./shared/define-config-DdWK1ZyG.mjs";
2
- import { R as PreRenderedChunk, f as BindingMagicString } from "./shared/binding-BHtM7anm.mjs";
1
+ import { $ as NormalizedOutputOptions, A as VERSION, At as LogLevel, B as PluginContext, C as ResolveIdResult, Ct as RenderedChunk, D as SourceDescription, E as RolldownPluginOption, Et as SourceMap, F as TreeshakingOptions, Ft as RollupLogWithString, G as GeneralHookFilter, I as TransformPluginContext, J as BufferEncoding, K as HookFilter, L as EmittedAsset, M as SourceMapInput, Mt as LogOrStringHandler, N as RolldownOptionsFunction, Nt as RollupError, O as TransformResult, Ot as ModuleInfo, P as OutputBundle, Pt as RollupLog, Q as InternalModuleFormat, R as EmittedFile, S as ResolveIdExtraOptions, St as OutputChunk, T as RolldownPlugin, Tt as RolldownOutput, U as MinimalPluginContext, V as DefineParallelPluginResult, W as PluginContextMeta, X as RolldownFileStats, Y as RolldownDirectoryEntry, Z as RolldownFsModule, _ as ModuleType, _t as MinifyOptions, a as InputOption, at as RolldownWatcherEvent, b as PartialResolvedId, bt as PreRenderedAsset, c as OptimizationOptions, ct as RolldownBuild, d as CustomPluginOptions, dt as AddonFunction, et as NormalizedInputOptions, f as FunctionPluginHooks, ft as ChunkFileNamesFunction, g as ModuleOptions, gt as GlobalsFunction, h as LoadResult, ht as GeneratedCodePreset, i as ExternalOption, it as RolldownWatcher, j as ExistingRawSourceMap, jt as LogLevelOption, kt as SourcemapIgnoreListOption, l as WatcherOptions, lt as BuildOptions, m as ImportKind, mt as GeneratedCodeOptions, n as ConfigExport, nt as WarningHandlerWithDefault, o as InputOptions, ot as WatchOptions, p as HookFilterExtension, pt as ChunkingContext, q as ModuleTypeFilter, r as RolldownOptions, rt as watch, s as ModuleTypes, st as rolldown, t as defineConfig, tt as LoggingFunction, u as AsyncPluginHooks, ut as build, v as ObjectHook, vt as ModuleFormat, w as ResolvedId, wt as RenderedModule, x as Plugin, xt as OutputAsset, y as ParallelPluginHooks, yt as OutputOptions, z as GetModuleInfo } from "./shared/define-config-CYc9_msm.mjs";
2
+ import { R as PreRenderedChunk, d as BindingMagicString } from "./shared/binding-TAvxYaaL.mjs";
3
+ import { o as PartialNull } from "./shared/utils-CzdPrevI.mjs";
3
4
  export { AddonFunction, AsyncPluginHooks, BindingMagicString, BufferEncoding, BuildOptions, ChunkFileNamesFunction, ChunkingContext, ConfigExport, CustomPluginOptions, DefineParallelPluginResult, EmittedAsset, EmittedFile, ExistingRawSourceMap, ExternalOption, FunctionPluginHooks, GeneralHookFilter, GeneratedCodeOptions, GeneratedCodePreset, GetModuleInfo, GlobalsFunction, HookFilter, HookFilterExtension, ImportKind, InputOption, InputOptions, InternalModuleFormat, LoadResult, LogLevel, LogLevelOption, LogOrStringHandler, LoggingFunction, MinifyOptions, MinimalPluginContext, ModuleFormat, ModuleInfo, ModuleOptions, ModuleType, ModuleTypeFilter, ModuleTypes, NormalizedInputOptions, NormalizedOutputOptions, ObjectHook, OptimizationOptions, OutputAsset, OutputBundle, OutputChunk, OutputOptions, ParallelPluginHooks, PartialNull, PartialResolvedId, Plugin, PluginContext, PluginContextMeta, PreRenderedAsset, PreRenderedChunk, RenderedChunk, RenderedModule, ResolveIdExtraOptions, ResolveIdResult, ResolvedId, RolldownBuild, RolldownDirectoryEntry, RolldownFileStats, RolldownFsModule, RolldownOptions, RolldownOptionsFunction, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatcher, RolldownWatcherEvent, RollupError, RollupLog, RollupLogWithString, SourceDescription, SourceMap, SourceMapInput, SourcemapIgnoreListOption, TransformPluginContext, TransformResult, TreeshakingOptions, VERSION, WarningHandlerWithDefault, WatchOptions, WatcherOptions, build, defineConfig, rolldown, watch };
package/dist/index.mjs CHANGED
@@ -1,7 +1,9 @@
1
- import "./shared/binding-DBWhurrz.mjs";
2
- import { a as build, i as watch, n as import_binding, o as rolldown, r as defineConfig, t as VERSION } from "./shared/src-BwxUhqZU.mjs";
3
- import "./shared/parse-ast-index-B4DJl5-M.mjs";
4
- import "./shared/misc-usdOVIou.mjs";
1
+ import "./shared/binding-Byz_-zMd.mjs";
2
+ import { a as build, i as watch, n as import_binding, o as rolldown, r as defineConfig, t as VERSION } from "./shared/src-CmBhXIUZ.mjs";
3
+ import "./shared/logs-CSQ_UMWp.mjs";
4
+ import "./shared/normalize-string-or-regex-DpeiLkum.mjs";
5
+ import "./shared/misc-DpQNcSw4.mjs";
6
+ import "./shared/parse-ast-index-C3nalU1P.mjs";
5
7
 
6
8
  var BindingMagicString = import_binding.BindingMagicString;
7
9
  export { BindingMagicString, VERSION, build, defineConfig, rolldown, watch };
@@ -1,11 +1,13 @@
1
- import { n as __toESM, t as require_binding } from "./shared/binding-DBWhurrz.mjs";
2
- import { d as bindingifyPlugin, u as PluginContextData } from "./shared/src-BwxUhqZU.mjs";
3
- import "./shared/parse-ast-index-B4DJl5-M.mjs";
4
- import "./shared/misc-usdOVIou.mjs";
1
+ import { t as require_binding } from "./shared/binding-Byz_-zMd.mjs";
2
+ import { l as PluginContextData, u as bindingifyPlugin } from "./shared/src-CmBhXIUZ.mjs";
3
+ import "./shared/logs-CSQ_UMWp.mjs";
4
+ import "./shared/normalize-string-or-regex-DpeiLkum.mjs";
5
+ import "./shared/misc-DpQNcSw4.mjs";
6
+ import "./shared/parse-ast-index-C3nalU1P.mjs";
5
7
  import { parentPort, workerData } from "node:worker_threads";
6
8
 
7
9
  //#region src/parallel-plugin-worker.ts
8
- var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
10
+ var import_binding = require_binding();
9
11
  const { registryId, pluginInfos, threadNumber } = workerData;
10
12
  (async () => {
11
13
  try {
@@ -1,5 +1,6 @@
1
- import { St as MaybePromise, x as Plugin } from "./shared/define-config-DdWK1ZyG.mjs";
2
- import "./shared/binding-BHtM7anm.mjs";
1
+ import { x as Plugin } from "./shared/define-config-CYc9_msm.mjs";
2
+ import "./shared/binding-TAvxYaaL.mjs";
3
+ import { i as MaybePromise } from "./shared/utils-CzdPrevI.mjs";
3
4
 
4
5
  //#region src/plugin/parallel-plugin-implementation.d.ts
5
6
  type ParallelPluginImplementation = Plugin;
@@ -1,4 +1,4 @@
1
- import { I as ParseResult, L as ParserOptions } from "./shared/binding-BHtM7anm.mjs";
1
+ import { I as ParseResult, L as ParserOptions } from "./shared/binding-TAvxYaaL.mjs";
2
2
  import { Program } from "@oxc-project/types";
3
3
 
4
4
  //#region src/parse-ast-index.d.ts
@@ -1,4 +1,5 @@
1
- import "./shared/binding-DBWhurrz.mjs";
2
- import { n as parseAstAsync, t as parseAst } from "./shared/parse-ast-index-B4DJl5-M.mjs";
1
+ import "./shared/binding-Byz_-zMd.mjs";
2
+ import "./shared/logs-CSQ_UMWp.mjs";
3
+ import { n as parseAstAsync, t as parseAst } from "./shared/parse-ast-index-C3nalU1P.mjs";
3
4
 
4
5
  export { parseAst, parseAstAsync };
@@ -0,0 +1,31 @@
1
+ import { _ as BindingReplacePluginConfig } from "./shared/binding-TAvxYaaL.mjs";
2
+ import { t as BuiltinPlugin } from "./shared/utils-CzdPrevI.mjs";
3
+ import { r as esmExternalRequirePlugin } from "./shared/constructors-DlLr_UMo.mjs";
4
+
5
+ //#region src/builtin-plugin/replace-plugin.d.ts
6
+
7
+ /**
8
+ * Replaces targeted strings in files while bundling.
9
+ *
10
+ * @example
11
+ * // Basic usage
12
+ * ```js
13
+ * replacePlugin({
14
+ * 'process.env.NODE_ENV': JSON.stringify('production'),
15
+ * __buildVersion: 15
16
+ * })
17
+ * ```
18
+ * @example
19
+ * // With options
20
+ * ```js
21
+ * replacePlugin({
22
+ * 'process.env.NODE_ENV': JSON.stringify('production'),
23
+ * __buildVersion: 15
24
+ * }, {
25
+ * preventAssignment: false,
26
+ * })
27
+ * ```
28
+ */
29
+ declare function replacePlugin(values?: BindingReplacePluginConfig["values"], options?: Omit<BindingReplacePluginConfig, "values">): BuiltinPlugin;
30
+ //#endregion
31
+ export { esmExternalRequirePlugin, replacePlugin };
@@ -0,0 +1,41 @@
1
+ import "./shared/binding-Byz_-zMd.mjs";
2
+ import "./shared/logs-CSQ_UMWp.mjs";
3
+ import { i as makeBuiltinPluginCallable, n as BuiltinPlugin } from "./shared/normalize-string-or-regex-DpeiLkum.mjs";
4
+ import { r as esmExternalRequirePlugin } from "./shared/constructors-DLBJKpBt.mjs";
5
+
6
+ //#region src/builtin-plugin/replace-plugin.ts
7
+ /**
8
+ * Replaces targeted strings in files while bundling.
9
+ *
10
+ * @example
11
+ * // Basic usage
12
+ * ```js
13
+ * replacePlugin({
14
+ * 'process.env.NODE_ENV': JSON.stringify('production'),
15
+ * __buildVersion: 15
16
+ * })
17
+ * ```
18
+ * @example
19
+ * // With options
20
+ * ```js
21
+ * replacePlugin({
22
+ * 'process.env.NODE_ENV': JSON.stringify('production'),
23
+ * __buildVersion: 15
24
+ * }, {
25
+ * preventAssignment: false,
26
+ * })
27
+ * ```
28
+ */
29
+ function replacePlugin(values = {}, options = {}) {
30
+ Object.keys(values).forEach((key) => {
31
+ const value = values[key];
32
+ if (typeof value !== "string") values[key] = String(value);
33
+ });
34
+ return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:replace", {
35
+ ...options,
36
+ values
37
+ }));
38
+ }
39
+
40
+ //#endregion
41
+ export { esmExternalRequirePlugin, replacePlugin };