@rolldown/browser 1.0.0-beta.45 → 1.0.0-beta.46

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.
@@ -1,6 +1,6 @@
1
1
  import * as _oxc_project_types0 from "@oxc-project/types";
2
2
 
3
- //#region src/binding.d.ts
3
+ //#region src/binding.d.cts
4
4
  type MaybePromise<T> = T | Promise<T>;
5
5
  type VoidNullable<T = void> = T | null | undefined | void;
6
6
  type BindingStringOrRegex = string | RegExp;
@@ -67,6 +67,14 @@ interface CompressOptions {
67
67
  * @default true
68
68
  */
69
69
  sequences?: boolean;
70
+ /**
71
+ * Set of label names to drop from the code.
72
+ *
73
+ * Labeled statements matching these names will be removed during minification.
74
+ *
75
+ * @default []
76
+ */
77
+ dropLabels?: Array<string>;
70
78
  /** Limit the maximum number of iterations for debugging purpose. */
71
79
  maxIterations?: number;
72
80
  }
@@ -1198,28 +1206,30 @@ declare class BindingMagicString {
1198
1206
  isEmpty(): boolean;
1199
1207
  }
1200
1208
  declare class BindingOutputAsset {
1201
- get fileName(): string;
1202
- get originalFileName(): string | null;
1203
- get originalFileNames(): Array<string>;
1204
- get source(): BindingAssetSource;
1205
- get name(): string | null;
1206
- get names(): Array<string>;
1209
+ dropInner(): ExternalMemoryStatus;
1210
+ getFileName(): string;
1211
+ getOriginalFileName(): string | null;
1212
+ getOriginalFileNames(): Array<string>;
1213
+ getSource(): BindingAssetSource;
1214
+ getName(): string | null;
1215
+ getNames(): Array<string>;
1207
1216
  }
1208
1217
  declare class BindingOutputChunk {
1209
- get isEntry(): boolean;
1210
- get isDynamicEntry(): boolean;
1211
- get facadeModuleId(): string | null;
1212
- get moduleIds(): Array<string>;
1213
- get exports(): Array<string>;
1214
- get fileName(): string;
1215
- get modules(): BindingModules;
1216
- get imports(): Array<string>;
1217
- get dynamicImports(): Array<string>;
1218
- get code(): string;
1219
- get map(): string | null;
1220
- get sourcemapFileName(): string | null;
1221
- get preliminaryFileName(): string;
1222
- get name(): string;
1218
+ dropInner(): ExternalMemoryStatus;
1219
+ getIsEntry(): boolean;
1220
+ getIsDynamicEntry(): boolean;
1221
+ getFacadeModuleId(): string | null;
1222
+ getModuleIds(): Array<string>;
1223
+ getExports(): Array<string>;
1224
+ getFileName(): string;
1225
+ getModules(): BindingModules;
1226
+ getImports(): Array<string>;
1227
+ getDynamicImports(): Array<string>;
1228
+ getCode(): string;
1229
+ getMap(): string | null;
1230
+ getSourcemapFileName(): string | null;
1231
+ getPreliminaryFileName(): string;
1232
+ getName(): string;
1223
1233
  }
1224
1234
  declare class BindingRenderedChunk {
1225
1235
  get name(): string;
@@ -1272,6 +1282,7 @@ interface BindingBuildImportAnalysisPluginConfig {
1272
1282
  optimizeModulePreloadRelativePaths: boolean;
1273
1283
  renderBuiltUrl: boolean;
1274
1284
  isRelativeBase: boolean;
1285
+ isTestV2?: boolean;
1275
1286
  }
1276
1287
  type BindingBuiltinPluginName = 'builtin:alias' | 'builtin:asset' | 'builtin:asset-import-meta-url' | 'builtin:build-import-analysis' | 'builtin:dynamic-import-vars' | 'builtin:esm-external-require' | 'builtin:import-glob' | 'builtin:isolated-declaration' | 'builtin:json' | 'builtin:load-fallback' | 'builtin:manifest' | 'builtin:module-preload-polyfill' | 'builtin:react-refresh-wrapper' | 'builtin:reporter' | 'builtin:replace' | 'builtin:transform' | 'builtin:vite-css' | 'builtin:vite-css-post' | 'builtin:vite-html' | 'builtin:vite-resolve' | 'builtin:wasm-fallback' | 'builtin:wasm-helper' | 'builtin:web-worker-post';
1277
1288
  interface BindingClientHmrUpdate {
@@ -1495,6 +1506,10 @@ interface BindingViteResolvePluginResolveOptions {
1495
1506
  interface BindingWasmHelperPluginConfig {
1496
1507
  decodedBase: string;
1497
1508
  }
1509
+ interface ExternalMemoryStatus {
1510
+ freed: boolean;
1511
+ reason?: string;
1512
+ }
1498
1513
  /** Error emitted from native side, it only contains kind and message, no stack trace. */
1499
1514
  interface NativeError {
1500
1515
  kind: string;
@@ -1509,4 +1524,4 @@ interface PreRenderedChunk {
1509
1524
  exports: Array<string>;
1510
1525
  }
1511
1526
  //#endregion
1512
- export { IsolatedDeclarationsResult as A, TransformResult as B, BindingViteCssPluginConfig as C, BindingWasmHelperPluginConfig as D, BindingViteResolvePluginConfig as E, ParserOptions as F, moduleRunnerTransform as H, PreRenderedChunk as I, ResolveResult as L, MinifyOptions as M, NapiResolveOptions as N, BindingWatcherEvent as O, ParseResult as P, ResolverFactory as R, BindingUrlResolver as S, BindingViteHtmlPluginConfig as T, transform as U, isolatedDeclaration as V, BindingRenderedChunk as _, BindingClientHmrUpdate as a, BindingTransformHookExtraArgs as b, BindingHookResolveIdExtraArgs as c, BindingJsonPluginConfig as d, BindingMagicString as f, BindingRebuildStrategy as g, BindingReactRefreshWrapperPluginConfig as h, BindingBundlerImpl as i, JsxOptions as j, IsolatedDeclarationsOptions as k, BindingImportGlobPluginConfig as l, BindingModulePreloadPolyfillPluginConfig as m, BindingBuildImportAnalysisPluginConfig as n, BindingDynamicImportVarsPluginConfig as o, BindingManifestPluginConfig as p, BindingBuiltinPluginName as r, BindingEsmExternalRequirePluginConfig as s, BindingAssetPluginConfig as t, BindingIsolatedDeclarationPluginConfig as u, BindingReplacePluginConfig as v, BindingViteCssPostPluginConfig as w, BindingTransformPluginConfig as x, BindingReporterPluginConfig as y, TransformOptions as z };
1527
+ export { IsolatedDeclarationsOptions as A, TransformOptions as B, BindingViteCssPluginConfig as C, BindingWasmHelperPluginConfig as D, BindingViteResolvePluginConfig as E, ParseResult as F, isolatedDeclaration as H, ParserOptions as I, PreRenderedChunk as L, JsxOptions as M, MinifyOptions as N, BindingWatcherEvent as O, NapiResolveOptions as P, ResolveResult as R, BindingUrlResolver as S, BindingViteHtmlPluginConfig as T, moduleRunnerTransform as U, TransformResult as V, transform as W, BindingRenderedChunk as _, BindingClientHmrUpdate as a, BindingTransformHookExtraArgs as b, BindingHookResolveIdExtraArgs as c, BindingJsonPluginConfig as d, BindingMagicString as f, BindingRebuildStrategy as g, BindingReactRefreshWrapperPluginConfig as h, BindingBundlerImpl as i, IsolatedDeclarationsResult as j, ExternalMemoryStatus as k, BindingImportGlobPluginConfig as l, BindingModulePreloadPolyfillPluginConfig as m, BindingBuildImportAnalysisPluginConfig as n, BindingDynamicImportVarsPluginConfig as o, BindingManifestPluginConfig as p, BindingBuiltinPluginName as r, BindingEsmExternalRequirePluginConfig as s, BindingAssetPluginConfig as t, BindingIsolatedDeclarationPluginConfig as u, BindingReplacePluginConfig as v, BindingViteCssPostPluginConfig as w, BindingTransformPluginConfig as x, BindingReporterPluginConfig as y, ResolverFactory as z };
@@ -1,4 +1,4 @@
1
- import { F as ParserOptions, I as PreRenderedChunk, M as MinifyOptions$1, O as BindingWatcherEvent, _ as BindingRenderedChunk, b as BindingTransformHookExtraArgs, c as BindingHookResolveIdExtraArgs, f as BindingMagicString, i as BindingBundlerImpl, j as JsxOptions, r as BindingBuiltinPluginName, z as TransformOptions$1 } from "./binding-DRegrFdE.mjs";
1
+ import { B as TransformOptions$1, I as ParserOptions, L as PreRenderedChunk, M as JsxOptions, N as MinifyOptions$1, O as BindingWatcherEvent, _ as BindingRenderedChunk, b as BindingTransformHookExtraArgs, c as BindingHookResolveIdExtraArgs, f as BindingMagicString, i as BindingBundlerImpl, k as ExternalMemoryStatus, r as BindingBuiltinPluginName } from "./binding-CCMrV5an.mjs";
2
2
  import { Program } from "@oxc-project/types";
3
3
  import { TopLevelFilterExpression } from "@rolldown/pluginutils";
4
4
 
@@ -61,8 +61,59 @@ interface ModuleInfo extends ModuleOptions {
61
61
  //#region src/utils/asset-source.d.ts
62
62
  type AssetSource = string | Uint8Array;
63
63
  //#endregion
64
+ //#region src/types/external-memory-handle.d.ts
65
+ declare const symbolForExternalMemoryHandle: "__rolldown_external_memory_handle__";
66
+ /**
67
+ * Interface for objects that hold external memory that can be explicitly freed.
68
+ */
69
+ interface ExternalMemoryHandle {
70
+ /**
71
+ * Frees the external memory held by this object.
72
+ * @param keepDataAlive - If true, evaluates all lazy fields before freeing memory.
73
+ * This will take time but prevents errors when accessing properties after freeing.
74
+ * @returns Status object with `freed` boolean and optional `reason` string.
75
+ * @internal
76
+ */
77
+ [symbolForExternalMemoryHandle]: (keepDataAlive?: boolean) => ExternalMemoryStatus;
78
+ }
79
+ /**
80
+ * Frees the external memory held by the given handle.
81
+ *
82
+ * This is useful when you want to manually release memory held by Rust objects
83
+ * (like `OutputChunk` or `OutputAsset`) before they are garbage collected.
84
+ *
85
+ * @param handle - The object with external memory to free
86
+ * @param keepDataAlive - If true, evaluates all lazy fields before freeing memory (default: false).
87
+ * This will take time to copy data from Rust to JavaScript, but prevents errors
88
+ * when accessing properties after the memory is freed.
89
+ * @returns Status object with `freed` boolean and optional `reason` string.
90
+ * - `{ freed: true }` if memory was successfully freed
91
+ * - `{ freed: false, reason: "..." }` if memory couldn't be freed (e.g., already freed or other references exist)
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * import { freeExternalMemory } from 'rolldown/experimental';
96
+ *
97
+ * const output = await bundle.generate();
98
+ * const chunk = output.output[0];
99
+ *
100
+ * // Use the chunk...
101
+ *
102
+ * // Manually free the memory (fast, but accessing properties after will throw)
103
+ * const status = freeExternalMemory(chunk); // { freed: true }
104
+ * const statusAgain = freeExternalMemory(chunk); // { freed: false, reason: "Memory has already been freed" }
105
+ *
106
+ * // Keep data alive before freeing (slower, but data remains accessible)
107
+ * freeExternalMemory(chunk, true); // Evaluates all lazy fields first
108
+ * console.log(chunk.code); // OK - data was copied to JavaScript before freeing
109
+ *
110
+ * // Without keepDataAlive, accessing chunk properties after freeing will throw an error
111
+ * ```
112
+ */
113
+ declare function freeExternalMemory(handle: ExternalMemoryHandle, keepDataAlive?: boolean): ExternalMemoryStatus;
114
+ //#endregion
64
115
  //#region src/types/rolldown-output.d.ts
65
- interface OutputAsset {
116
+ interface OutputAsset extends ExternalMemoryHandle {
66
117
  type: "asset";
67
118
  fileName: string;
68
119
  /** @deprecated Use "originalFileNames" instead. */
@@ -105,7 +156,7 @@ interface RenderedChunk extends Omit<BindingRenderedChunk, "modules"> {
105
156
  imports: Array<string>;
106
157
  dynamicImports: Array<string>;
107
158
  }
108
- interface OutputChunk {
159
+ interface OutputChunk extends ExternalMemoryHandle {
109
160
  type: "chunk";
110
161
  code: string;
111
162
  name: string;
@@ -124,7 +175,7 @@ interface OutputChunk {
124
175
  sourcemapFileName: string | null;
125
176
  preliminaryFileName: string;
126
177
  }
127
- interface RolldownOutput {
178
+ interface RolldownOutput extends ExternalMemoryHandle {
128
179
  output: [OutputChunk, ...(OutputChunk | OutputAsset)[]];
129
180
  }
130
181
  //#endregion
@@ -602,6 +653,9 @@ declare class RolldownBuild {
602
653
  scan(): Promise<void>;
603
654
  generate(outputOptions?: OutputOptions): Promise<RolldownOutput>;
604
655
  write(outputOptions?: OutputOptions): Promise<RolldownOutput>;
656
+ /**
657
+ * Close the build and free resources.
658
+ */
605
659
  close(): Promise<void>;
606
660
  [Symbol.asyncDispose](): Promise<void>;
607
661
  get watchFiles(): Promise<string[]>;
@@ -1647,4 +1701,4 @@ declare function defineConfig(config: RolldownOptions[]): RolldownOptions[];
1647
1701
  declare function defineConfig(config: RolldownOptionsFunction): RolldownOptionsFunction;
1648
1702
  declare function defineConfig(config: ConfigExport): ConfigExport;
1649
1703
  //#endregion
1650
- export { InternalModuleFormat as $, BuiltinPlugin as A, SourceMap as At, GetModuleInfo as B, ResolveIdResult as C, PartialNull as Ct, SourceDescription as D, RenderedChunk as Dt, RolldownPluginOption as E, OutputChunk as Et, OutputBundle as F, LogOrStringHandler as Ft, PluginContextMeta as G, DefineParallelPluginResult as H, TreeshakingOptions as I, RollupError as It, ModuleTypeFilter as J, GeneralHookFilter as K, TransformPluginContext as L, RollupLog as Lt, ExistingRawSourceMap as M, SourcemapIgnoreListOption as Mt, SourceMapInput as N, LogLevel as Nt, TransformResult as O, RenderedModule as Ot, RolldownOptionsFunction as P, LogLevelOption as Pt, RolldownFsModule as Q, EmittedAsset as R, RollupLogWithString as Rt, ResolveIdExtraOptions as S, MaybePromise as St, RolldownPlugin as T, OutputAsset as Tt, defineParallelPlugin as U, PluginContext as V, MinimalPluginContext as W, RolldownDirectoryEntry as X, BufferEncoding as Y, RolldownFileStats as Z, ModuleType as _, GlobalsFunction as _t, InputOption as a, RolldownWatcher as at, PartialResolvedId as b, OutputOptions as bt, OptimizationOptions as c, rolldown as ct, CustomPluginOptions as d, build as dt, NormalizedOutputOptions as et, FunctionPluginHooks as f, AddonFunction as ft, ModuleOptions as g, GeneratedCodePreset as gt, LoadResult as h, GeneratedCodeOptions as ht, ExternalOption as i, watch as it, VERSION as j, ModuleInfo as jt, withFilter as k, RolldownOutput as kt, WatcherOptions as l, RolldownBuild as lt, ImportKind as m, ChunkingContext as mt, ConfigExport as n, LoggingFunction as nt, InputOptions as o, RolldownWatcherEvent as ot, HookFilterExtension as p, ChunkFileNamesFunction as pt, HookFilter as q, RolldownOptions as r, WarningHandlerWithDefault as rt, ModuleTypes as s, WatchOptions as st, defineConfig as t, NormalizedInputOptions as tt, AsyncPluginHooks as u, BuildOptions as ut, ObjectHook as v, MinifyOptions as vt, ResolvedId as w, StringOrRegExp as wt, Plugin as x, PreRenderedAsset as xt, ParallelPluginHooks as y, ModuleFormat as yt, EmittedFile as z };
1704
+ export { InternalModuleFormat as $, BuiltinPlugin as A, SourceMap as At, GetModuleInfo as B, ResolveIdResult as C, PartialNull as Ct, SourceDescription as D, RenderedChunk as Dt, RolldownPluginOption as E, OutputChunk as Et, OutputBundle as F, LogLevelOption as Ft, PluginContextMeta as G, DefineParallelPluginResult as H, TreeshakingOptions as I, LogOrStringHandler as It, ModuleTypeFilter as J, GeneralHookFilter as K, TransformPluginContext as L, RollupError as Lt, ExistingRawSourceMap as M, ModuleInfo as Mt, SourceMapInput as N, SourcemapIgnoreListOption as Nt, TransformResult as O, RenderedModule as Ot, RolldownOptionsFunction as P, LogLevel as Pt, RolldownFsModule as Q, EmittedAsset as R, RollupLog as Rt, ResolveIdExtraOptions as S, MaybePromise as St, RolldownPlugin as T, OutputAsset as Tt, defineParallelPlugin as U, PluginContext as V, MinimalPluginContext as W, RolldownDirectoryEntry as X, BufferEncoding as Y, RolldownFileStats as Z, ModuleType as _, GlobalsFunction as _t, InputOption as a, RolldownWatcher as at, PartialResolvedId as b, OutputOptions as bt, OptimizationOptions as c, rolldown as ct, CustomPluginOptions as d, build as dt, NormalizedOutputOptions as et, FunctionPluginHooks as f, AddonFunction as ft, ModuleOptions as g, GeneratedCodePreset as gt, LoadResult as h, GeneratedCodeOptions as ht, ExternalOption as i, watch as it, VERSION as j, freeExternalMemory as jt, withFilter as k, RolldownOutput as kt, WatcherOptions as l, RolldownBuild as lt, ImportKind as m, ChunkingContext as mt, ConfigExport as n, LoggingFunction as nt, InputOptions as o, RolldownWatcherEvent as ot, HookFilterExtension as p, ChunkFileNamesFunction as pt, HookFilter as q, RolldownOptions as r, WarningHandlerWithDefault as rt, ModuleTypes as s, WatchOptions as st, defineConfig as t, NormalizedInputOptions as tt, AsyncPluginHooks as u, BuildOptions as ut, ObjectHook as v, MinifyOptions as vt, ResolvedId as w, StringOrRegExp as wt, Plugin as x, PreRenderedAsset as xt, ParallelPluginHooks as y, ModuleFormat as yt, EmittedFile as z, RollupLogWithString as zt };
@@ -1,9 +1,9 @@
1
- import { o as rolldown } from "./src-B4ZmdjD5.mjs";
1
+ import { o as rolldown } from "./src-B8saaB3b.mjs";
2
+ import fs from "node:fs";
2
3
  import path from "node:path";
3
4
  import { readdir } from "node:fs/promises";
4
5
  import { pathToFileURL } from "node:url";
5
6
  import { cwd } from "node:process";
6
- import fs from "node:fs";
7
7
 
8
8
  //#region src/utils/load-config.ts
9
9
  async function bundleTsConfig(configFile, isEsm) {
@@ -1,4 +1,4 @@
1
- import { parseAsync, parseSync } from "../rolldown-binding.wasi.cjs";
1
+ import { n as __toESM, t as require_binding } from "./binding-BeWSOIj5.mjs";
2
2
  import { styleText } from "node:util";
3
3
 
4
4
  //#region src/utils/code-frame.ts
@@ -41,6 +41,11 @@ function getCodeFrame(source, line, column) {
41
41
 
42
42
  //#endregion
43
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
+ */
44
49
  function styleText$1(...args) {
45
50
  return styleText(...args);
46
51
  }
@@ -217,7 +222,7 @@ function augmentCodeLocation(properties, pos, source, id) {
217
222
  }
218
223
 
219
224
  //#endregion
220
- //#region ../../node_modules/.pnpm/oxc-parser@0.95.0/node_modules/oxc-parser/src-js/wrap.js
225
+ //#region ../../node_modules/.pnpm/oxc-parser@0.96.0/node_modules/oxc-parser/src-js/wrap.js
221
226
  function wrap$1(result) {
222
227
  let program, module, comments, errors;
223
228
  return {
@@ -250,11 +255,12 @@ function applyFix(program, fixPath) {
250
255
  if (node.bigint) node.value = BigInt(node.bigint);
251
256
  else try {
252
257
  node.value = RegExp(node.regex.pattern, node.regex.flags);
253
- } catch (_err) {}
258
+ } catch {}
254
259
  }
255
260
 
256
261
  //#endregion
257
262
  //#region src/parse-ast-index.ts
263
+ var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
258
264
  function wrap(result, sourceText) {
259
265
  result = wrap$1(result);
260
266
  if (result.errors.length > 0) return normalizeParseError(sourceText, result.errors);
@@ -281,13 +287,13 @@ const defaultParserOptions = {
281
287
  preserveParens: false
282
288
  };
283
289
  function parseAst(sourceText, options, filename) {
284
- return wrap(parseSync(filename ?? "file.js", sourceText, {
290
+ return wrap((0, import_binding.parseSync)(filename ?? "file.js", sourceText, {
285
291
  ...defaultParserOptions,
286
292
  ...options
287
293
  }), sourceText);
288
294
  }
289
295
  async function parseAstAsync(sourceText, options, filename) {
290
- return wrap(await parseAsync(filename ?? "file.js", sourceText, {
296
+ return wrap(await (0, import_binding.parseAsync)(filename ?? "file.js", sourceText, {
291
297
  ...defaultParserOptions,
292
298
  ...options
293
299
  }), sourceText);