@rolldown/browser 1.0.0-beta.46 → 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 (39) hide show
  1. package/dist/cli-setup.mjs +3 -4
  2. package/dist/cli.mjs +22 -10
  3. package/dist/config.d.mts +3 -2
  4. package/dist/config.mjs +6 -5
  5. package/dist/constructors-EhfoQfqh.js +68 -0
  6. package/dist/experimental-index.browser.mjs +38 -117
  7. package/dist/experimental-index.d.mts +18 -58
  8. package/dist/experimental-index.mjs +41 -120
  9. package/dist/filter-index.d.mts +3 -2
  10. package/dist/filter-index.mjs +1 -1
  11. package/dist/index.browser.mjs +2 -2
  12. package/dist/index.d.mts +3 -2
  13. package/dist/index.mjs +5 -5
  14. package/dist/{shared/parse-ast-index-DMI5m8Lk.mjs → normalize-string-or-regex-d47jXr3r.js} +38 -110
  15. package/dist/parallel-plugin-worker.mjs +7 -6
  16. package/dist/parallel-plugin.d.mts +3 -2
  17. package/dist/parse-ast-index.d.mts +1 -1
  18. package/dist/parse-ast-index.mjs +2 -2
  19. package/dist/plugins-index.browser.mjs +39 -0
  20. package/dist/plugins-index.d.mts +31 -0
  21. package/dist/plugins-index.mjs +40 -0
  22. package/dist/rolldown-binding.wasi-browser.js +1 -1
  23. package/dist/rolldown-binding.wasi.cjs +1 -1
  24. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  25. package/dist/shared/{binding-CCMrV5an.d.mts → binding-B4uTNiw2.d.mts} +49 -58
  26. package/dist/shared/constructors-CaN9lKj2.d.mts +32 -0
  27. package/dist/shared/constructors-DcEzB0nc.mjs +68 -0
  28. package/dist/shared/{define-config-Bj-neIhz.d.mts → define-config-Dv3i4cxM.d.mts} +4 -62
  29. package/dist/shared/{load-config-DnUAKl9P.mjs → load-config-B-QIvCpC.mjs} +2 -2
  30. package/dist/shared/logs-CPsamAuj.mjs +181 -0
  31. package/dist/shared/normalize-string-or-regex-CbDij6KB.mjs +46 -0
  32. package/dist/shared/parse-ast-index-D9jH_38U.mjs +81 -0
  33. package/dist/shared/{prompt-YGfbLmz5.mjs → prompt-Ckjl2FdJ.mjs} +1 -1
  34. package/dist/shared/{src-B8saaB3b.mjs → src-CvsuRKGv.mjs} +247 -224
  35. package/dist/shared/utils-CduIqa7h.d.mts +18 -0
  36. package/dist/{src-B-7Hrt6w.js → src-DLQqj5Wo.js} +234 -994
  37. package/package.json +1 -1
  38. package/dist/shared/binding-BeWSOIj5.mjs +0 -578
  39. /package/dist/shared/{composable-filters-CgRsnfr3.mjs → composable-filters-CBpK2Fbc.mjs} +0 -0
@@ -1,11 +1,13 @@
1
- import { n as __toESM, t as require_binding } from "./shared/binding-BeWSOIj5.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-B8saaB3b.mjs";
3
- import "./shared/parse-ast-index-DMI5m8Lk.mjs";
4
- import "./shared/composable-filters-CgRsnfr3.mjs";
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
8
- var import_binding$1 = /* @__PURE__ */ __toESM(require_binding(), 1);
9
11
  var DevEngine = class DevEngine {
10
12
  #inner;
11
13
  #cachedBuildFinishPromise = null;
@@ -36,7 +38,7 @@ var DevEngine = class DevEngine {
36
38
  }
37
39
  userOnOutput(transformToRollupOutput(result));
38
40
  } : 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,
41
+ rebuildStrategy: devOptions.rebuildStrategy ? devOptions.rebuildStrategy === "always" ? BindingRebuildStrategy$1.Always : devOptions.rebuildStrategy === "auto" ? BindingRebuildStrategy$1.Auto : BindingRebuildStrategy$1.Never : void 0,
40
42
  watch: devOptions.watch && {
41
43
  skipWrite: devOptions.watch.skipWrite,
42
44
  usePolling: devOptions.watch.usePolling,
@@ -47,7 +49,7 @@ var DevEngine = class DevEngine {
47
49
  debounceTickRate: devOptions.watch.debounceTickRate
48
50
  }
49
51
  };
50
- return new DevEngine(new import_binding$1.BindingDevEngine(options.bundlerOptions, bindingDevOptions));
52
+ return new DevEngine(new BindingDevEngine(options.bundlerOptions, bindingDevOptions));
51
53
  }
52
54
  constructor(inner) {
53
55
  this.#inner = inner;
@@ -131,17 +133,42 @@ function freeExternalMemory(handle, keepDataAlive = false) {
131
133
  //#endregion
132
134
  //#region src/api/experimental.ts
133
135
  /**
134
- * 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.
135
137
  *
136
- * 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
+ * ```
137
149
  */
138
- const scan = async (input) => {
139
- 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();
140
163
  try {
141
- await build.scan();
164
+ unwrapBindingResult(await bundler.scan(ret.bundlerOptions));
165
+ } catch (err) {
166
+ await cleanup();
167
+ throw err;
142
168
  } finally {
143
- await build.close();
169
+ cleanupPromise = cleanup();
144
170
  }
171
+ return cleanupPromise;
145
172
  };
146
173
 
147
174
  //#endregion
@@ -155,68 +182,6 @@ function defineParallelPlugin(pluginPath) {
155
182
  };
156
183
  }
157
184
 
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
185
  //#endregion
221
186
  //#region src/builtin-plugin/alias-plugin.ts
222
187
  function aliasPlugin(config) {
@@ -229,41 +194,6 @@ function assetPlugin(config) {
229
194
  return new BuiltinPlugin("builtin:asset", config);
230
195
  }
231
196
 
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
197
  //#endregion
268
198
  //#region src/builtin-plugin/transform-plugin.ts
269
199
  function transformPlugin(config) {
@@ -293,13 +223,4 @@ function viteCSSPlugin(config) {
293
223
  }
294
224
 
295
225
  //#endregion
296
- //#region src/experimental-index.ts
297
- var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
298
-
299
- //#endregion
300
- var BindingRebuildStrategy = import_binding.BindingRebuildStrategy;
301
- var ResolverFactory = import_binding.ResolverFactory;
302
- var isolatedDeclaration = import_binding.isolatedDeclaration;
303
- var moduleRunnerTransform = import_binding.moduleRunnerTransform;
304
- var transform = import_binding.transform;
305
- export { BindingRebuildStrategy, DevEngine, ResolverFactory, aliasPlugin, assetPlugin, buildImportAnalysisPlugin, defineParallelPlugin, dev, dynamicImportVarsPlugin, esmExternalRequirePlugin, freeExternalMemory, importGlobPlugin, isolatedDeclaration, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, 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-Bj-neIhz.mjs";
2
- import "./shared/binding-CCMrV5an.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-CgRsnfr3.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,4 +1,4 @@
1
- import { a as build, i as watch, n as import_binding, o as rolldown, r as defineConfig, t as VERSION } from "./src-B-7Hrt6w.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
- var BindingMagicString = import_binding.BindingMagicString;
4
4
  export { BindingMagicString, VERSION, build, defineConfig, rolldown, watch };
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-Bj-neIhz.mjs";
2
- import { L as PreRenderedChunk, f as BindingMagicString } from "./shared/binding-CCMrV5an.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-Dv3i4cxM.mjs";
2
+ import { R as PreRenderedChunk, d as BindingMagicString } from "./shared/binding-B4uTNiw2.mjs";
3
+ import { o as PartialNull } from "./shared/utils-CduIqa7h.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,7 @@
1
- import "./shared/binding-BeWSOIj5.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-B8saaB3b.mjs";
3
- import "./shared/parse-ast-index-DMI5m8Lk.mjs";
4
- import "./shared/composable-filters-CgRsnfr3.mjs";
1
+ import { a as build, i as watch, n as VERSION, o as rolldown, r as defineConfig, t as BindingMagicString } 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";
5
6
 
6
- var BindingMagicString = import_binding.BindingMagicString;
7
7
  export { BindingMagicString, VERSION, build, defineConfig, rolldown, watch };
@@ -1,5 +1,4 @@
1
- import { n as __toESM, t as require_binding } from "./binding-BeWSOIj5.mjs";
2
- import { styleText } from "node:util";
1
+ import { BindingCallableBuiltinPlugin } from "./rolldown-binding.wasi-browser.js";
3
2
 
4
3
  //#region src/utils/code-frame.ts
5
4
  function spaces(index) {
@@ -39,17 +38,6 @@ function getCodeFrame(source, line, column) {
39
38
  }).join("\n");
40
39
  }
41
40
 
42
- //#endregion
43
- //#region src/utils/style-text.ts
44
- /**
45
- * Cross-platform styleText utility that works in both Node.js and browser environments
46
- * In Node.js, it uses the native `styleText` from `node:util`
47
- * In browser, it provides empty styling functions for compatibility
48
- */
49
- function styleText$1(...args) {
50
- return styleText(...args);
51
- }
52
-
53
41
  //#endregion
54
42
  //#region src/log/locate-character/index.js
55
43
  /** @typedef {import('./types').Location} Location */
@@ -113,7 +101,7 @@ function locate(source, search, options) {
113
101
 
114
102
  //#endregion
115
103
  //#region src/log/logs.ts
116
- const INVALID_LOG_POSITION = "INVALID_LOG_POSITION", PLUGIN_ERROR = "PLUGIN_ERROR", INPUT_HOOK_IN_OUTPUT_PLUGIN = "INPUT_HOOK_IN_OUTPUT_PLUGIN", CYCLE_LOADING = "CYCLE_LOADING", MULTIPLY_NOTIFY_OPTION = "MULTIPLY_NOTIFY_OPTION", PARSE_ERROR = "PARSE_ERROR", NO_FS_IN_BROWSER = "NO_FS_IN_BROWSER", DEPRECATED_DEFINE = "DEPRECATED_DEFINE", DEPRECATED_INJECT = "DEPRECATED_INJECT", DEPRECATED_PROFILER_NAMES = "DEPRECATED_PROFILER_NAMES", DEPRECATED_KEEP_NAMES = "DEPRECATED_KEEP_NAMES", DEPRECATED_DROP_LABELS = "DEPRECATED_DROP_LABELS";
104
+ const INVALID_LOG_POSITION = "INVALID_LOG_POSITION", PLUGIN_ERROR = "PLUGIN_ERROR", INPUT_HOOK_IN_OUTPUT_PLUGIN = "INPUT_HOOK_IN_OUTPUT_PLUGIN", CYCLE_LOADING = "CYCLE_LOADING", MULTIPLY_NOTIFY_OPTION = "MULTIPLY_NOTIFY_OPTION", PARSE_ERROR = "PARSE_ERROR", NO_FS_IN_BROWSER = "NO_FS_IN_BROWSER";
117
105
  function logParseError(message) {
118
106
  return {
119
107
  code: PARSE_ERROR,
@@ -144,34 +132,10 @@ function logMultiplyNotifyOption() {
144
132
  message: `Found multiply notify option at watch options, using first one to start notify watcher.`
145
133
  };
146
134
  }
147
- function logDeprecatedDefine() {
148
- return {
149
- code: DEPRECATED_DEFINE,
150
- message: `${styleText$1(["yellow", "bold"], "⚠ Deprecation Warning:")} The top-level "define" option is deprecated. Use "transform.define" instead.`
151
- };
152
- }
153
- function logDeprecatedInject() {
154
- return {
155
- code: DEPRECATED_INJECT,
156
- message: `${styleText$1(["yellow", "bold"], "⚠ Deprecation Warning:")} The top-level "inject" option is deprecated. Use "transform.inject" instead.`
157
- };
158
- }
159
- function logDeprecatedProfilerNames() {
160
- return {
161
- code: DEPRECATED_PROFILER_NAMES,
162
- message: "The top-level \"profilerNames\" option is deprecated. Use \"output.generatedCode.profilerNames\" instead."
163
- };
164
- }
165
- function logDeprecatedKeepNames() {
135
+ function logNoFileSystemInBrowser(method) {
166
136
  return {
167
- code: DEPRECATED_KEEP_NAMES,
168
- message: "The top-level \"keepNames\" option is deprecated. Use \"output.keepNames\" instead."
169
- };
170
- }
171
- function logDeprecatedDropLabels() {
172
- return {
173
- code: DEPRECATED_DROP_LABELS,
174
- message: `${styleText$1(["yellow", "bold"], "⚠ Deprecation Warning:")} The top-level "dropLabels" option is deprecated. Use "transform.dropLabels" instead.`
137
+ code: NO_FS_IN_BROWSER,
138
+ message: `Cannot access the file system (via "${method}") when using the browser build of Rolldown.`
175
139
  };
176
140
  }
177
141
  function logPluginError(error$1, plugin, { hook, id } = {}) {
@@ -222,82 +186,46 @@ function augmentCodeLocation(properties, pos, source, id) {
222
186
  }
223
187
 
224
188
  //#endregion
225
- //#region ../../node_modules/.pnpm/oxc-parser@0.96.0/node_modules/oxc-parser/src-js/wrap.js
226
- function wrap$1(result) {
227
- let program, module, comments, errors;
228
- return {
229
- get program() {
230
- if (!program) program = jsonParseAst(result.program);
231
- return program;
232
- },
233
- get module() {
234
- if (!module) module = result.module;
235
- return module;
236
- },
237
- get comments() {
238
- if (!comments) comments = result.comments;
239
- return comments;
240
- },
241
- get errors() {
242
- if (!errors) errors = result.errors;
243
- return errors;
189
+ //#region src/builtin-plugin/utils.ts
190
+ var BuiltinPlugin = class {
191
+ constructor(name, _options) {
192
+ this.name = name;
193
+ this._options = _options;
194
+ }
195
+ };
196
+ function makeBuiltinPluginCallable(plugin) {
197
+ let callablePlugin = new BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
198
+ const wrappedPlugin = plugin;
199
+ for (const key in callablePlugin) wrappedPlugin[key] = async function(...args) {
200
+ try {
201
+ return await callablePlugin[key](...args);
202
+ } catch (e) {
203
+ if (e instanceof Error && !e.stack?.includes("at ")) Error.captureStackTrace(e, wrappedPlugin[key]);
204
+ return error(logPluginError(e, plugin.name, {
205
+ hook: key,
206
+ id: key === "transform" ? args[2] : void 0
207
+ }));
244
208
  }
245
209
  };
210
+ return wrappedPlugin;
246
211
  }
247
- function jsonParseAst(programJson) {
248
- const { node: program, fixes } = JSON.parse(programJson);
249
- for (const fixPath of fixes) applyFix(program, fixPath);
250
- return program;
251
- }
252
- function applyFix(program, fixPath) {
253
- let node = program;
254
- for (const key of fixPath) node = node[key];
255
- if (node.bigint) node.value = BigInt(node.bigint);
256
- else try {
257
- node.value = RegExp(node.regex.pattern, node.regex.flags);
258
- } catch {}
212
+ function bindingifyBuiltInPlugin(plugin) {
213
+ return {
214
+ __name: plugin.name,
215
+ options: plugin._options
216
+ };
259
217
  }
260
218
 
261
219
  //#endregion
262
- //#region src/parse-ast-index.ts
263
- var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
264
- function wrap(result, sourceText) {
265
- result = wrap$1(result);
266
- if (result.errors.length > 0) return normalizeParseError(sourceText, result.errors);
267
- return result.program;
268
- }
269
- function normalizeParseError(sourceText, errors) {
270
- let message = `Parse failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
271
- for (let i = 0; i < errors.length; i++) {
272
- if (i >= 5) {
273
- message += "\n...";
274
- break;
275
- }
276
- const e = errors[i];
277
- message += e.message + "\n" + e.labels.map((label) => {
278
- const location = locate(sourceText, label.start, { offsetLine: 1 });
279
- if (!location) return;
280
- return getCodeFrame(sourceText, location.line, location.column);
281
- }).filter(Boolean).join("\n");
282
- }
283
- return error(logParseError(message));
284
- }
285
- const defaultParserOptions = {
286
- lang: "js",
287
- preserveParens: false
288
- };
289
- function parseAst(sourceText, options, filename) {
290
- return wrap((0, import_binding.parseSync)(filename ?? "file.js", sourceText, {
291
- ...defaultParserOptions,
292
- ...options
293
- }), sourceText);
220
+ //#region src/utils/normalize-string-or-regex.ts
221
+ function normalizedStringOrRegex(pattern) {
222
+ if (!pattern) return;
223
+ if (!isReadonlyArray(pattern)) return [pattern];
224
+ return pattern;
294
225
  }
295
- async function parseAstAsync(sourceText, options, filename) {
296
- return wrap(await (0, import_binding.parseAsync)(filename ?? "file.js", sourceText, {
297
- ...defaultParserOptions,
298
- ...options
299
- }), sourceText);
226
+ function isReadonlyArray(input) {
227
+ return Array.isArray(input);
300
228
  }
301
229
 
302
230
  //#endregion
303
- export { logCycleLoading as a, logDeprecatedInject as c, logInputHookInOutputPlugin as d, logInvalidLogPosition as f, styleText$1 as h, error as i, logDeprecatedKeepNames as l, logPluginError as m, parseAstAsync as n, logDeprecatedDefine as o, logMultiplyNotifyOption as p, augmentCodeLocation as r, logDeprecatedDropLabels as s, parseAst as t, logDeprecatedProfilerNames as u };
231
+ export { augmentCodeLocation as a, logInputHookInOutputPlugin as c, logNoFileSystemInBrowser as d, logParseError as f, getCodeFrame as h, makeBuiltinPluginCallable as i, logInvalidLogPosition as l, locate as m, BuiltinPlugin as n, error as o, logPluginError as p, bindingifyBuiltInPlugin as r, logCycleLoading as s, normalizedStringOrRegex as t, logMultiplyNotifyOption as u };
@@ -1,15 +1,16 @@
1
- import { n as __toESM, t as require_binding } from "./shared/binding-BeWSOIj5.mjs";
2
- import { d as bindingifyPlugin, u as PluginContextData } from "./shared/src-B8saaB3b.mjs";
3
- import "./shared/parse-ast-index-DMI5m8Lk.mjs";
4
- import "./shared/composable-filters-CgRsnfr3.mjs";
1
+ import { l as PluginContextData, u as bindingifyPlugin } 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";
5
6
  import { parentPort, workerData } from "node:worker_threads";
7
+ import { registerPlugins } from "./rolldown-binding.wasi.cjs";
6
8
 
7
9
  //#region src/parallel-plugin-worker.ts
8
- var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
9
10
  const { registryId, pluginInfos, threadNumber } = workerData;
10
11
  (async () => {
11
12
  try {
12
- (0, import_binding.registerPlugins)(registryId, await Promise.all(pluginInfos.map(async (pluginInfo) => {
13
+ registerPlugins(registryId, await Promise.all(pluginInfos.map(async (pluginInfo) => {
13
14
  const definePluginImpl = (await import(pluginInfo.fileUrl)).default;
14
15
  const plugin = await definePluginImpl(pluginInfo.options, { threadNumber });
15
16
  return {
@@ -1,5 +1,6 @@
1
- import { St as MaybePromise, x as Plugin } from "./shared/define-config-Bj-neIhz.mjs";
2
- import "./shared/binding-CCMrV5an.mjs";
1
+ import { x as Plugin } from "./shared/define-config-Dv3i4cxM.mjs";
2
+ import "./shared/binding-B4uTNiw2.mjs";
3
+ import { i as MaybePromise } from "./shared/utils-CduIqa7h.mjs";
3
4
 
4
5
  //#region src/plugin/parallel-plugin-implementation.d.ts
5
6
  type ParallelPluginImplementation = Plugin;
@@ -1,4 +1,4 @@
1
- import { F as ParseResult, I as ParserOptions } from "./shared/binding-CCMrV5an.mjs";
1
+ import { I as ParseResult, L as ParserOptions } from "./shared/binding-B4uTNiw2.mjs";
2
2
  import { Program } from "@oxc-project/types";
3
3
 
4
4
  //#region src/parse-ast-index.d.ts
@@ -1,4 +1,4 @@
1
- import "./shared/binding-BeWSOIj5.mjs";
2
- import { n as parseAstAsync, t as parseAst } from "./shared/parse-ast-index-DMI5m8Lk.mjs";
1
+ import "./shared/logs-CPsamAuj.mjs";
2
+ import { n as parseAstAsync, t as parseAst } from "./shared/parse-ast-index-D9jH_38U.mjs";
3
3
 
4
4
  export { parseAst, parseAstAsync };
@@ -0,0 +1,39 @@
1
+ import { i as makeBuiltinPluginCallable, n as BuiltinPlugin } from "./normalize-string-or-regex-d47jXr3r.js";
2
+ import { r as esmExternalRequirePlugin } from "./constructors-EhfoQfqh.js";
3
+
4
+ //#region src/builtin-plugin/replace-plugin.ts
5
+ /**
6
+ * Replaces targeted strings in files while bundling.
7
+ *
8
+ * @example
9
+ * // Basic usage
10
+ * ```js
11
+ * replacePlugin({
12
+ * 'process.env.NODE_ENV': JSON.stringify('production'),
13
+ * __buildVersion: 15
14
+ * })
15
+ * ```
16
+ * @example
17
+ * // With options
18
+ * ```js
19
+ * replacePlugin({
20
+ * 'process.env.NODE_ENV': JSON.stringify('production'),
21
+ * __buildVersion: 15
22
+ * }, {
23
+ * preventAssignment: false,
24
+ * })
25
+ * ```
26
+ */
27
+ function replacePlugin(values = {}, options = {}) {
28
+ Object.keys(values).forEach((key) => {
29
+ const value = values[key];
30
+ if (typeof value !== "string") values[key] = String(value);
31
+ });
32
+ return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:replace", {
33
+ ...options,
34
+ values
35
+ }));
36
+ }
37
+
38
+ //#endregion
39
+ export { esmExternalRequirePlugin, replacePlugin };
@@ -0,0 +1,31 @@
1
+ import { _ as BindingReplacePluginConfig } from "./shared/binding-B4uTNiw2.mjs";
2
+ import { t as BuiltinPlugin } from "./shared/utils-CduIqa7h.mjs";
3
+ import { r as esmExternalRequirePlugin } from "./shared/constructors-CaN9lKj2.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,40 @@
1
+ import "./shared/logs-CPsamAuj.mjs";
2
+ import { i as makeBuiltinPluginCallable, n as BuiltinPlugin } from "./shared/normalize-string-or-regex-CbDij6KB.mjs";
3
+ import { r as esmExternalRequirePlugin } from "./shared/constructors-DcEzB0nc.mjs";
4
+
5
+ //#region src/builtin-plugin/replace-plugin.ts
6
+ /**
7
+ * Replaces targeted strings in files while bundling.
8
+ *
9
+ * @example
10
+ * // Basic usage
11
+ * ```js
12
+ * replacePlugin({
13
+ * 'process.env.NODE_ENV': JSON.stringify('production'),
14
+ * __buildVersion: 15
15
+ * })
16
+ * ```
17
+ * @example
18
+ * // With options
19
+ * ```js
20
+ * replacePlugin({
21
+ * 'process.env.NODE_ENV': JSON.stringify('production'),
22
+ * __buildVersion: 15
23
+ * }, {
24
+ * preventAssignment: false,
25
+ * })
26
+ * ```
27
+ */
28
+ function replacePlugin(values = {}, options = {}) {
29
+ Object.keys(values).forEach((key) => {
30
+ const value = values[key];
31
+ if (typeof value !== "string") values[key] = String(value);
32
+ });
33
+ return makeBuiltinPluginCallable(new BuiltinPlugin("builtin:replace", {
34
+ ...options,
35
+ values
36
+ }));
37
+ }
38
+
39
+ //#endregion
40
+ export { esmExternalRequirePlugin, replacePlugin };
@@ -85,7 +85,6 @@ export const transformAsync = __napiModule.exports.transformAsync
85
85
  export const BindingBundleEndEventData = __napiModule.exports.BindingBundleEndEventData
86
86
  export const BindingBundleErrorEventData = __napiModule.exports.BindingBundleErrorEventData
87
87
  export const BindingBundler = __napiModule.exports.BindingBundler
88
- export const BindingBundlerImpl = __napiModule.exports.BindingBundlerImpl
89
88
  export const BindingCallableBuiltinPlugin = __napiModule.exports.BindingCallableBuiltinPlugin
90
89
  export const BindingChunkingContext = __napiModule.exports.BindingChunkingContext
91
90
  export const BindingDevEngine = __napiModule.exports.BindingDevEngine
@@ -101,6 +100,7 @@ export const BindingRenderedModule = __napiModule.exports.BindingRenderedModule
101
100
  export const BindingTransformPluginContext = __napiModule.exports.BindingTransformPluginContext
102
101
  export const BindingUrlResolver = __napiModule.exports.BindingUrlResolver
103
102
  export const BindingWatcher = __napiModule.exports.BindingWatcher
103
+ export const BindingWatcherBundler = __napiModule.exports.BindingWatcherBundler
104
104
  export const BindingWatcherChangeData = __napiModule.exports.BindingWatcherChangeData
105
105
  export const BindingWatcherEvent = __napiModule.exports.BindingWatcherEvent
106
106
  export const ParallelJsPluginRegistry = __napiModule.exports.ParallelJsPluginRegistry