@rolldown/browser 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,7 +1,7 @@
1
1
  import { BindingAttachDebugInfo, BindingBundler, BindingCallableBuiltinPlugin, BindingChunkModuleOrderBy, BindingLogLevel, BindingMagicString, BindingMagicString as BindingMagicString$1, BindingPluginOrder, BindingPropertyReadSideEffects, BindingPropertyWriteSideEffects, BindingWatcher, parseSync, shutdownAsyncRuntime, startAsyncRuntime } from "./rolldown-binding.wasi-browser.js";
2
2
 
3
3
  //#region package.json
4
- var version = "1.0.0-beta.45";
4
+ var version = "1.0.0-beta.47";
5
5
 
6
6
  //#endregion
7
7
  //#region src/utils/code-frame.ts
@@ -2504,19 +2504,63 @@ function validateOption(key, options) {
2504
2504
  }
2505
2505
 
2506
2506
  //#endregion
2507
- //#region src/types/sourcemap.ts
2508
- function bindingifySourcemap$1(map) {
2509
- if (map == null) return;
2510
- return { inner: typeof map === "string" ? map : {
2511
- file: map.file ?? void 0,
2512
- mappings: map.mappings,
2513
- sourceRoot: "sourceRoot" in map ? map.sourceRoot ?? void 0 : void 0,
2514
- sources: map.sources?.map((s) => s ?? void 0),
2515
- sourcesContent: map.sourcesContent?.map((s) => s ?? void 0),
2516
- names: map.names,
2517
- x_google_ignoreList: map.x_google_ignoreList,
2518
- debugId: "debugId" in map ? map.debugId : void 0
2519
- } };
2507
+ //#region src/decorators/lazy.ts
2508
+ const LAZY_FIELDS_KEY = Symbol("__lazy_fields__");
2509
+ const LAZY_CACHE_PREFIX = "__cached_";
2510
+ /**
2511
+ * Legacy decorator that makes a getter lazy-evaluated and cached.
2512
+ * Also auto-registers the field for batch prefetching.
2513
+ *
2514
+ * @example
2515
+ * ```typescript
2516
+ * class MyClass {
2517
+ * @lazy
2518
+ * get expensiveValue() {
2519
+ * return someExpensiveComputation();
2520
+ * }
2521
+ * }
2522
+ * ```
2523
+ */
2524
+ function lazy(target, propertyKey, descriptor) {
2525
+ if (!target.constructor[LAZY_FIELDS_KEY]) target.constructor[LAZY_FIELDS_KEY] = /* @__PURE__ */ new Set();
2526
+ target.constructor[LAZY_FIELDS_KEY].add(propertyKey);
2527
+ const originalGetter = descriptor.get;
2528
+ const cacheKey = LAZY_CACHE_PREFIX + propertyKey;
2529
+ descriptor.get = function() {
2530
+ if (!(cacheKey in this)) this[cacheKey] = originalGetter.call(this);
2531
+ return this[cacheKey];
2532
+ };
2533
+ return descriptor;
2534
+ }
2535
+ /**
2536
+ * Get all lazy field names from a class instance.
2537
+ *
2538
+ * @param instance - Instance to inspect
2539
+ * @returns Set of lazy property names
2540
+ */
2541
+ function getLazyFields(instance$1) {
2542
+ return instance$1.constructor[LAZY_FIELDS_KEY] || /* @__PURE__ */ new Set();
2543
+ }
2544
+
2545
+ //#endregion
2546
+ //#region src/decorators/non-enumerable.ts
2547
+ /**
2548
+ * Decorator that makes a property or method non-enumerable.
2549
+ * This hides the property from enumeration (e.g., Object.keys(), for...in loops).
2550
+ *
2551
+ * @example
2552
+ * ```typescript
2553
+ * class MyClass {
2554
+ * @nonEnumerable
2555
+ * hiddenMethod() {
2556
+ * return 'This method will not show up in Object.keys()';
2557
+ * }
2558
+ * }
2559
+ * ```
2560
+ */
2561
+ function nonEnumerable(target, propertyKey, descriptor) {
2562
+ descriptor.enumerable = false;
2563
+ return descriptor;
2520
2564
  }
2521
2565
 
2522
2566
  //#endregion
@@ -2528,6 +2572,56 @@ function bindingAssetSource(source) {
2528
2572
  return { inner: source };
2529
2573
  }
2530
2574
 
2575
+ //#endregion
2576
+ //#region \0@oxc-project+runtime@0.96.0/helpers/decorate.js
2577
+ function __decorate(decorators, target, key, desc) {
2578
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2579
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2580
+ 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;
2581
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2582
+ }
2583
+
2584
+ //#endregion
2585
+ //#region src/types/output-asset-impl.ts
2586
+ var OutputAssetImpl = class {
2587
+ type = "asset";
2588
+ constructor(bindingAsset) {
2589
+ this.bindingAsset = bindingAsset;
2590
+ }
2591
+ get fileName() {
2592
+ return this.bindingAsset.getFileName();
2593
+ }
2594
+ get originalFileName() {
2595
+ return this.bindingAsset.getOriginalFileName() || null;
2596
+ }
2597
+ get originalFileNames() {
2598
+ return this.bindingAsset.getOriginalFileNames();
2599
+ }
2600
+ get name() {
2601
+ return this.bindingAsset.getName() ?? void 0;
2602
+ }
2603
+ get names() {
2604
+ return this.bindingAsset.getNames();
2605
+ }
2606
+ get source() {
2607
+ return transformAssetSource(this.bindingAsset.getSource());
2608
+ }
2609
+ __rolldown_external_memory_handle__(keepDataAlive) {
2610
+ if (keepDataAlive) this.#evaluateAllLazyFields();
2611
+ return this.bindingAsset.dropInner();
2612
+ }
2613
+ #evaluateAllLazyFields() {
2614
+ for (const field of getLazyFields(this)) this[field];
2615
+ }
2616
+ };
2617
+ __decorate([lazy], OutputAssetImpl.prototype, "fileName", null);
2618
+ __decorate([lazy], OutputAssetImpl.prototype, "originalFileName", null);
2619
+ __decorate([lazy], OutputAssetImpl.prototype, "originalFileNames", null);
2620
+ __decorate([lazy], OutputAssetImpl.prototype, "name", null);
2621
+ __decorate([lazy], OutputAssetImpl.prototype, "names", null);
2622
+ __decorate([lazy], OutputAssetImpl.prototype, "source", null);
2623
+ __decorate([nonEnumerable], OutputAssetImpl.prototype, "__rolldown_external_memory_handle__", null);
2624
+
2531
2625
  //#endregion
2532
2626
  //#region src/utils/transform-rendered-module.ts
2533
2627
  function transformToRenderedModule(bindingRenderedModule) {
@@ -2593,6 +2687,96 @@ function transformChunkModules(modules) {
2593
2687
  return result;
2594
2688
  }
2595
2689
 
2690
+ //#endregion
2691
+ //#region src/types/output-chunk-impl.ts
2692
+ var OutputChunkImpl = class {
2693
+ type = "chunk";
2694
+ constructor(bindingChunk) {
2695
+ this.bindingChunk = bindingChunk;
2696
+ }
2697
+ get fileName() {
2698
+ return this.bindingChunk.getFileName();
2699
+ }
2700
+ get name() {
2701
+ return this.bindingChunk.getName();
2702
+ }
2703
+ get exports() {
2704
+ return this.bindingChunk.getExports();
2705
+ }
2706
+ get isEntry() {
2707
+ return this.bindingChunk.getIsEntry();
2708
+ }
2709
+ get facadeModuleId() {
2710
+ return this.bindingChunk.getFacadeModuleId() || null;
2711
+ }
2712
+ get isDynamicEntry() {
2713
+ return this.bindingChunk.getIsDynamicEntry();
2714
+ }
2715
+ get sourcemapFileName() {
2716
+ return this.bindingChunk.getSourcemapFileName() || null;
2717
+ }
2718
+ get preliminaryFileName() {
2719
+ return this.bindingChunk.getPreliminaryFileName();
2720
+ }
2721
+ get code() {
2722
+ return this.bindingChunk.getCode();
2723
+ }
2724
+ get modules() {
2725
+ return transformChunkModules(this.bindingChunk.getModules());
2726
+ }
2727
+ get imports() {
2728
+ return this.bindingChunk.getImports();
2729
+ }
2730
+ get dynamicImports() {
2731
+ return this.bindingChunk.getDynamicImports();
2732
+ }
2733
+ get moduleIds() {
2734
+ return this.bindingChunk.getModuleIds();
2735
+ }
2736
+ get map() {
2737
+ const mapString = this.bindingChunk.getMap();
2738
+ return mapString ? transformToRollupSourceMap(mapString) : null;
2739
+ }
2740
+ __rolldown_external_memory_handle__(keepDataAlive) {
2741
+ if (keepDataAlive) this.#evaluateAllLazyFields();
2742
+ return this.bindingChunk.dropInner();
2743
+ }
2744
+ #evaluateAllLazyFields() {
2745
+ for (const field of getLazyFields(this)) this[field];
2746
+ }
2747
+ };
2748
+ __decorate([lazy], OutputChunkImpl.prototype, "fileName", null);
2749
+ __decorate([lazy], OutputChunkImpl.prototype, "name", null);
2750
+ __decorate([lazy], OutputChunkImpl.prototype, "exports", null);
2751
+ __decorate([lazy], OutputChunkImpl.prototype, "isEntry", null);
2752
+ __decorate([lazy], OutputChunkImpl.prototype, "facadeModuleId", null);
2753
+ __decorate([lazy], OutputChunkImpl.prototype, "isDynamicEntry", null);
2754
+ __decorate([lazy], OutputChunkImpl.prototype, "sourcemapFileName", null);
2755
+ __decorate([lazy], OutputChunkImpl.prototype, "preliminaryFileName", null);
2756
+ __decorate([lazy], OutputChunkImpl.prototype, "code", null);
2757
+ __decorate([lazy], OutputChunkImpl.prototype, "modules", null);
2758
+ __decorate([lazy], OutputChunkImpl.prototype, "imports", null);
2759
+ __decorate([lazy], OutputChunkImpl.prototype, "dynamicImports", null);
2760
+ __decorate([lazy], OutputChunkImpl.prototype, "moduleIds", null);
2761
+ __decorate([lazy], OutputChunkImpl.prototype, "map", null);
2762
+ __decorate([nonEnumerable], OutputChunkImpl.prototype, "__rolldown_external_memory_handle__", null);
2763
+
2764
+ //#endregion
2765
+ //#region src/types/sourcemap.ts
2766
+ function bindingifySourcemap$1(map) {
2767
+ if (map == null) return;
2768
+ return { inner: typeof map === "string" ? map : {
2769
+ file: map.file ?? void 0,
2770
+ mappings: map.mappings,
2771
+ sourceRoot: "sourceRoot" in map ? map.sourceRoot ?? void 0 : void 0,
2772
+ sources: map.sources?.map((s) => s ?? void 0),
2773
+ sourcesContent: map.sourcesContent?.map((s) => s ?? void 0),
2774
+ names: map.names,
2775
+ x_google_ignoreList: map.x_google_ignoreList,
2776
+ debugId: "debugId" in map ? map.debugId : void 0
2777
+ } };
2778
+ }
2779
+
2596
2780
  //#endregion
2597
2781
  //#region src/utils/transform-to-rollup-output.ts
2598
2782
  function transformToRollupSourceMap(map) {
@@ -2608,78 +2792,38 @@ function transformToRollupSourceMap(map) {
2608
2792
  return obj;
2609
2793
  }
2610
2794
  function transformToRollupOutputChunk(bindingChunk) {
2611
- const chunk = {
2612
- type: "chunk",
2613
- get code() {
2614
- return bindingChunk.code;
2615
- },
2616
- fileName: bindingChunk.fileName,
2617
- name: bindingChunk.name,
2618
- get modules() {
2619
- return transformChunkModules(bindingChunk.modules);
2620
- },
2621
- get imports() {
2622
- return bindingChunk.imports;
2623
- },
2624
- get dynamicImports() {
2625
- return bindingChunk.dynamicImports;
2626
- },
2627
- exports: bindingChunk.exports,
2628
- isEntry: bindingChunk.isEntry,
2629
- facadeModuleId: bindingChunk.facadeModuleId || null,
2630
- isDynamicEntry: bindingChunk.isDynamicEntry,
2631
- get moduleIds() {
2632
- return bindingChunk.moduleIds;
2633
- },
2634
- get map() {
2635
- return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
2636
- },
2637
- sourcemapFileName: bindingChunk.sourcemapFileName || null,
2638
- preliminaryFileName: bindingChunk.preliminaryFileName
2639
- };
2640
- const cache = {};
2641
- return new Proxy(chunk, {
2642
- get(target, p) {
2643
- if (p in cache) return cache[p];
2644
- const value = target[p];
2645
- cache[p] = value;
2646
- return value;
2647
- },
2648
- has(target, p) {
2649
- if (p in cache) return true;
2650
- return p in target;
2651
- }
2652
- });
2795
+ return new OutputChunkImpl(bindingChunk);
2653
2796
  }
2654
2797
  function transformToMutableRollupOutputChunk(bindingChunk, changed) {
2655
2798
  const chunk = {
2656
2799
  type: "chunk",
2657
2800
  get code() {
2658
- return bindingChunk.code;
2801
+ return bindingChunk.getCode();
2659
2802
  },
2660
- fileName: bindingChunk.fileName,
2661
- name: bindingChunk.name,
2803
+ fileName: bindingChunk.getFileName(),
2804
+ name: bindingChunk.getName(),
2662
2805
  get modules() {
2663
- return transformChunkModules(bindingChunk.modules);
2806
+ return transformChunkModules(bindingChunk.getModules());
2664
2807
  },
2665
2808
  get imports() {
2666
- return bindingChunk.imports;
2809
+ return bindingChunk.getImports();
2667
2810
  },
2668
2811
  get dynamicImports() {
2669
- return bindingChunk.dynamicImports;
2812
+ return bindingChunk.getDynamicImports();
2670
2813
  },
2671
- exports: bindingChunk.exports,
2672
- isEntry: bindingChunk.isEntry,
2673
- facadeModuleId: bindingChunk.facadeModuleId || null,
2674
- isDynamicEntry: bindingChunk.isDynamicEntry,
2814
+ exports: bindingChunk.getExports(),
2815
+ isEntry: bindingChunk.getIsEntry(),
2816
+ facadeModuleId: bindingChunk.getFacadeModuleId() || null,
2817
+ isDynamicEntry: bindingChunk.getIsDynamicEntry(),
2675
2818
  get moduleIds() {
2676
- return bindingChunk.moduleIds;
2819
+ return bindingChunk.getModuleIds();
2677
2820
  },
2678
2821
  get map() {
2679
- return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
2822
+ const map = bindingChunk.getMap();
2823
+ return map ? transformToRollupSourceMap(map) : null;
2680
2824
  },
2681
- sourcemapFileName: bindingChunk.sourcemapFileName || null,
2682
- preliminaryFileName: bindingChunk.preliminaryFileName
2825
+ sourcemapFileName: bindingChunk.getSourcemapFileName() || null,
2826
+ preliminaryFileName: bindingChunk.getPreliminaryFileName()
2683
2827
  };
2684
2828
  const cache = {};
2685
2829
  return new Proxy(chunk, {
@@ -2691,7 +2835,7 @@ function transformToMutableRollupOutputChunk(bindingChunk, changed) {
2691
2835
  },
2692
2836
  set(_target, p, newValue) {
2693
2837
  cache[p] = newValue;
2694
- changed.updated.add(bindingChunk.fileName);
2838
+ changed.updated.add(bindingChunk.getFileName());
2695
2839
  return true;
2696
2840
  },
2697
2841
  has(target, p) {
@@ -2701,36 +2845,19 @@ function transformToMutableRollupOutputChunk(bindingChunk, changed) {
2701
2845
  });
2702
2846
  }
2703
2847
  function transformToRollupOutputAsset(bindingAsset) {
2704
- const asset = {
2705
- type: "asset",
2706
- fileName: bindingAsset.fileName,
2707
- originalFileName: bindingAsset.originalFileName || null,
2708
- originalFileNames: bindingAsset.originalFileNames,
2709
- get source() {
2710
- return transformAssetSource(bindingAsset.source);
2711
- },
2712
- name: bindingAsset.name ?? void 0,
2713
- names: bindingAsset.names
2714
- };
2715
- const cache = {};
2716
- return new Proxy(asset, { get(target, p) {
2717
- if (p in cache) return cache[p];
2718
- const value = target[p];
2719
- cache[p] = value;
2720
- return value;
2721
- } });
2848
+ return new OutputAssetImpl(bindingAsset);
2722
2849
  }
2723
2850
  function transformToMutableRollupOutputAsset(bindingAsset, changed) {
2724
2851
  const asset = {
2725
2852
  type: "asset",
2726
- fileName: bindingAsset.fileName,
2727
- originalFileName: bindingAsset.originalFileName || null,
2728
- originalFileNames: bindingAsset.originalFileNames,
2853
+ fileName: bindingAsset.getFileName(),
2854
+ originalFileName: bindingAsset.getOriginalFileName() || null,
2855
+ originalFileNames: bindingAsset.getOriginalFileNames(),
2729
2856
  get source() {
2730
- return transformAssetSource(bindingAsset.source);
2857
+ return transformAssetSource(bindingAsset.getSource());
2731
2858
  },
2732
- name: bindingAsset.name ?? void 0,
2733
- names: bindingAsset.names
2859
+ name: bindingAsset.getName() ?? void 0,
2860
+ names: bindingAsset.getNames()
2734
2861
  };
2735
2862
  const cache = {};
2736
2863
  return new Proxy(asset, {
@@ -2742,7 +2869,7 @@ function transformToMutableRollupOutputAsset(bindingAsset, changed) {
2742
2869
  },
2743
2870
  set(_target, p, newValue) {
2744
2871
  cache[p] = newValue;
2745
- changed.updated.add(bindingAsset.fileName);
2872
+ changed.updated.add(bindingAsset.getFileName());
2746
2873
  return true;
2747
2874
  }
2748
2875
  });
@@ -2819,10 +2946,23 @@ var RolldownOutputImpl = class {
2819
2946
  get output() {
2820
2947
  return transformToRollupOutput(this.bindingOutputs).output;
2821
2948
  }
2949
+ __rolldown_external_memory_handle__(keepDataAlive) {
2950
+ const results = this.output.map((item) => item.__rolldown_external_memory_handle__(keepDataAlive));
2951
+ if (!results.every((r) => r.freed)) {
2952
+ const reasons = results.filter((r) => !r.freed).map((r) => r.reason).filter(Boolean);
2953
+ return {
2954
+ freed: false,
2955
+ reason: `Failed to free ${reasons.length} item(s): ${reasons.join("; ")}`
2956
+ };
2957
+ }
2958
+ return { freed: true };
2959
+ }
2822
2960
  };
2961
+ __decorate([lazy], RolldownOutputImpl.prototype, "output", null);
2962
+ __decorate([nonEnumerable], RolldownOutputImpl.prototype, "__rolldown_external_memory_handle__", null);
2823
2963
 
2824
2964
  //#endregion
2825
- //#region ../../node_modules/.pnpm/oxc-parser@0.95.0/node_modules/oxc-parser/src-js/wrap.js
2965
+ //#region ../../node_modules/.pnpm/oxc-parser@0.96.0/node_modules/oxc-parser/src-js/wrap.js
2826
2966
  function wrap$1(result) {
2827
2967
  let program, module, comments, errors;
2828
2968
  return {
@@ -2855,7 +2995,7 @@ function applyFix(program, fixPath) {
2855
2995
  if (node.bigint) node.value = BigInt(node.bigint);
2856
2996
  else try {
2857
2997
  node.value = RegExp(node.regex.pattern, node.regex.flags);
2858
- } catch (_err) {}
2998
+ } catch {}
2859
2999
  }
2860
3000
 
2861
3001
  //#endregion
@@ -3510,11 +3650,15 @@ function bindingifyTransform(args$1) {
3510
3650
  const { handler, meta, options } = normalizeHook(hook);
3511
3651
  return {
3512
3652
  plugin: async (ctx, code$1, id$1, meta$1) => {
3653
+ let magicStringInstance, astInstance;
3513
3654
  Object.defineProperties(meta$1, {
3514
3655
  magicString: { get() {
3515
- return new BindingMagicString(code$1);
3656
+ if (magicStringInstance) return magicStringInstance;
3657
+ magicStringInstance = new BindingMagicString(code$1);
3658
+ return magicStringInstance;
3516
3659
  } },
3517
3660
  ast: { get() {
3661
+ if (astInstance) return astInstance;
3518
3662
  let lang = "js";
3519
3663
  switch (meta$1.moduleType) {
3520
3664
  case "js":
@@ -3525,10 +3669,11 @@ function bindingifyTransform(args$1) {
3525
3669
  break;
3526
3670
  default: break;
3527
3671
  }
3528
- return parseAst(code$1, {
3672
+ astInstance = parseAst(code$1, {
3529
3673
  astType: meta$1.moduleType.includes("ts") ? "ts" : "js",
3530
3674
  lang
3531
3675
  });
3676
+ return astInstance;
3532
3677
  } }
3533
3678
  });
3534
3679
  const transformCtx = new TransformPluginContextImpl(args$1.outputOptions, ctx.inner(), args$1.plugin, args$1.pluginContextData, ctx, id$1, code$1, args$1.onLog, args$1.logLevel, args$1.watchMode);
@@ -4706,6 +4851,9 @@ var RolldownBuild = class RolldownBuild {
4706
4851
  const { impl } = await this.#getBundlerWithStopWorker(outputOptions);
4707
4852
  return new RolldownOutputImpl(unwrapBindingResult(await impl.write()));
4708
4853
  }
4854
+ /**
4855
+ * Close the build and free resources.
4856
+ */
4709
4857
  async close() {
4710
4858
  if (this.#bundlerImpl) {
4711
4859
  await this.#bundlerImpl.stopWorkers?.();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rolldown/browser",
3
- "version": "1.0.0-beta.45",
3
+ "version": "1.0.0-beta.47",
4
4
  "description": "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.",
5
5
  "homepage": "https://rolldown.rs/",
6
6
  "type": "module",