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

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.44";
4
+ var version = "1.0.0-beta.45";
5
5
 
6
6
  //#endregion
7
7
  //#region src/utils/code-frame.ts
@@ -1833,6 +1833,25 @@ function tuple(items, message2) {
1833
1833
  };
1834
1834
  }
1835
1835
  /* @__NO_SIDE_EFFECTS__ */
1836
+ function undefined_(message2) {
1837
+ return {
1838
+ kind: "schema",
1839
+ type: "undefined",
1840
+ reference: undefined_,
1841
+ expects: "undefined",
1842
+ async: false,
1843
+ message: message2,
1844
+ get "~standard"() {
1845
+ return /* @__PURE__ */ _getStandardProps(this);
1846
+ },
1847
+ "~run"(dataset, config2) {
1848
+ if (dataset.value === void 0) dataset.typed = true;
1849
+ else _addIssue(this, "type", dataset, config2);
1850
+ return dataset;
1851
+ }
1852
+ };
1853
+ }
1854
+ /* @__NO_SIDE_EFFECTS__ */
1836
1855
  function _subIssues(datasets) {
1837
1856
  let issues;
1838
1857
  if (datasets) for (const dataset of datasets) if (issues) issues.push(...dataset.issues);
@@ -2015,6 +2034,9 @@ function safeParse(schema, input, config2) {
2015
2034
  //#endregion
2016
2035
  //#region src/utils/validator.ts
2017
2036
  const StringOrRegExpSchema = union([string(), instance(RegExp)]);
2037
+ function vFunction() {
2038
+ return function_();
2039
+ }
2018
2040
  const LogLevelSchema = union([
2019
2041
  literal("debug"),
2020
2042
  literal("info"),
@@ -2029,14 +2051,15 @@ const InputOptionSchema = union([
2029
2051
  array(string()),
2030
2052
  record(string(), string())
2031
2053
  ]);
2032
- const ExternalSchema = union([
2054
+ const ExternalOptionFunctionSchema = pipe(vFunction(), args(tuple([
2055
+ string(),
2056
+ optional(string()),
2057
+ boolean()
2058
+ ])), returns(nullish(boolean())));
2059
+ const ExternalOptionSchema = union([
2033
2060
  StringOrRegExpSchema,
2034
2061
  array(StringOrRegExpSchema),
2035
- pipe(function_(), args(tuple([
2036
- string(),
2037
- optional(string()),
2038
- boolean()
2039
- ])), returns(nullish(boolean())))
2062
+ ExternalOptionFunctionSchema
2040
2063
  ]);
2041
2064
  const ModuleTypesSchema = record(string(), union([
2042
2065
  literal("asset"),
@@ -2055,7 +2078,7 @@ const ModuleTypesSchema = record(string(), union([
2055
2078
  const JsxOptionsSchema = strictObject({
2056
2079
  runtime: pipe(optional(union([literal("classic"), literal("automatic")])), description("Which runtime to use")),
2057
2080
  development: pipe(optional(boolean()), description("Development specific information")),
2058
- throwIfNamespace: pipe(optional(string()), description("Toggles whether to throw an error when a tag name uses an XML namespace")),
2081
+ throwIfNamespace: pipe(optional(boolean()), description("Toggles whether to throw an error when a tag name uses an XML namespace")),
2059
2082
  importSource: pipe(optional(string()), description("Import the factory of element and fragment if mode is classic")),
2060
2083
  pragma: pipe(optional(string()), description("Jsx element transformation")),
2061
2084
  pragmaFrag: pipe(optional(string()), description("Jsx fragment transformation")),
@@ -2096,7 +2119,13 @@ const TransformOptionsSchema = object({
2096
2119
  typescript: optional(TypescriptSchema),
2097
2120
  helpers: optional(HelpersSchema),
2098
2121
  decorators: optional(DecoratorOptionSchema),
2099
- jsx: optional(union([literal("preserve"), JsxOptionsSchema])),
2122
+ jsx: optional(union([
2123
+ literal(false),
2124
+ literal("preserve"),
2125
+ literal("react"),
2126
+ literal("react-jsx"),
2127
+ JsxOptionsSchema
2128
+ ])),
2100
2129
  target: pipe(optional(union([string(), array(string())])), description("The JavaScript target environment")),
2101
2130
  define: optional(record(string(), string())),
2102
2131
  inject: optional(record(string(), union([string(), tuple([string(), string()])]))),
@@ -2131,8 +2160,8 @@ const ChecksOptionsSchema = strictObject({
2131
2160
  preferBuiltinFeature: pipe(optional(boolean()), description("Whether to emit warning when detecting prefer builtin feature"))
2132
2161
  });
2133
2162
  const CompressOptionsKeepNamesSchema = strictObject({
2134
- function: optional(boolean()),
2135
- class: optional(boolean())
2163
+ function: boolean(),
2164
+ class: boolean()
2136
2165
  });
2137
2166
  const CompressOptionsSchema = strictObject({
2138
2167
  target: optional(union([
@@ -2154,8 +2183,8 @@ const CompressOptionsSchema = strictObject({
2154
2183
  unused: optional(union([boolean(), literal("keep_assign")]))
2155
2184
  });
2156
2185
  const MangleOptionsKeepNamesSchema = strictObject({
2157
- function: optional(boolean()),
2158
- class: optional(boolean())
2186
+ function: boolean(),
2187
+ class: boolean()
2159
2188
  });
2160
2189
  const MangleOptionsSchema = strictObject({
2161
2190
  toplevel: optional(boolean()),
@@ -2194,22 +2223,19 @@ const TreeshakingOptionsSchema = union([boolean(), looseObject({
2194
2223
  propertyWriteSideEffects: optional(union([literal(false), literal("always")]))
2195
2224
  })]);
2196
2225
  const OptimizationOptionsSchema = strictObject({
2197
- inlineConst: pipe(optional(union([
2198
- boolean(),
2199
- literal("smart"),
2200
- strictObject({
2201
- mode: optional(union([literal("all"), literal("smart")])),
2202
- pass: optional(number())
2203
- })
2204
- ])), description("Enable crossmodule constant inlining")),
2226
+ inlineConst: pipe(optional(union([boolean(), strictObject({
2227
+ mode: optional(union([literal("all"), literal("smart")])),
2228
+ pass: optional(number())
2229
+ })])), description("Enable crossmodule constant inlining")),
2205
2230
  pifeForModuleWrappers: pipe(optional(boolean()), description("Use PIFE pattern for module wrappers"))
2206
2231
  });
2207
- const OnLogSchema = pipe(function_(), args(tuple([
2232
+ const LogOrStringHandlerSchema = pipe(vFunction(), args(tuple([LogLevelWithErrorSchema, RollupLogWithStringSchema])));
2233
+ const OnLogSchema = pipe(vFunction(), args(tuple([
2208
2234
  LogLevelSchema,
2209
2235
  RollupLogSchema,
2210
- pipe(function_(), args(tuple([LogLevelWithErrorSchema, RollupLogWithStringSchema])))
2236
+ LogOrStringHandlerSchema
2211
2237
  ])));
2212
- const OnwarnSchema = pipe(function_(), args(tuple([RollupLogSchema, pipe(function_(), args(tuple([union([RollupLogWithStringSchema, pipe(function_(), returns(RollupLogWithStringSchema))])])))])));
2238
+ const OnwarnSchema = pipe(vFunction(), args(tuple([RollupLogSchema, pipe(vFunction(), args(tuple([union([RollupLogWithStringSchema, pipe(vFunction(), returns(RollupLogWithStringSchema))])])))])));
2213
2239
  const HmrSchema = union([boolean(), strictObject({
2214
2240
  new: optional(boolean()),
2215
2241
  port: optional(number()),
@@ -2219,7 +2245,7 @@ const HmrSchema = union([boolean(), strictObject({
2219
2245
  const InputOptionsSchema = strictObject({
2220
2246
  input: optional(InputOptionSchema),
2221
2247
  plugins: optional(custom(() => true)),
2222
- external: optional(ExternalSchema),
2248
+ external: optional(ExternalOptionSchema),
2223
2249
  makeAbsoluteExternalsRelative: optional(union([boolean(), literal("ifRelativeSource")])),
2224
2250
  resolve: optional(ResolveOptionsSchema),
2225
2251
  cwd: pipe(optional(string()), description("Current working directory")),
@@ -2303,12 +2329,22 @@ const ModuleFormatSchema = union([
2303
2329
  literal("iife"),
2304
2330
  literal("umd")
2305
2331
  ]);
2306
- const AddonFunctionSchema = pipe(function_(), args(tuple([custom(() => true)])), returnsAsync(unionAsync([string(), pipeAsync(promise(), awaitAsync(), string())])));
2307
- const ChunkFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
2308
- const AssetFileNamesSchema = union([string(), pipe(function_(), args(tuple([custom(() => true)])), returns(string()))]);
2309
- const SanitizeFileNameSchema = union([boolean(), pipe(function_(), args(tuple([string()])), returns(string()))]);
2310
- const GlobalsFunctionSchema = pipe(function_(), args(tuple([string()])), returns(string()));
2311
- const PathsFunctionSchema = pipe(function_(), args(tuple([string()])), returns(string()));
2332
+ const AddonFunctionSchema = pipe(vFunction(), args(tuple([custom(() => true)])), returnsAsync(unionAsync([string(), pipeAsync(promise(), awaitAsync(), string())])));
2333
+ const ChunkFileNamesFunctionSchema = pipe(vFunction(), args(tuple([custom(() => true)])), returns(string()));
2334
+ const ChunkFileNamesSchema = union([string(), ChunkFileNamesFunctionSchema]);
2335
+ const AssetFileNamesFunctionSchema = pipe(vFunction(), args(tuple([custom(() => true)])), returns(string()));
2336
+ const AssetFileNamesSchema = union([string(), AssetFileNamesFunctionSchema]);
2337
+ const SanitizeFileNameFunctionSchema = pipe(vFunction(), args(tuple([string()])), returns(string()));
2338
+ const SanitizeFileNameSchema = union([boolean(), SanitizeFileNameFunctionSchema]);
2339
+ const GlobalsFunctionSchema = pipe(vFunction(), args(tuple([string()])), returns(string()));
2340
+ const PathsFunctionSchema = pipe(vFunction(), args(tuple([string()])), returns(string()));
2341
+ const ManualChunksFunctionSchema = pipe(vFunction(), args(tuple([string(), object({})])), returns(nullish(string())));
2342
+ const AdvancedChunksNameFunctionSchema = pipe(vFunction(), args(tuple([string(), object({})])), returns(nullish(string())));
2343
+ const AdvancedChunksTestFunctionSchema = pipe(vFunction(), args(tuple([string()])), returns(union([
2344
+ boolean(),
2345
+ void_(),
2346
+ undefined_()
2347
+ ])));
2312
2348
  const AdvancedChunksSchema = strictObject({
2313
2349
  includeDependenciesRecursively: optional(boolean()),
2314
2350
  minSize: optional(number()),
@@ -2317,12 +2353,8 @@ const AdvancedChunksSchema = strictObject({
2317
2353
  maxModuleSize: optional(number()),
2318
2354
  minShareCount: optional(number()),
2319
2355
  groups: optional(array(strictObject({
2320
- name: union([string(), pipe(function_(), args(tuple([string()])), returns(nullish(string())))]),
2321
- test: optional(union([
2322
- string(),
2323
- instance(RegExp),
2324
- pipe(function_(), args(tuple([string()])), returns(union([nullish(boolean()), void_()])))
2325
- ])),
2356
+ name: union([string(), AdvancedChunksNameFunctionSchema]),
2357
+ test: optional(union([StringOrRegExpSchema, AdvancedChunksTestFunctionSchema])),
2326
2358
  priority: optional(number()),
2327
2359
  minSize: optional(number()),
2328
2360
  minShareCount: optional(number()),
@@ -2379,7 +2411,7 @@ const OutputOptionsSchema = strictObject({
2379
2411
  sanitizeFileName: optional(SanitizeFileNameSchema),
2380
2412
  minify: pipe(optional(union([
2381
2413
  boolean(),
2382
- string("dce-only"),
2414
+ literal("dce-only"),
2383
2415
  MinifyOptionsSchema
2384
2416
  ])), description("Minify the bundled file")),
2385
2417
  name: pipe(optional(string()), description("Name for UMD / IIFE format outputs")),
@@ -2388,15 +2420,12 @@ const OutputOptionsSchema = strictObject({
2388
2420
  generatedCode: pipe(optional(partial(GeneratedCodeOptionsSchema)), description("Generated code options")),
2389
2421
  externalLiveBindings: pipe(optional(boolean()), description("external live bindings")),
2390
2422
  inlineDynamicImports: pipe(optional(boolean()), description("Inline dynamic imports")),
2391
- manualChunks: optional(pipe(function_(), args(tuple([string(), object({})])), returns(union([string(), nullish(string())])))),
2423
+ manualChunks: optional(ManualChunksFunctionSchema),
2392
2424
  advancedChunks: optional(AdvancedChunksSchema),
2393
2425
  legalComments: pipe(optional(union([literal("none"), literal("inline")])), description("Control comments in the output")),
2394
2426
  plugins: optional(custom(() => true)),
2395
2427
  polyfillRequire: pipe(optional(boolean()), description("Disable require polyfill injection")),
2396
- hoistTransitiveImports: optional(custom((input) => {
2397
- if (input) return false;
2398
- return true;
2399
- }, () => `The 'true' value is not supported`)),
2428
+ hoistTransitiveImports: optional(literal(false)),
2400
2429
  preserveModules: pipe(optional(boolean()), description("Preserve module structure")),
2401
2430
  preserveModulesRoot: pipe(optional(string()), description("Put preserved modules under this path at root level")),
2402
2431
  virtualDirname: optional(string()),
@@ -2474,6 +2503,324 @@ function validateOption(key, options) {
2474
2503
  }
2475
2504
  }
2476
2505
 
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
+ } };
2520
+ }
2521
+
2522
+ //#endregion
2523
+ //#region src/utils/asset-source.ts
2524
+ function transformAssetSource(bindingAssetSource$1) {
2525
+ return bindingAssetSource$1.inner;
2526
+ }
2527
+ function bindingAssetSource(source) {
2528
+ return { inner: source };
2529
+ }
2530
+
2531
+ //#endregion
2532
+ //#region src/utils/transform-rendered-module.ts
2533
+ function transformToRenderedModule(bindingRenderedModule) {
2534
+ return {
2535
+ get code() {
2536
+ return bindingRenderedModule.code;
2537
+ },
2538
+ get renderedLength() {
2539
+ return bindingRenderedModule.code?.length || 0;
2540
+ },
2541
+ get renderedExports() {
2542
+ return bindingRenderedModule.renderedExports;
2543
+ }
2544
+ };
2545
+ }
2546
+
2547
+ //#endregion
2548
+ //#region src/utils/transform-rendered-chunk.ts
2549
+ function transformRenderedChunk(chunk) {
2550
+ let modules = null;
2551
+ return {
2552
+ type: "chunk",
2553
+ get name() {
2554
+ return chunk.name;
2555
+ },
2556
+ get isEntry() {
2557
+ return chunk.isEntry;
2558
+ },
2559
+ get isDynamicEntry() {
2560
+ return chunk.isDynamicEntry;
2561
+ },
2562
+ get facadeModuleId() {
2563
+ return chunk.facadeModuleId;
2564
+ },
2565
+ get moduleIds() {
2566
+ return chunk.moduleIds;
2567
+ },
2568
+ get exports() {
2569
+ return chunk.exports;
2570
+ },
2571
+ get fileName() {
2572
+ return chunk.fileName;
2573
+ },
2574
+ get imports() {
2575
+ return chunk.imports;
2576
+ },
2577
+ get dynamicImports() {
2578
+ return chunk.dynamicImports;
2579
+ },
2580
+ get modules() {
2581
+ if (!modules) modules = transformChunkModules(chunk.modules);
2582
+ return modules;
2583
+ }
2584
+ };
2585
+ }
2586
+ function transformChunkModules(modules) {
2587
+ const result = {};
2588
+ for (let i = 0; i < modules.values.length; i++) {
2589
+ let key = modules.keys[i];
2590
+ const mod = modules.values[i];
2591
+ result[key] = transformToRenderedModule(mod);
2592
+ }
2593
+ return result;
2594
+ }
2595
+
2596
+ //#endregion
2597
+ //#region src/utils/transform-to-rollup-output.ts
2598
+ function transformToRollupSourceMap(map) {
2599
+ const obj = {
2600
+ ...JSON.parse(map),
2601
+ toString() {
2602
+ return JSON.stringify(obj);
2603
+ },
2604
+ toUrl() {
2605
+ return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
2606
+ }
2607
+ };
2608
+ return obj;
2609
+ }
2610
+ 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
+ });
2653
+ }
2654
+ function transformToMutableRollupOutputChunk(bindingChunk, changed) {
2655
+ const chunk = {
2656
+ type: "chunk",
2657
+ get code() {
2658
+ return bindingChunk.code;
2659
+ },
2660
+ fileName: bindingChunk.fileName,
2661
+ name: bindingChunk.name,
2662
+ get modules() {
2663
+ return transformChunkModules(bindingChunk.modules);
2664
+ },
2665
+ get imports() {
2666
+ return bindingChunk.imports;
2667
+ },
2668
+ get dynamicImports() {
2669
+ return bindingChunk.dynamicImports;
2670
+ },
2671
+ exports: bindingChunk.exports,
2672
+ isEntry: bindingChunk.isEntry,
2673
+ facadeModuleId: bindingChunk.facadeModuleId || null,
2674
+ isDynamicEntry: bindingChunk.isDynamicEntry,
2675
+ get moduleIds() {
2676
+ return bindingChunk.moduleIds;
2677
+ },
2678
+ get map() {
2679
+ return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
2680
+ },
2681
+ sourcemapFileName: bindingChunk.sourcemapFileName || null,
2682
+ preliminaryFileName: bindingChunk.preliminaryFileName
2683
+ };
2684
+ const cache = {};
2685
+ return new Proxy(chunk, {
2686
+ get(target, p) {
2687
+ if (p in cache) return cache[p];
2688
+ const value = target[p];
2689
+ cache[p] = value;
2690
+ return value;
2691
+ },
2692
+ set(_target, p, newValue) {
2693
+ cache[p] = newValue;
2694
+ changed.updated.add(bindingChunk.fileName);
2695
+ return true;
2696
+ },
2697
+ has(target, p) {
2698
+ if (p in cache) return true;
2699
+ return p in target;
2700
+ }
2701
+ });
2702
+ }
2703
+ 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
+ } });
2722
+ }
2723
+ function transformToMutableRollupOutputAsset(bindingAsset, changed) {
2724
+ const asset = {
2725
+ type: "asset",
2726
+ fileName: bindingAsset.fileName,
2727
+ originalFileName: bindingAsset.originalFileName || null,
2728
+ originalFileNames: bindingAsset.originalFileNames,
2729
+ get source() {
2730
+ return transformAssetSource(bindingAsset.source);
2731
+ },
2732
+ name: bindingAsset.name ?? void 0,
2733
+ names: bindingAsset.names
2734
+ };
2735
+ const cache = {};
2736
+ return new Proxy(asset, {
2737
+ get(target, p) {
2738
+ if (p in cache) return cache[p];
2739
+ const value = target[p];
2740
+ cache[p] = value;
2741
+ return value;
2742
+ },
2743
+ set(_target, p, newValue) {
2744
+ cache[p] = newValue;
2745
+ changed.updated.add(bindingAsset.fileName);
2746
+ return true;
2747
+ }
2748
+ });
2749
+ }
2750
+ function transformToRollupOutput(output) {
2751
+ const { chunks, assets } = output;
2752
+ return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk)), ...assets.map((asset) => transformToRollupOutputAsset(asset))] };
2753
+ }
2754
+ function transformToMutableRollupOutput(output, changed) {
2755
+ const { chunks, assets } = output;
2756
+ return { output: [...chunks.map((chunk) => transformToMutableRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToMutableRollupOutputAsset(asset, changed))] };
2757
+ }
2758
+ function transformToOutputBundle(context, output, changed) {
2759
+ const bundle = Object.fromEntries(transformToMutableRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
2760
+ return new Proxy(bundle, {
2761
+ set(_target, _p, _newValue, _receiver) {
2762
+ const originalStackTraceLimit = Error.stackTraceLimit;
2763
+ Error.stackTraceLimit = 2;
2764
+ const message = "This plugin assigns to bundle variable. This is discouraged by Rollup and is not supported by Rolldown. This will be ignored. https://rollupjs.org/plugin-development/#generatebundle:~:text=DANGER,this.emitFile.";
2765
+ const stack = new Error(message).stack ?? message;
2766
+ Error.stackTraceLimit = originalStackTraceLimit;
2767
+ context.warn({
2768
+ message: stack,
2769
+ code: "UNSUPPORTED_BUNDLE_ASSIGNMENT"
2770
+ });
2771
+ return true;
2772
+ },
2773
+ deleteProperty(target, property) {
2774
+ if (typeof property === "string") changed.deleted.add(property);
2775
+ return true;
2776
+ }
2777
+ });
2778
+ }
2779
+ function collectChangedBundle(changed, bundle) {
2780
+ const changes = {};
2781
+ for (const key in bundle) {
2782
+ if (changed.deleted.has(key) || !changed.updated.has(key)) continue;
2783
+ const item = bundle[key];
2784
+ if (item.type === "asset") changes[key] = {
2785
+ filename: item.fileName,
2786
+ originalFileNames: item.originalFileNames,
2787
+ source: bindingAssetSource(item.source),
2788
+ names: item.names
2789
+ };
2790
+ else changes[key] = {
2791
+ code: item.code,
2792
+ filename: item.fileName,
2793
+ name: item.name,
2794
+ isEntry: item.isEntry,
2795
+ exports: item.exports,
2796
+ modules: {},
2797
+ imports: item.imports,
2798
+ dynamicImports: item.dynamicImports,
2799
+ facadeModuleId: item.facadeModuleId || void 0,
2800
+ isDynamicEntry: item.isDynamicEntry,
2801
+ moduleIds: item.moduleIds,
2802
+ map: bindingifySourcemap$1(item.map),
2803
+ sourcemapFilename: item.sourcemapFileName || void 0,
2804
+ preliminaryFilename: item.preliminaryFileName
2805
+ };
2806
+ }
2807
+ return {
2808
+ changes,
2809
+ deleted: changed.deleted
2810
+ };
2811
+ }
2812
+
2813
+ //#endregion
2814
+ //#region src/types/rolldown-output-impl.ts
2815
+ var RolldownOutputImpl = class {
2816
+ constructor(bindingOutputs) {
2817
+ this.bindingOutputs = bindingOutputs;
2818
+ }
2819
+ get output() {
2820
+ return transformToRollupOutput(this.bindingOutputs).output;
2821
+ }
2822
+ };
2823
+
2477
2824
  //#endregion
2478
2825
  //#region ../../node_modules/.pnpm/oxc-parser@0.95.0/node_modules/oxc-parser/src-js/wrap.js
2479
2826
  function wrap$1(result) {
@@ -2545,22 +2892,6 @@ function parseAst(sourceText, options, filename) {
2545
2892
  }), sourceText);
2546
2893
  }
2547
2894
 
2548
- //#endregion
2549
- //#region src/types/sourcemap.ts
2550
- function bindingifySourcemap$1(map) {
2551
- if (map == null) return;
2552
- return { inner: typeof map === "string" ? map : {
2553
- file: map.file ?? void 0,
2554
- mappings: map.mappings,
2555
- sourceRoot: "sourceRoot" in map ? map.sourceRoot ?? void 0 : void 0,
2556
- sources: map.sources?.map((s) => s ?? void 0),
2557
- sourcesContent: map.sourcesContent?.map((s) => s ?? void 0),
2558
- names: map.names,
2559
- x_google_ignoreList: map.x_google_ignoreList,
2560
- debugId: "debugId" in map ? map.debugId : void 0
2561
- } };
2562
- }
2563
-
2564
2895
  //#endregion
2565
2896
  //#region src/utils/error.ts
2566
2897
  function unwrapBindingResult(container) {
@@ -2663,7 +2994,7 @@ function normalizeTransformHookSourcemap(id$1, originalCode, rawMap) {
2663
2994
  }
2664
2995
 
2665
2996
  //#endregion
2666
- //#region ../pluginutils/dist/index.mjs
2997
+ //#region ../pluginutils/dist/composable-filters.js
2667
2998
  var And = class {
2668
2999
  kind;
2669
3000
  args;
@@ -2925,15 +3256,6 @@ function bindingPluginOrder(order) {
2925
3256
  }
2926
3257
  }
2927
3258
 
2928
- //#endregion
2929
- //#region src/utils/asset-source.ts
2930
- function transformAssetSource(bindingAssetSource$1) {
2931
- return bindingAssetSource$1.inner;
2932
- }
2933
- function bindingAssetSource(source) {
2934
- return { inner: source };
2935
- }
2936
-
2937
3259
  //#endregion
2938
3260
  //#region src/plugin/fs.ts
2939
3261
  const fsModule = {
@@ -3286,220 +3608,6 @@ function bindingifyModuleParsed(args$1) {
3286
3608
  };
3287
3609
  }
3288
3610
 
3289
- //#endregion
3290
- //#region src/utils/transform-rendered-module.ts
3291
- function transformToRenderedModule(bindingRenderedModule) {
3292
- return {
3293
- get code() {
3294
- return bindingRenderedModule.code;
3295
- },
3296
- get renderedLength() {
3297
- return bindingRenderedModule.code?.length || 0;
3298
- },
3299
- get renderedExports() {
3300
- return bindingRenderedModule.renderedExports;
3301
- }
3302
- };
3303
- }
3304
-
3305
- //#endregion
3306
- //#region src/utils/transform-rendered-chunk.ts
3307
- function transformRenderedChunk(chunk) {
3308
- let modules = null;
3309
- return {
3310
- type: "chunk",
3311
- get name() {
3312
- return chunk.name;
3313
- },
3314
- get isEntry() {
3315
- return chunk.isEntry;
3316
- },
3317
- get isDynamicEntry() {
3318
- return chunk.isDynamicEntry;
3319
- },
3320
- get facadeModuleId() {
3321
- return chunk.facadeModuleId;
3322
- },
3323
- get moduleIds() {
3324
- return chunk.moduleIds;
3325
- },
3326
- get exports() {
3327
- return chunk.exports;
3328
- },
3329
- get fileName() {
3330
- return chunk.fileName;
3331
- },
3332
- get imports() {
3333
- return chunk.imports;
3334
- },
3335
- get dynamicImports() {
3336
- return chunk.dynamicImports;
3337
- },
3338
- get modules() {
3339
- if (!modules) modules = transformChunkModules(chunk.modules);
3340
- return modules;
3341
- }
3342
- };
3343
- }
3344
- function transformChunkModules(modules) {
3345
- const result = {};
3346
- for (let i = 0; i < modules.values.length; i++) {
3347
- let key = modules.keys[i];
3348
- const mod = modules.values[i];
3349
- result[key] = transformToRenderedModule(mod);
3350
- }
3351
- return result;
3352
- }
3353
-
3354
- //#endregion
3355
- //#region src/utils/transform-to-rollup-output.ts
3356
- function transformToRollupSourceMap(map) {
3357
- const obj = {
3358
- ...JSON.parse(map),
3359
- toString() {
3360
- return JSON.stringify(obj);
3361
- },
3362
- toUrl() {
3363
- return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), "utf-8").toString("base64")}`;
3364
- }
3365
- };
3366
- return obj;
3367
- }
3368
- function transformToRollupOutputChunk(bindingChunk, changed) {
3369
- const chunk = {
3370
- type: "chunk",
3371
- get code() {
3372
- return bindingChunk.code;
3373
- },
3374
- fileName: bindingChunk.fileName,
3375
- name: bindingChunk.name,
3376
- get modules() {
3377
- return transformChunkModules(bindingChunk.modules);
3378
- },
3379
- get imports() {
3380
- return bindingChunk.imports;
3381
- },
3382
- get dynamicImports() {
3383
- return bindingChunk.dynamicImports;
3384
- },
3385
- exports: bindingChunk.exports,
3386
- isEntry: bindingChunk.isEntry,
3387
- facadeModuleId: bindingChunk.facadeModuleId || null,
3388
- isDynamicEntry: bindingChunk.isDynamicEntry,
3389
- get moduleIds() {
3390
- return bindingChunk.moduleIds;
3391
- },
3392
- get map() {
3393
- return bindingChunk.map ? transformToRollupSourceMap(bindingChunk.map) : null;
3394
- },
3395
- sourcemapFileName: bindingChunk.sourcemapFileName || null,
3396
- preliminaryFileName: bindingChunk.preliminaryFileName
3397
- };
3398
- const cache = {};
3399
- return new Proxy(chunk, {
3400
- get(target, p) {
3401
- if (p in cache) return cache[p];
3402
- const value = target[p];
3403
- cache[p] = value;
3404
- return value;
3405
- },
3406
- set(_target, p, newValue) {
3407
- cache[p] = newValue;
3408
- changed?.updated.add(bindingChunk.fileName);
3409
- return true;
3410
- },
3411
- has(target, p) {
3412
- if (p in cache) return true;
3413
- return p in target;
3414
- }
3415
- });
3416
- }
3417
- function transformToRollupOutputAsset(bindingAsset, changed) {
3418
- const asset = {
3419
- type: "asset",
3420
- fileName: bindingAsset.fileName,
3421
- originalFileName: bindingAsset.originalFileName || null,
3422
- originalFileNames: bindingAsset.originalFileNames,
3423
- get source() {
3424
- return transformAssetSource(bindingAsset.source);
3425
- },
3426
- name: bindingAsset.name ?? void 0,
3427
- names: bindingAsset.names
3428
- };
3429
- const cache = {};
3430
- return new Proxy(asset, {
3431
- get(target, p) {
3432
- if (p in cache) return cache[p];
3433
- const value = target[p];
3434
- cache[p] = value;
3435
- return value;
3436
- },
3437
- set(_target, p, newValue) {
3438
- cache[p] = newValue;
3439
- changed?.updated.add(bindingAsset.fileName);
3440
- return true;
3441
- }
3442
- });
3443
- }
3444
- function transformToRollupOutput(output, changed) {
3445
- const { chunks, assets } = output;
3446
- return { output: [...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)), ...assets.map((asset) => transformToRollupOutputAsset(asset, changed))] };
3447
- }
3448
- function transformToOutputBundle(context, output, changed) {
3449
- const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [item.fileName, item]));
3450
- return new Proxy(bundle, {
3451
- set(_target, _p, _newValue, _receiver) {
3452
- const originalStackTraceLimit = Error.stackTraceLimit;
3453
- Error.stackTraceLimit = 2;
3454
- const message = "This plugin assigns to bundle variable. This is discouraged by Rollup and is not supported by Rolldown. This will be ignored. https://rollupjs.org/plugin-development/#generatebundle:~:text=DANGER,this.emitFile.";
3455
- const stack = new Error(message).stack ?? message;
3456
- Error.stackTraceLimit = originalStackTraceLimit;
3457
- context.warn({
3458
- message: stack,
3459
- code: "UNSUPPORTED_BUNDLE_ASSIGNMENT"
3460
- });
3461
- return true;
3462
- },
3463
- deleteProperty(target, property) {
3464
- if (typeof property === "string") changed.deleted.add(property);
3465
- return true;
3466
- }
3467
- });
3468
- }
3469
- function collectChangedBundle(changed, bundle) {
3470
- const changes = {};
3471
- for (const key in bundle) {
3472
- if (changed.deleted.has(key) || !changed.updated.has(key)) continue;
3473
- const item = bundle[key];
3474
- if (item.type === "asset") changes[key] = {
3475
- filename: item.fileName,
3476
- originalFileNames: item.originalFileNames,
3477
- source: bindingAssetSource(item.source),
3478
- names: item.names
3479
- };
3480
- else changes[key] = {
3481
- code: item.code,
3482
- filename: item.fileName,
3483
- name: item.name,
3484
- isEntry: item.isEntry,
3485
- exports: item.exports,
3486
- modules: {},
3487
- imports: item.imports,
3488
- dynamicImports: item.dynamicImports,
3489
- facadeModuleId: item.facadeModuleId || void 0,
3490
- isDynamicEntry: item.isDynamicEntry,
3491
- moduleIds: item.moduleIds,
3492
- map: bindingifySourcemap$1(item.map),
3493
- sourcemapFilename: item.sourcemapFileName || void 0,
3494
- preliminaryFilename: item.preliminaryFileName
3495
- };
3496
- }
3497
- return {
3498
- changes,
3499
- deleted: changed.deleted
3500
- };
3501
- }
3502
-
3503
3611
  //#endregion
3504
3612
  //#region src/plugin/bindingify-output-hooks.ts
3505
3613
  function bindingifyRenderStart(args$1) {
@@ -3539,7 +3647,7 @@ function bindingifyAugmentChunkHash(args$1) {
3539
3647
  const { handler, meta } = normalizeHook(hook);
3540
3648
  return {
3541
3649
  plugin: async (ctx, chunk) => {
3542
- return await handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), transformRenderedChunk(chunk));
3650
+ return handler.call(new PluginContextImpl(args$1.outputOptions, ctx, args$1.plugin, args$1.pluginContextData, args$1.onLog, args$1.logLevel, args$1.watchMode), transformRenderedChunk(chunk));
3543
3651
  },
3544
3652
  meta: bindingifyPluginHookMeta(meta)
3545
3653
  };
@@ -4591,12 +4699,12 @@ var RolldownBuild = class RolldownBuild {
4591
4699
  async generate(outputOptions = {}) {
4592
4700
  validateOption("output", outputOptions);
4593
4701
  const { impl } = await this.#getBundlerWithStopWorker(outputOptions);
4594
- return transformToRollupOutput(unwrapBindingResult(await impl.generate()));
4702
+ return new RolldownOutputImpl(unwrapBindingResult(await impl.generate()));
4595
4703
  }
4596
4704
  async write(outputOptions = {}) {
4597
4705
  validateOption("output", outputOptions);
4598
4706
  const { impl } = await this.#getBundlerWithStopWorker(outputOptions);
4599
- return transformToRollupOutput(unwrapBindingResult(await impl.write()));
4707
+ return new RolldownOutputImpl(unwrapBindingResult(await impl.write()));
4600
4708
  }
4601
4709
  async close() {
4602
4710
  if (this.#bundlerImpl) {
@@ -4777,4 +4885,4 @@ function defineConfig(config) {
4777
4885
  const VERSION = version;
4778
4886
 
4779
4887
  //#endregion
4780
- export { build as a, createBundlerOptions as c, normalizeBindingResult as d, bindingifySourcemap$1 as f, makeBuiltinPluginCallable as h, watch as i, normalizedStringOrRegex as l, BuiltinPlugin as m, VERSION as n, rolldown as o, PluginDriver as p, defineConfig as r, RolldownBuild as s, BindingMagicString$1 as t, transformToRollupOutput as u };
4888
+ export { build as a, createBundlerOptions as c, transformToRollupOutput as d, bindingifySourcemap$1 as f, makeBuiltinPluginCallable as h, watch as i, normalizedStringOrRegex as l, BuiltinPlugin as m, VERSION as n, rolldown as o, PluginDriver as p, defineConfig as r, RolldownBuild as s, BindingMagicString$1 as t, normalizeBindingResult as u };