rolldown 1.0.0-beta.45 → 1.0.0-beta.47

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,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-S7w0fEEX.mjs";
1
+ import { L as ParserOptions, M as JsxOptions, N as MinifyOptions$1, O as BindingWatcherEvent, R as PreRenderedChunk, V as TransformOptions$1, _ as BindingRenderedChunk, b as BindingTransformHookExtraArgs, c as BindingHookResolveIdExtraArgs, f as BindingMagicString, i as BindingBundlerImpl, k as ExternalMemoryStatus, r as BindingBuiltinPluginName } from "./binding-BHtM7anm.mjs";
2
2
  import { TopLevelFilterExpression } from "@rolldown/pluginutils";
3
3
  import { Program } from "@oxc-project/types";
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,4 +1,4 @@
1
- import { a as rolldown } from "./src-CPA2meNe.mjs";
1
+ import { o as rolldown } from "./src-BwxUhqZU.mjs";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import { readdir } from "node:fs/promises";
@@ -1,4 +1,4 @@
1
- import { b as parseSync, y as parseAsync } from "./binding-D7oxcV7l.mjs";
1
+ import { n as __toESM, t as require_binding } from "./binding-DBWhurrz.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);