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,5 +1,5 @@
1
- import { C as startAsyncRuntime, S as shutdownAsyncRuntime, c as BindingPluginOrder, f as BindingWatcher, g as initTraceSubscriber, i as BindingChunkModuleOrderBy, l as BindingPropertyReadSideEffects, n as BindingBundler, o as BindingLogLevel, p as ParallelJsPluginRegistry, r as BindingCallableBuiltinPlugin, s as BindingMagicString, t as BindingAttachDebugInfo, u as BindingPropertyWriteSideEffects } from "./binding-D7oxcV7l.mjs";
2
- import { a as logCycleLoading, c as logDeprecatedInject, d as logInputHookInOutputPlugin, f as logInvalidLogPosition, h as styleText, i as error, l as logDeprecatedKeepNames, m as logPluginError, o as logDeprecatedDefine, p as logMultiplyNotifyOption, r as augmentCodeLocation, s as logDeprecatedDropLabels, t as parseAst, u as logDeprecatedProfilerNames } from "./parse-ast-index-lp33x2Wb.mjs";
1
+ import { n as __toESM, t as require_binding } from "./binding-DBWhurrz.mjs";
2
+ import { a as logCycleLoading, c as logDeprecatedInject, d as logInputHookInOutputPlugin, f as logInvalidLogPosition, h as styleText, i as error, l as logDeprecatedKeepNames, m as logPluginError, o as logDeprecatedDefine, p as logMultiplyNotifyOption, r as augmentCodeLocation, s as logDeprecatedDropLabels, t as parseAst, u as logDeprecatedProfilerNames } from "./parse-ast-index-B4DJl5-M.mjs";
3
3
  import { a as unreachable, i as unimplemented, o as unsupported, r as noop, t as arraify } from "./misc-usdOVIou.mjs";
4
4
  import { Worker, isMainThread } from "node:worker_threads";
5
5
  import path from "node:path";
@@ -209,8 +209,9 @@ const { onExit, load, unload } = signalExitWrap(processOk(process$1) ? new Signa
209
209
 
210
210
  //#endregion
211
211
  //#region src/setup.ts
212
+ var import_binding$8 = /* @__PURE__ */ __toESM(require_binding(), 1);
212
213
  if (isMainThread) {
213
- const subscriberGuard = initTraceSubscriber();
214
+ const subscriberGuard = (0, import_binding$8.initTraceSubscriber)();
214
215
  onExit(() => {
215
216
  subscriberGuard?.close();
216
217
  });
@@ -218,11 +219,12 @@ if (isMainThread) {
218
219
 
219
220
  //#endregion
220
221
  //#region package.json
221
- var version = "1.0.0-beta.45";
222
+ var version = "1.0.0-beta.47";
222
223
  var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
223
224
 
224
225
  //#endregion
225
226
  //#region src/builtin-plugin/utils.ts
227
+ var import_binding$7 = /* @__PURE__ */ __toESM(require_binding(), 1);
226
228
  var BuiltinPlugin = class {
227
229
  constructor(name, _options) {
228
230
  this.name = name;
@@ -230,7 +232,7 @@ var BuiltinPlugin = class {
230
232
  }
231
233
  };
232
234
  function makeBuiltinPluginCallable(plugin) {
233
- let callablePlugin = new BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
235
+ let callablePlugin = new import_binding$7.BindingCallableBuiltinPlugin(bindingifyBuiltInPlugin(plugin));
234
236
  const wrappedPlugin = plugin;
235
237
  for (const key in callablePlugin) wrappedPlugin[key] = async function(...args$1) {
236
238
  try {
@@ -2137,19 +2139,63 @@ function getCliSchemaInfo() {
2137
2139
  }
2138
2140
 
2139
2141
  //#endregion
2140
- //#region src/types/sourcemap.ts
2141
- function bindingifySourcemap$1(map) {
2142
- if (map == null) return;
2143
- return { inner: typeof map === "string" ? map : {
2144
- file: map.file ?? void 0,
2145
- mappings: map.mappings,
2146
- sourceRoot: "sourceRoot" in map ? map.sourceRoot ?? void 0 : void 0,
2147
- sources: map.sources?.map((s) => s ?? void 0),
2148
- sourcesContent: map.sourcesContent?.map((s) => s ?? void 0),
2149
- names: map.names,
2150
- x_google_ignoreList: map.x_google_ignoreList,
2151
- debugId: "debugId" in map ? map.debugId : void 0
2152
- } };
2142
+ //#region src/decorators/lazy.ts
2143
+ const LAZY_FIELDS_KEY = Symbol("__lazy_fields__");
2144
+ const LAZY_CACHE_PREFIX = "__cached_";
2145
+ /**
2146
+ * Legacy decorator that makes a getter lazy-evaluated and cached.
2147
+ * Also auto-registers the field for batch prefetching.
2148
+ *
2149
+ * @example
2150
+ * ```typescript
2151
+ * class MyClass {
2152
+ * @lazy
2153
+ * get expensiveValue() {
2154
+ * return someExpensiveComputation();
2155
+ * }
2156
+ * }
2157
+ * ```
2158
+ */
2159
+ function lazy(target, propertyKey, descriptor) {
2160
+ if (!target.constructor[LAZY_FIELDS_KEY]) target.constructor[LAZY_FIELDS_KEY] = /* @__PURE__ */ new Set();
2161
+ target.constructor[LAZY_FIELDS_KEY].add(propertyKey);
2162
+ const originalGetter = descriptor.get;
2163
+ const cacheKey = LAZY_CACHE_PREFIX + propertyKey;
2164
+ descriptor.get = function() {
2165
+ if (!(cacheKey in this)) this[cacheKey] = originalGetter.call(this);
2166
+ return this[cacheKey];
2167
+ };
2168
+ return descriptor;
2169
+ }
2170
+ /**
2171
+ * Get all lazy field names from a class instance.
2172
+ *
2173
+ * @param instance - Instance to inspect
2174
+ * @returns Set of lazy property names
2175
+ */
2176
+ function getLazyFields(instance$1) {
2177
+ return instance$1.constructor[LAZY_FIELDS_KEY] || /* @__PURE__ */ new Set();
2178
+ }
2179
+
2180
+ //#endregion
2181
+ //#region src/decorators/non-enumerable.ts
2182
+ /**
2183
+ * Decorator that makes a property or method non-enumerable.
2184
+ * This hides the property from enumeration (e.g., Object.keys(), for...in loops).
2185
+ *
2186
+ * @example
2187
+ * ```typescript
2188
+ * class MyClass {
2189
+ * @nonEnumerable
2190
+ * hiddenMethod() {
2191
+ * return 'This method will not show up in Object.keys()';
2192
+ * }
2193
+ * }
2194
+ * ```
2195
+ */
2196
+ function nonEnumerable(target, propertyKey, descriptor) {
2197
+ descriptor.enumerable = false;
2198
+ return descriptor;
2153
2199
  }
2154
2200
 
2155
2201
  //#endregion
@@ -2161,6 +2207,56 @@ function bindingAssetSource(source) {
2161
2207
  return { inner: source };
2162
2208
  }
2163
2209
 
2210
+ //#endregion
2211
+ //#region \0@oxc-project+runtime@0.96.0/helpers/decorate.js
2212
+ function __decorate(decorators, target, key, desc) {
2213
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2214
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2215
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2216
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2217
+ }
2218
+
2219
+ //#endregion
2220
+ //#region src/types/output-asset-impl.ts
2221
+ var OutputAssetImpl = class {
2222
+ type = "asset";
2223
+ constructor(bindingAsset) {
2224
+ this.bindingAsset = bindingAsset;
2225
+ }
2226
+ get fileName() {
2227
+ return this.bindingAsset.getFileName();
2228
+ }
2229
+ get originalFileName() {
2230
+ return this.bindingAsset.getOriginalFileName() || null;
2231
+ }
2232
+ get originalFileNames() {
2233
+ return this.bindingAsset.getOriginalFileNames();
2234
+ }
2235
+ get name() {
2236
+ return this.bindingAsset.getName() ?? void 0;
2237
+ }
2238
+ get names() {
2239
+ return this.bindingAsset.getNames();
2240
+ }
2241
+ get source() {
2242
+ return transformAssetSource(this.bindingAsset.getSource());
2243
+ }
2244
+ __rolldown_external_memory_handle__(keepDataAlive) {
2245
+ if (keepDataAlive) this.#evaluateAllLazyFields();
2246
+ return this.bindingAsset.dropInner();
2247
+ }
2248
+ #evaluateAllLazyFields() {
2249
+ for (const field of getLazyFields(this)) this[field];
2250
+ }
2251
+ };
2252
+ __decorate([lazy], OutputAssetImpl.prototype, "fileName", null);
2253
+ __decorate([lazy], OutputAssetImpl.prototype, "originalFileName", null);
2254
+ __decorate([lazy], OutputAssetImpl.prototype, "originalFileNames", null);
2255
+ __decorate([lazy], OutputAssetImpl.prototype, "name", null);
2256
+ __decorate([lazy], OutputAssetImpl.prototype, "names", null);
2257
+ __decorate([lazy], OutputAssetImpl.prototype, "source", null);
2258
+ __decorate([nonEnumerable], OutputAssetImpl.prototype, "__rolldown_external_memory_handle__", null);
2259
+
2164
2260
  //#endregion
2165
2261
  //#region src/utils/transform-rendered-module.ts
2166
2262
  function transformToRenderedModule(bindingRenderedModule) {
@@ -2226,6 +2322,96 @@ function transformChunkModules(modules) {
2226
2322
  return result;
2227
2323
  }
2228
2324
 
2325
+ //#endregion
2326
+ //#region src/types/output-chunk-impl.ts
2327
+ var OutputChunkImpl = class {
2328
+ type = "chunk";
2329
+ constructor(bindingChunk) {
2330
+ this.bindingChunk = bindingChunk;
2331
+ }
2332
+ get fileName() {
2333
+ return this.bindingChunk.getFileName();
2334
+ }
2335
+ get name() {
2336
+ return this.bindingChunk.getName();
2337
+ }
2338
+ get exports() {
2339
+ return this.bindingChunk.getExports();
2340
+ }
2341
+ get isEntry() {
2342
+ return this.bindingChunk.getIsEntry();
2343
+ }
2344
+ get facadeModuleId() {
2345
+ return this.bindingChunk.getFacadeModuleId() || null;
2346
+ }
2347
+ get isDynamicEntry() {
2348
+ return this.bindingChunk.getIsDynamicEntry();
2349
+ }
2350
+ get sourcemapFileName() {
2351
+ return this.bindingChunk.getSourcemapFileName() || null;
2352
+ }
2353
+ get preliminaryFileName() {
2354
+ return this.bindingChunk.getPreliminaryFileName();
2355
+ }
2356
+ get code() {
2357
+ return this.bindingChunk.getCode();
2358
+ }
2359
+ get modules() {
2360
+ return transformChunkModules(this.bindingChunk.getModules());
2361
+ }
2362
+ get imports() {
2363
+ return this.bindingChunk.getImports();
2364
+ }
2365
+ get dynamicImports() {
2366
+ return this.bindingChunk.getDynamicImports();
2367
+ }
2368
+ get moduleIds() {
2369
+ return this.bindingChunk.getModuleIds();
2370
+ }
2371
+ get map() {
2372
+ const mapString = this.bindingChunk.getMap();
2373
+ return mapString ? transformToRollupSourceMap(mapString) : null;
2374
+ }
2375
+ __rolldown_external_memory_handle__(keepDataAlive) {
2376
+ if (keepDataAlive) this.#evaluateAllLazyFields();
2377
+ return this.bindingChunk.dropInner();
2378
+ }
2379
+ #evaluateAllLazyFields() {
2380
+ for (const field of getLazyFields(this)) this[field];
2381
+ }
2382
+ };
2383
+ __decorate([lazy], OutputChunkImpl.prototype, "fileName", null);
2384
+ __decorate([lazy], OutputChunkImpl.prototype, "name", null);
2385
+ __decorate([lazy], OutputChunkImpl.prototype, "exports", null);
2386
+ __decorate([lazy], OutputChunkImpl.prototype, "isEntry", null);
2387
+ __decorate([lazy], OutputChunkImpl.prototype, "facadeModuleId", null);
2388
+ __decorate([lazy], OutputChunkImpl.prototype, "isDynamicEntry", null);
2389
+ __decorate([lazy], OutputChunkImpl.prototype, "sourcemapFileName", null);
2390
+ __decorate([lazy], OutputChunkImpl.prototype, "preliminaryFileName", null);
2391
+ __decorate([lazy], OutputChunkImpl.prototype, "code", null);
2392
+ __decorate([lazy], OutputChunkImpl.prototype, "modules", null);
2393
+ __decorate([lazy], OutputChunkImpl.prototype, "imports", null);
2394
+ __decorate([lazy], OutputChunkImpl.prototype, "dynamicImports", null);
2395
+ __decorate([lazy], OutputChunkImpl.prototype, "moduleIds", null);
2396
+ __decorate([lazy], OutputChunkImpl.prototype, "map", null);
2397
+ __decorate([nonEnumerable], OutputChunkImpl.prototype, "__rolldown_external_memory_handle__", null);
2398
+
2399
+ //#endregion
2400
+ //#region src/types/sourcemap.ts
2401
+ function bindingifySourcemap$1(map) {
2402
+ if (map == null) return;
2403
+ return { inner: typeof map === "string" ? map : {
2404
+ file: map.file ?? void 0,
2405
+ mappings: map.mappings,
2406
+ sourceRoot: "sourceRoot" in map ? map.sourceRoot ?? void 0 : void 0,
2407
+ sources: map.sources?.map((s) => s ?? void 0),
2408
+ sourcesContent: map.sourcesContent?.map((s) => s ?? void 0),
2409
+ names: map.names,
2410
+ x_google_ignoreList: map.x_google_ignoreList,
2411
+ debugId: "debugId" in map ? map.debugId : void 0
2412
+ } };
2413
+ }
2414
+
2229
2415
  //#endregion
2230
2416
  //#region src/utils/transform-to-rollup-output.ts
2231
2417
  function transformToRollupSourceMap(map) {
@@ -2241,78 +2427,38 @@ function transformToRollupSourceMap(map) {
2241
2427
  return obj;
2242
2428
  }
2243
2429
  function transformToRollupOutputChunk(bindingChunk) {
2244
- const chunk = {
2245
- type: "chunk",
2246
- get code() {
2247
- return bindingChunk.code;
2248
- },
2249
- fileName: bindingChunk.fileName,
2250
- name: bindingChunk.name,
2251
- get modules() {
2252
- return transformChunkModules(bindingChunk.modules);
2253
- },
2254
- get imports() {
2255
- return bindingChunk.imports;
2256
- },
2257
- get dynamicImports() {
2258
- return bindingChunk.dynamicImports;
2259
- },
2260
- exports: bindingChunk.exports,
2261
- isEntry: bindingChunk.isEntry,
2262
- facadeModuleId: bindingChunk.facadeModuleId || null,
2263
- isDynamicEntry: bindingChunk.isDynamicEntry,
2264
- get moduleIds() {
2265
- return bindingChunk.moduleIds;
2266
- },
2267
- get map() {
2268
- return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
2269
- },
2270
- sourcemapFileName: bindingChunk.sourcemapFileName || null,
2271
- preliminaryFileName: bindingChunk.preliminaryFileName
2272
- };
2273
- const cache = {};
2274
- return new Proxy(chunk, {
2275
- get(target, p) {
2276
- if (p in cache) return cache[p];
2277
- const value = target[p];
2278
- cache[p] = value;
2279
- return value;
2280
- },
2281
- has(target, p) {
2282
- if (p in cache) return true;
2283
- return p in target;
2284
- }
2285
- });
2430
+ return new OutputChunkImpl(bindingChunk);
2286
2431
  }
2287
2432
  function transformToMutableRollupOutputChunk(bindingChunk, changed) {
2288
2433
  const chunk = {
2289
2434
  type: "chunk",
2290
2435
  get code() {
2291
- return bindingChunk.code;
2436
+ return bindingChunk.getCode();
2292
2437
  },
2293
- fileName: bindingChunk.fileName,
2294
- name: bindingChunk.name,
2438
+ fileName: bindingChunk.getFileName(),
2439
+ name: bindingChunk.getName(),
2295
2440
  get modules() {
2296
- return transformChunkModules(bindingChunk.modules);
2441
+ return transformChunkModules(bindingChunk.getModules());
2297
2442
  },
2298
2443
  get imports() {
2299
- return bindingChunk.imports;
2444
+ return bindingChunk.getImports();
2300
2445
  },
2301
2446
  get dynamicImports() {
2302
- return bindingChunk.dynamicImports;
2447
+ return bindingChunk.getDynamicImports();
2303
2448
  },
2304
- exports: bindingChunk.exports,
2305
- isEntry: bindingChunk.isEntry,
2306
- facadeModuleId: bindingChunk.facadeModuleId || null,
2307
- isDynamicEntry: bindingChunk.isDynamicEntry,
2449
+ exports: bindingChunk.getExports(),
2450
+ isEntry: bindingChunk.getIsEntry(),
2451
+ facadeModuleId: bindingChunk.getFacadeModuleId() || null,
2452
+ isDynamicEntry: bindingChunk.getIsDynamicEntry(),
2308
2453
  get moduleIds() {
2309
- return bindingChunk.moduleIds;
2454
+ return bindingChunk.getModuleIds();
2310
2455
  },
2311
2456
  get map() {
2312
- return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
2457
+ const map = bindingChunk.getMap();
2458
+ return map ? transformToRollupSourceMap(map) : null;
2313
2459
  },
2314
- sourcemapFileName: bindingChunk.sourcemapFileName || null,
2315
- preliminaryFileName: bindingChunk.preliminaryFileName
2460
+ sourcemapFileName: bindingChunk.getSourcemapFileName() || null,
2461
+ preliminaryFileName: bindingChunk.getPreliminaryFileName()
2316
2462
  };
2317
2463
  const cache = {};
2318
2464
  return new Proxy(chunk, {
@@ -2324,7 +2470,7 @@ function transformToMutableRollupOutputChunk(bindingChunk, changed) {
2324
2470
  },
2325
2471
  set(_target, p, newValue) {
2326
2472
  cache[p] = newValue;
2327
- changed.updated.add(bindingChunk.fileName);
2473
+ changed.updated.add(bindingChunk.getFileName());
2328
2474
  return true;
2329
2475
  },
2330
2476
  has(target, p) {
@@ -2334,36 +2480,19 @@ function transformToMutableRollupOutputChunk(bindingChunk, changed) {
2334
2480
  });
2335
2481
  }
2336
2482
  function transformToRollupOutputAsset(bindingAsset) {
2337
- const asset = {
2338
- type: "asset",
2339
- fileName: bindingAsset.fileName,
2340
- originalFileName: bindingAsset.originalFileName || null,
2341
- originalFileNames: bindingAsset.originalFileNames,
2342
- get source() {
2343
- return transformAssetSource(bindingAsset.source);
2344
- },
2345
- name: bindingAsset.name ?? void 0,
2346
- names: bindingAsset.names
2347
- };
2348
- const cache = {};
2349
- return new Proxy(asset, { get(target, p) {
2350
- if (p in cache) return cache[p];
2351
- const value = target[p];
2352
- cache[p] = value;
2353
- return value;
2354
- } });
2483
+ return new OutputAssetImpl(bindingAsset);
2355
2484
  }
2356
2485
  function transformToMutableRollupOutputAsset(bindingAsset, changed) {
2357
2486
  const asset = {
2358
2487
  type: "asset",
2359
- fileName: bindingAsset.fileName,
2360
- originalFileName: bindingAsset.originalFileName || null,
2361
- originalFileNames: bindingAsset.originalFileNames,
2488
+ fileName: bindingAsset.getFileName(),
2489
+ originalFileName: bindingAsset.getOriginalFileName() || null,
2490
+ originalFileNames: bindingAsset.getOriginalFileNames(),
2362
2491
  get source() {
2363
- return transformAssetSource(bindingAsset.source);
2492
+ return transformAssetSource(bindingAsset.getSource());
2364
2493
  },
2365
- name: bindingAsset.name ?? void 0,
2366
- names: bindingAsset.names
2494
+ name: bindingAsset.getName() ?? void 0,
2495
+ names: bindingAsset.getNames()
2367
2496
  };
2368
2497
  const cache = {};
2369
2498
  return new Proxy(asset, {
@@ -2375,7 +2504,7 @@ function transformToMutableRollupOutputAsset(bindingAsset, changed) {
2375
2504
  },
2376
2505
  set(_target, p, newValue) {
2377
2506
  cache[p] = newValue;
2378
- changed.updated.add(bindingAsset.fileName);
2507
+ changed.updated.add(bindingAsset.getFileName());
2379
2508
  return true;
2380
2509
  }
2381
2510
  });
@@ -2452,7 +2581,20 @@ var RolldownOutputImpl = class {
2452
2581
  get output() {
2453
2582
  return transformToRollupOutput(this.bindingOutputs).output;
2454
2583
  }
2584
+ __rolldown_external_memory_handle__(keepDataAlive) {
2585
+ const results = this.output.map((item) => item.__rolldown_external_memory_handle__(keepDataAlive));
2586
+ if (!results.every((r) => r.freed)) {
2587
+ const reasons = results.filter((r) => !r.freed).map((r) => r.reason).filter(Boolean);
2588
+ return {
2589
+ freed: false,
2590
+ reason: `Failed to free ${reasons.length} item(s): ${reasons.join("; ")}`
2591
+ };
2592
+ }
2593
+ return { freed: true };
2594
+ }
2455
2595
  };
2596
+ __decorate([lazy], RolldownOutputImpl.prototype, "output", null);
2597
+ __decorate([nonEnumerable], RolldownOutputImpl.prototype, "__rolldown_external_memory_handle__", null);
2456
2598
 
2457
2599
  //#endregion
2458
2600
  //#region src/utils/error.ts
@@ -2721,13 +2863,14 @@ function bindingifyRenderChunkFilter(filterOption) {
2721
2863
 
2722
2864
  //#endregion
2723
2865
  //#region src/plugin/bindingify-plugin-hook-meta.ts
2866
+ var import_binding$6 = /* @__PURE__ */ __toESM(require_binding(), 1);
2724
2867
  function bindingifyPluginHookMeta(options) {
2725
2868
  return { order: bindingPluginOrder(options.order) };
2726
2869
  }
2727
2870
  function bindingPluginOrder(order) {
2728
2871
  switch (order) {
2729
- case "post": return BindingPluginOrder.Post;
2730
- case "pre": return BindingPluginOrder.Pre;
2872
+ case "post": return import_binding$6.BindingPluginOrder.Post;
2873
+ case "pre": return import_binding$6.BindingPluginOrder.Pre;
2731
2874
  case null:
2732
2875
  case void 0: return;
2733
2876
  default: throw new Error(`Unknown plugin order: ${order}`);
@@ -2888,6 +3031,7 @@ var TransformPluginContextImpl = class extends PluginContextImpl {
2888
3031
 
2889
3032
  //#endregion
2890
3033
  //#region src/plugin/bindingify-build-hooks.ts
3034
+ var import_binding$5 = /* @__PURE__ */ __toESM(require_binding(), 1);
2891
3035
  function bindingifyBuildStart(args$1) {
2892
3036
  const hook = args$1.plugin.buildStart;
2893
3037
  if (!hook) return {};
@@ -2983,11 +3127,15 @@ function bindingifyTransform(args$1) {
2983
3127
  const { handler, meta, options } = normalizeHook(hook);
2984
3128
  return {
2985
3129
  plugin: async (ctx, code, id, meta$1) => {
3130
+ let magicStringInstance, astInstance;
2986
3131
  Object.defineProperties(meta$1, {
2987
3132
  magicString: { get() {
2988
- return new BindingMagicString(code);
3133
+ if (magicStringInstance) return magicStringInstance;
3134
+ magicStringInstance = new import_binding$5.BindingMagicString(code);
3135
+ return magicStringInstance;
2989
3136
  } },
2990
3137
  ast: { get() {
3138
+ if (astInstance) return astInstance;
2991
3139
  let lang = "js";
2992
3140
  switch (meta$1.moduleType) {
2993
3141
  case "js":
@@ -2998,10 +3146,11 @@ function bindingifyTransform(args$1) {
2998
3146
  break;
2999
3147
  default: break;
3000
3148
  }
3001
- return parseAst(code, {
3149
+ astInstance = parseAst(code, {
3002
3150
  astType: meta$1.moduleType.includes("ts") ? "ts" : "js",
3003
3151
  lang
3004
3152
  });
3153
+ return astInstance;
3005
3154
  } }
3006
3155
  });
3007
3156
  const transformCtx = new TransformPluginContextImpl(args$1.outputOptions, ctx.inner(), args$1.plugin, args$1.pluginContextData, ctx, id, code, args$1.onLog, args$1.logLevel, args$1.watchMode);
@@ -3016,7 +3165,7 @@ function bindingifyTransform(args$1) {
3016
3165
  let normalizedCode = void 0;
3017
3166
  let map = ret.map;
3018
3167
  if (typeof ret.code === "string") normalizedCode = ret.code;
3019
- else if (ret.code instanceof BindingMagicString) {
3168
+ else if (ret.code instanceof import_binding$5.BindingMagicString) {
3020
3169
  let magicString = ret.code;
3021
3170
  normalizedCode = magicString.toString();
3022
3171
  let fallbackSourcemap = ctx.sendMagicString(magicString);
@@ -3745,6 +3894,7 @@ function normalizeTransformOptions(inputOptions, onLog) {
3745
3894
 
3746
3895
  //#endregion
3747
3896
  //#region src/utils/bindingify-input-options.ts
3897
+ var import_binding$4 = /* @__PURE__ */ __toESM(require_binding(), 1);
3748
3898
  function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, normalizedOutputPlugins, onLog, logLevel, watchMode) {
3749
3899
  const pluginContextData = new PluginContextData(onLog, outputOptions, normalizedOutputPlugins);
3750
3900
  const plugins = rawPlugins.map((plugin) => {
@@ -3814,9 +3964,9 @@ function bindingifyHmr(hmr) {
3814
3964
  function bindingifyAttachDebugInfo(attachDebugInfo) {
3815
3965
  switch (attachDebugInfo) {
3816
3966
  case void 0: return;
3817
- case "full": return BindingAttachDebugInfo.Full;
3818
- case "simple": return BindingAttachDebugInfo.Simple;
3819
- case "none": return BindingAttachDebugInfo.None;
3967
+ case "full": return import_binding$4.BindingAttachDebugInfo.Full;
3968
+ case "simple": return import_binding$4.BindingAttachDebugInfo.Simple;
3969
+ case "none": return import_binding$4.BindingAttachDebugInfo.None;
3820
3970
  }
3821
3971
  }
3822
3972
  function bindingifyExternal(external) {
@@ -3829,13 +3979,13 @@ function bindingifyExternal(external) {
3829
3979
  }
3830
3980
  }
3831
3981
  function bindingifyExperimental(experimental) {
3832
- let chunkModulesOrder = BindingChunkModuleOrderBy.ExecOrder;
3982
+ let chunkModulesOrder = import_binding$4.BindingChunkModuleOrderBy.ExecOrder;
3833
3983
  if (experimental?.chunkModulesOrder) switch (experimental.chunkModulesOrder) {
3834
3984
  case "exec-order":
3835
- chunkModulesOrder = BindingChunkModuleOrderBy.ExecOrder;
3985
+ chunkModulesOrder = import_binding$4.BindingChunkModuleOrderBy.ExecOrder;
3836
3986
  break;
3837
3987
  case "module-id":
3838
- chunkModulesOrder = BindingChunkModuleOrderBy.ModuleId;
3988
+ chunkModulesOrder = import_binding$4.BindingChunkModuleOrderBy.ModuleId;
3839
3989
  break;
3840
3990
  default: throw new Error(`Unexpected chunkModulesOrder: ${experimental.chunkModulesOrder}`);
3841
3991
  }
@@ -3895,10 +4045,10 @@ function bindingifyInject(inject) {
3895
4045
  }
3896
4046
  function bindingifyLogLevel(logLevel) {
3897
4047
  switch (logLevel) {
3898
- case "silent": return BindingLogLevel.Silent;
3899
- case "debug": return BindingLogLevel.Debug;
3900
- case "warn": return BindingLogLevel.Warn;
3901
- case "info": return BindingLogLevel.Info;
4048
+ case "silent": return import_binding$4.BindingLogLevel.Silent;
4049
+ case "debug": return import_binding$4.BindingLogLevel.Debug;
4050
+ case "warn": return import_binding$4.BindingLogLevel.Warn;
4051
+ case "info": return import_binding$4.BindingLogLevel.Info;
3902
4052
  default: throw new Error(`Unexpected log level: ${logLevel}`);
3903
4053
  }
3904
4054
  }
@@ -3934,19 +4084,19 @@ function bindingifyTreeshakeOptions(config) {
3934
4084
  };
3935
4085
  switch (config.propertyReadSideEffects) {
3936
4086
  case "always":
3937
- normalizedConfig.propertyReadSideEffects = BindingPropertyReadSideEffects.Always;
4087
+ normalizedConfig.propertyReadSideEffects = import_binding$4.BindingPropertyReadSideEffects.Always;
3938
4088
  break;
3939
4089
  case false:
3940
- normalizedConfig.propertyReadSideEffects = BindingPropertyReadSideEffects.False;
4090
+ normalizedConfig.propertyReadSideEffects = import_binding$4.BindingPropertyReadSideEffects.False;
3941
4091
  break;
3942
4092
  default:
3943
4093
  }
3944
4094
  switch (config.propertyWriteSideEffects) {
3945
4095
  case "always":
3946
- normalizedConfig.propertyWriteSideEffects = BindingPropertyWriteSideEffects.Always;
4096
+ normalizedConfig.propertyWriteSideEffects = import_binding$4.BindingPropertyWriteSideEffects.Always;
3947
4097
  break;
3948
4098
  case false:
3949
- normalizedConfig.propertyWriteSideEffects = BindingPropertyWriteSideEffects.False;
4099
+ normalizedConfig.propertyWriteSideEffects = import_binding$4.BindingPropertyWriteSideEffects.False;
3950
4100
  break;
3951
4101
  default:
3952
4102
  }
@@ -4106,6 +4256,7 @@ function bindingifyAdvancedChunks(advancedChunks, manualChunks) {
4106
4256
 
4107
4257
  //#endregion
4108
4258
  //#region src/utils/initialize-parallel-plugins.ts
4259
+ var import_binding$3 = /* @__PURE__ */ __toESM(require_binding(), 1);
4109
4260
  async function initializeParallelPlugins(plugins) {
4110
4261
  const pluginInfos = [];
4111
4262
  for (const [index, plugin] of plugins.entries()) if ("_parallel" in plugin) {
@@ -4118,7 +4269,7 @@ async function initializeParallelPlugins(plugins) {
4118
4269
  }
4119
4270
  if (pluginInfos.length <= 0) return;
4120
4271
  const count = availableParallelism();
4121
- const parallelJsPluginRegistry = new ParallelJsPluginRegistry(count);
4272
+ const parallelJsPluginRegistry = new import_binding$3.ParallelJsPluginRegistry(count);
4122
4273
  const registryId = parallelJsPluginRegistry.id;
4123
4274
  const workers = await initializeWorkers(registryId, count, pluginInfos);
4124
4275
  const stopWorkers = async () => {
@@ -4196,6 +4347,7 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode) {
4196
4347
 
4197
4348
  //#endregion
4198
4349
  //#region src/api/rolldown/rolldown-build.ts
4350
+ var import_binding$2 = /* @__PURE__ */ __toESM(require_binding());
4199
4351
  Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
4200
4352
  var RolldownBuild = class RolldownBuild {
4201
4353
  #inputOptions;
@@ -4204,7 +4356,7 @@ var RolldownBuild = class RolldownBuild {
4204
4356
  static asyncRuntimeShutdown = false;
4205
4357
  constructor(inputOptions) {
4206
4358
  this.#inputOptions = inputOptions;
4207
- this.#bundler = new BindingBundler();
4359
+ this.#bundler = new import_binding$2.BindingBundler();
4208
4360
  }
4209
4361
  get closed() {
4210
4362
  return this.#bundlerImpl?.impl.closed ?? true;
@@ -4212,13 +4364,13 @@ var RolldownBuild = class RolldownBuild {
4212
4364
  async #getBundlerWithStopWorker(outputOptions) {
4213
4365
  if (this.#bundlerImpl) await this.#bundlerImpl.stopWorkers?.();
4214
4366
  const option = await createBundlerOptions(this.#inputOptions, outputOptions, false);
4215
- if (RolldownBuild.asyncRuntimeShutdown) startAsyncRuntime();
4367
+ if (RolldownBuild.asyncRuntimeShutdown) (0, import_binding$2.startAsyncRuntime)();
4216
4368
  try {
4217
4369
  return this.#bundlerImpl = {
4218
4370
  impl: this.#bundler.createImpl(option.bundlerOptions),
4219
4371
  stopWorkers: option.stopWorkers,
4220
4372
  shutdown: () => {
4221
- shutdownAsyncRuntime();
4373
+ (0, import_binding$2.shutdownAsyncRuntime)();
4222
4374
  RolldownBuild.asyncRuntimeShutdown = true;
4223
4375
  }
4224
4376
  };
@@ -4241,6 +4393,9 @@ var RolldownBuild = class RolldownBuild {
4241
4393
  const { impl } = await this.#getBundlerWithStopWorker(outputOptions);
4242
4394
  return new RolldownOutputImpl(unwrapBindingResult(await impl.write()));
4243
4395
  }
4396
+ /**
4397
+ * Close the build and free resources.
4398
+ */
4244
4399
  async close() {
4245
4400
  if (this.#bundlerImpl) {
4246
4401
  await this.#bundlerImpl.stopWorkers?.();
@@ -4355,6 +4510,7 @@ var WatcherEmitter = class {
4355
4510
 
4356
4511
  //#endregion
4357
4512
  //#region src/api/watch/watcher.ts
4513
+ var import_binding$1 = /* @__PURE__ */ __toESM(require_binding(), 1);
4358
4514
  var Watcher = class {
4359
4515
  closed;
4360
4516
  inner;
@@ -4376,7 +4532,7 @@ var Watcher = class {
4376
4532
  this.closed = true;
4377
4533
  for (const stop of this.stopWorkers) await stop?.();
4378
4534
  await this.inner.close();
4379
- shutdownAsyncRuntime();
4535
+ (0, import_binding$1.shutdownAsyncRuntime)();
4380
4536
  }
4381
4537
  start() {
4382
4538
  process.nextTick(() => this.inner.start(this.emitter.onEvent.bind(this.emitter)));
@@ -4388,7 +4544,7 @@ async function createWatcher(emitter, input) {
4388
4544
  return createBundlerOptions(await PluginDriver.callOptionsHook(option, true), output, true);
4389
4545
  })).flat());
4390
4546
  const notifyOptions = getValidNotifyOption(bundlerOptions);
4391
- new Watcher(emitter, new BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), notifyOptions), bundlerOptions.map((option) => option.stopWorkers)).start();
4547
+ new Watcher(emitter, new import_binding$1.BindingWatcher(bundlerOptions.map((option) => option.bundlerOptions), notifyOptions), bundlerOptions.map((option) => option.stopWorkers)).start();
4392
4548
  }
4393
4549
  function getValidNotifyOption(bundlerOptions) {
4394
4550
  let result;
@@ -4417,7 +4573,8 @@ function defineConfig(config) {
4417
4573
 
4418
4574
  //#endregion
4419
4575
  //#region src/index.ts
4576
+ var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
4420
4577
  const VERSION = version;
4421
4578
 
4422
4579
  //#endregion
4423
- export { onExit as C, version as S, validateCliOptions as _, rolldown as a, makeBuiltinPluginCallable as b, normalizedStringOrRegex as c, normalizeBindingResult as d, transformToRollupOutput as f, getOutputCliKeys as g, getInputCliKeys as h, build as i, PluginContextData as l, getCliSchemaInfo as m, defineConfig as n, RolldownBuild as o, bindingifySourcemap$1 as p, watch as r, createBundlerOptions as s, VERSION as t, bindingifyPlugin as u, PluginDriver as v, description$1 as x, BuiltinPlugin as y };
4580
+ export { version as C, description$1 as S, getOutputCliKeys as _, build as a, BuiltinPlugin as b, createBundlerOptions as c, bindingifyPlugin as d, normalizeBindingResult as f, getInputCliKeys as g, getCliSchemaInfo as h, watch as i, normalizedStringOrRegex as l, bindingifySourcemap$1 as m, import_binding as n, rolldown as o, transformToRollupOutput as p, defineConfig as r, RolldownBuild as s, VERSION as t, PluginContextData as u, validateCliOptions as v, onExit as w, makeBuiltinPluginCallable as x, PluginDriver as y };