@rollipop/rolldown 1.0.0-rc.2 → 1.0.0-rc.3

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.
Files changed (44) hide show
  1. package/dist/cli-setup.mjs +1 -1
  2. package/dist/cli.mjs +27 -996
  3. package/dist/config.d.mts +10 -5
  4. package/dist/config.mjs +9 -12
  5. package/dist/experimental-index.d.mts +72 -14
  6. package/dist/experimental-index.mjs +64 -11
  7. package/dist/experimental-runtime-types.d.ts +0 -5
  8. package/dist/filter-index.d.mts +2 -2
  9. package/dist/filter-index.mjs +24 -1
  10. package/dist/get-log-filter.d.mts +3 -7
  11. package/dist/get-log-filter.mjs +23 -2
  12. package/dist/index.d.mts +4 -4
  13. package/dist/index.mjs +10 -9
  14. package/dist/parallel-plugin-worker.mjs +5 -4
  15. package/dist/parallel-plugin.d.mts +2 -2
  16. package/dist/parse-ast-index.d.mts +26 -2
  17. package/dist/parse-ast-index.mjs +61 -2
  18. package/dist/plugins-index.d.mts +8 -5
  19. package/dist/plugins-index.mjs +8 -5
  20. package/dist/shared/{binding-Bo6UcGYl.d.mts → binding-C4ZlFAt6.d.mts} +302 -117
  21. package/dist/shared/{binding-9QXxzPo6.mjs → binding-D25Pz9Tj.mjs} +32 -26
  22. package/dist/shared/{bindingify-input-options-C--dZCPv.mjs → bindingify-input-options-D6jfpJ6l.mjs} +52 -113
  23. package/dist/shared/{constructors-DsYXT8FB.mjs → constructors-BAGdj697.mjs} +8 -5
  24. package/dist/shared/{constructors-B64fS2o1.d.mts → constructors-C-tyKVjw.d.mts} +9 -4
  25. package/dist/shared/{define-config-DT_Hpxdr.d.mts → define-config-BKLqq_zt.d.mts} +148 -43
  26. package/dist/shared/error-BoaGIj5N.mjs +90 -0
  27. package/dist/shared/get-log-filter-semyr3Lj.d.mts +35 -0
  28. package/dist/shared/{load-config-TBowPn4n.mjs → load-config-CV5K8wKJ.mjs} +10 -2
  29. package/dist/shared/{logs-NH298mHo.mjs → logs-CCc_0vhs.mjs} +1 -1
  30. package/dist/shared/{normalize-string-or-regex-CaBvmZZK.mjs → normalize-string-or-regex-tBSnk6HY.mjs} +2 -2
  31. package/dist/shared/parse-DWZRPGsB.mjs +77 -0
  32. package/dist/shared/{rolldown-5hTSdYMy.mjs → rolldown-CZ1SIh-x.mjs} +1 -1
  33. package/dist/shared/{rolldown-build-B7oitB1K.mjs → rolldown-build-BYA-VVk0.mjs} +1019 -26
  34. package/dist/shared/transform-CIcvJTbn.mjs +93 -0
  35. package/dist/shared/transform-DoG7c5_r.d.mts +132 -0
  36. package/dist/shared/{watch-CkctCkiN.mjs → watch-DV7vV2OV.mjs} +6 -5
  37. package/dist/utils-index.d.mts +376 -0
  38. package/dist/utils-index.mjs +2426 -0
  39. package/package.json +17 -16
  40. package/dist/shared/parse-ast-index-BQ9Myuc2.mjs +0 -99
  41. /package/dist/shared/{define-config-BVG4QvnP.mjs → define-config-BMj_QknW.mjs} +0 -0
  42. /package/dist/shared/{logging-CE90D8JR.d.mts → logging-C6h4g8dA.d.mts} +0 -0
  43. /package/dist/shared/{misc-CCZIsXVO.mjs → misc-Xty885dB.mjs} +0 -0
  44. /package/dist/shared/{prompt-CI-U8Lh4.mjs → prompt-B56gTa4S.mjs} +0 -0
@@ -1,5 +1,5 @@
1
- import { C as BindingViteWasmHelperPluginConfig, b as BindingViteReporterPluginConfig, g as BindingViteJsonPluginConfig, h as BindingViteImportGlobPluginConfig, i as BindingEsmExternalRequirePluginConfig, m as BindingViteDynamicImportVarsPluginConfig, o as BindingIsolatedDeclarationPluginConfig, p as BindingViteBuildImportAnalysisPluginConfig, v as BindingViteModulePreloadPolyfillPluginConfig, x as BindingViteResolvePluginConfig, y as BindingViteReactRefreshWrapperPluginConfig } from "./binding-Bo6UcGYl.mjs";
2
- import { It as StringOrRegExp, M as BuiltinPlugin } from "./define-config-DT_Hpxdr.mjs";
1
+ import { C as BindingViteModulePreloadPolyfillPluginConfig, E as BindingViteResolvePluginConfig, T as BindingViteReporterPluginConfig, b as BindingViteImportGlobPluginConfig, l as BindingIsolatedDeclarationPluginConfig, s as BindingEsmExternalRequirePluginConfig, v as BindingViteBuildImportAnalysisPluginConfig, w as BindingViteReactRefreshWrapperPluginConfig, x as BindingViteJsonPluginConfig, y as BindingViteDynamicImportVarsPluginConfig } from "./binding-C4ZlFAt6.mjs";
2
+ import { M as BuiltinPlugin, Rt as StringOrRegExp } from "./define-config-BKLqq_zt.mjs";
3
3
 
4
4
  //#region src/builtin-plugin/constructors.d.ts
5
5
  declare function viteModulePreloadPolyfillPlugin(config?: BindingViteModulePreloadPolyfillPluginConfig): BuiltinPlugin;
@@ -10,7 +10,6 @@ type DynamicImportVarsPluginConfig = Omit<BindingViteDynamicImportVarsPluginConf
10
10
  declare function viteDynamicImportVarsPlugin(config?: DynamicImportVarsPluginConfig): BuiltinPlugin;
11
11
  declare function viteImportGlobPlugin(config?: BindingViteImportGlobPluginConfig): BuiltinPlugin;
12
12
  declare function viteReporterPlugin(config: BindingViteReporterPluginConfig): BuiltinPlugin;
13
- declare function viteWasmHelperPlugin(config: BindingViteWasmHelperPluginConfig): BuiltinPlugin;
14
13
  declare function viteWasmFallbackPlugin(): BuiltinPlugin;
15
14
  declare function viteLoadFallbackPlugin(): BuiltinPlugin;
16
15
  declare function viteJsonPlugin(config: BindingViteJsonPluginConfig): BuiltinPlugin;
@@ -18,6 +17,12 @@ declare function viteBuildImportAnalysisPlugin(config: BindingViteBuildImportAna
18
17
  declare function viteResolvePlugin(config: Omit<BindingViteResolvePluginConfig, "yarnPnp">): BuiltinPlugin;
19
18
  declare function isolatedDeclarationPlugin(config?: BindingIsolatedDeclarationPluginConfig): BuiltinPlugin;
20
19
  declare function viteWebWorkerPostPlugin(): BuiltinPlugin;
20
+ /**
21
+ * A plugin that converts CommonJS require() calls for external dependencies into ESM import statements.
22
+ *
23
+ * @see https://rolldown.rs/builtin-plugins/esm-external-require
24
+ * @category Builtin Plugins
25
+ */
21
26
  declare function esmExternalRequirePlugin(config?: BindingEsmExternalRequirePluginConfig): BuiltinPlugin;
22
27
  type ViteReactRefreshWrapperPluginConfig = Omit<BindingViteReactRefreshWrapperPluginConfig, "include" | "exclude"> & {
23
28
  include?: StringOrRegExp | StringOrRegExp[];
@@ -25,4 +30,4 @@ type ViteReactRefreshWrapperPluginConfig = Omit<BindingViteReactRefreshWrapperPl
25
30
  };
26
31
  declare function viteReactRefreshWrapperPlugin(config: ViteReactRefreshWrapperPluginConfig): BuiltinPlugin;
27
32
  //#endregion
28
- export { viteImportGlobPlugin as a, viteModulePreloadPolyfillPlugin as c, viteResolvePlugin as d, viteWasmFallbackPlugin as f, viteDynamicImportVarsPlugin as i, viteReactRefreshWrapperPlugin as l, viteWebWorkerPostPlugin as m, isolatedDeclarationPlugin as n, viteJsonPlugin as o, viteWasmHelperPlugin as p, viteBuildImportAnalysisPlugin as r, viteLoadFallbackPlugin as s, esmExternalRequirePlugin as t, viteReporterPlugin as u };
33
+ export { viteImportGlobPlugin as a, viteModulePreloadPolyfillPlugin as c, viteResolvePlugin as d, viteWasmFallbackPlugin as f, viteDynamicImportVarsPlugin as i, viteReactRefreshWrapperPlugin as l, isolatedDeclarationPlugin as n, viteJsonPlugin as o, viteWebWorkerPostPlugin as p, viteBuildImportAnalysisPlugin as r, viteLoadFallbackPlugin as s, esmExternalRequirePlugin as t, viteReporterPlugin as u };
@@ -1,5 +1,5 @@
1
- import { a as RolldownLog, i as RolldownError, n as LogLevelOption, o as RolldownLogWithString, r as LogOrStringHandler, t as LogLevel } from "./logging-CE90D8JR.mjs";
2
- import { L as TransformOptions$1, N as ParserOptions, O as JsxOptions, P as PreRenderedChunk, T as ExternalMemoryStatus, a as BindingHookResolveIdExtraArgs, c as BindingPluginContextResolveOptions, f as BindingTransformHookExtraArgs, k as MinifyOptions$1, s as BindingMagicString, t as BindingBuiltinPluginName, u as BindingRenderedChunk, w as BindingWatcherBundler } from "./binding-Bo6UcGYl.mjs";
1
+ import { a as RolldownLog, i as RolldownError, n as LogLevelOption, o as RolldownLogWithString, r as LogOrStringHandler, t as LogLevel } from "./logging-C6h4g8dA.mjs";
2
+ import { H as TransformOptions$1, L as ParserOptions, M as JsxOptions, N as MinifyOptions$1, O as BindingWatcherBundler, R as PreRenderedChunk, c as BindingHookResolveIdExtraArgs, d as BindingPluginContextResolveOptions, h as BindingTransformHookExtraArgs, k as ExternalMemoryStatus, p as BindingRenderedChunk, t as BindingBuiltinPluginName, u as BindingMagicString } from "./binding-C4ZlFAt6.mjs";
3
3
  import { TopLevelFilterExpression } from "@rollipop/rolldown-pluginutils";
4
4
  import { Program } from "@oxc-project/types";
5
5
 
@@ -50,6 +50,16 @@ interface ModuleInfo extends ModuleOptions {
50
50
  * Whether this module is a user- or plugin-defined entry point.
51
51
  */
52
52
  isEntry: boolean;
53
+ /**
54
+ * The detected format of the module, based on both its syntax and module definition
55
+ * metadata (such as `package.json` `type` and file extensions like `.mjs`/`.cjs`/`.mts`/`.cts`).
56
+ * - "esm" for ES modules (has `import`/`export` statements or is defined as ESM by module metadata)
57
+ * - "cjs" for CommonJS modules (uses `module.exports`, `exports`, top-level `return`, or is defined as CommonJS by module metadata)
58
+ * - "unknown" when the format could not be determined from either syntax or module definition metadata
59
+ *
60
+ * @experimental
61
+ */
62
+ inputFormat: "es" | "cjs" | "unknown";
53
63
  }
54
64
  //#endregion
55
65
  //#region src/utils/asset-source.d.ts
@@ -313,6 +323,20 @@ type CodeSplittingNameFunction = (moduleId: string, ctx: ChunkingContext) => str
313
323
  /** @inline */
314
324
  type CodeSplittingTestFunction = (id: string) => boolean | undefined | void;
315
325
  type MinifyOptions = Omit<MinifyOptions$1, "module" | "sourcemap">;
326
+ interface CommentsOptions {
327
+ /**
328
+ * Comments that contain `@license`, `@preserve` or start with `//!` or `/*!`
329
+ */
330
+ legal?: boolean;
331
+ /**
332
+ * Comments that contain `@__PURE__`, `@__NO_SIDE_EFFECTS__` or `@vite-ignore`
333
+ */
334
+ annotation?: boolean;
335
+ /**
336
+ * JSDoc comments
337
+ */
338
+ jsdoc?: boolean;
339
+ }
316
340
  /** @inline */
317
341
  interface ChunkingContext {
318
342
  getModuleInfo(moduleId: string): ModuleInfo | null;
@@ -360,7 +384,7 @@ interface OutputOptions {
360
384
  * - `'iife'` stands for [Immediately Invoked Function Expression](https://developer.mozilla.org/en-US/docs/Glossary/IIFE).
361
385
  * - `'umd'` stands for [Universal Module Definition](https://github.com/umdjs/umd).
362
386
  *
363
- * @default 'esm'
387
+ * @default 'es'
364
388
  *
365
389
  *
366
390
  */
@@ -441,7 +465,7 @@ interface OutputOptions {
441
465
  */
442
466
  sourcemapPathTransform?: SourcemapPathTransformOption;
443
467
  /**
444
- * A string to prepend to the bundle before `renderChunk` hook.
468
+ * A string to prepend to the bundle before {@linkcode Plugin.renderChunk | renderChunk} hook.
445
469
  *
446
470
  * See {@linkcode intro | output.intro}, {@linkcode postBanner | output.postBanner} as well.
447
471
  *
@@ -449,7 +473,7 @@ interface OutputOptions {
449
473
  */
450
474
  banner?: string | AddonFunction;
451
475
  /**
452
- * A string to append to the bundle before `renderChunk` hook.
476
+ * A string to append to the bundle before {@linkcode Plugin.renderChunk | renderChunk} hook.
453
477
  *
454
478
  * See {@linkcode outro | output.outro}, {@linkcode postFooter | output.postFooter} as well.
455
479
  *
@@ -457,7 +481,7 @@ interface OutputOptions {
457
481
  */
458
482
  footer?: string | AddonFunction;
459
483
  /**
460
- * A string to prepend to the bundle after `renderChunk` hook and minification.
484
+ * A string to prepend to the bundle after {@linkcode Plugin.renderChunk | renderChunk} hook and minification.
461
485
  *
462
486
  * See {@linkcode banner | output.banner}, {@linkcode intro | output.intro} as well.
463
487
  *
@@ -465,7 +489,7 @@ interface OutputOptions {
465
489
  */
466
490
  postBanner?: string | AddonFunction;
467
491
  /**
468
- * A string to append to the bundle after `renderChunk` hook and minification.
492
+ * A string to append to the bundle after {@linkcode Plugin.renderChunk | renderChunk} hook and minification.
469
493
  *
470
494
  * See {@linkcode footer | output.footer}, {@linkcode outro | output.outro} as well.
471
495
  *
@@ -473,7 +497,7 @@ interface OutputOptions {
473
497
  */
474
498
  postFooter?: string | AddonFunction;
475
499
  /**
476
- * A string to prepend inside any format-specific wrapper.
500
+ * A string to prepend inside any {@link OutputOptions.format | format}-specific wrapper.
477
501
  *
478
502
  * See {@linkcode banner | output.banner}, {@linkcode postBanner | output.postBanner} as well.
479
503
  *
@@ -481,7 +505,7 @@ interface OutputOptions {
481
505
  */
482
506
  intro?: string | AddonFunction;
483
507
  /**
484
- * A string to append inside any format-specific wrapper.
508
+ * A string to append inside any {@link OutputOptions.format | format}-specific wrapper.
485
509
  *
486
510
  * See {@linkcode footer | output.footer}, {@linkcode postFooter | output.postFooter} as well.
487
511
  *
@@ -489,7 +513,7 @@ interface OutputOptions {
489
513
  */
490
514
  outro?: string | AddonFunction;
491
515
  /**
492
- * Whether to extend the global variable defined by the {@linkcode OutputOptions.name | name} option in `umd` or `iife` formats.
516
+ * Whether to extend the global variable defined by the {@linkcode OutputOptions.name | name} option in `umd` or `iife` {@link OutputOptions.format | formats}.
493
517
  *
494
518
  * When `true`, the global variable will be defined as `global.name = global.name || {}`.
495
519
  * When `false`, the global defined by name will be overwritten like `global.name = {}`.
@@ -498,12 +522,12 @@ interface OutputOptions {
498
522
  */
499
523
  extend?: boolean;
500
524
  /**
501
- * Whether to add a `__esModule: true` property when generating exports for non-ES formats.
525
+ * Whether to add a `__esModule: true` property when generating exports for non-ES {@link OutputOptions.format | formats}.
502
526
  *
503
527
  * This property signifies that the exported value is the namespace of an ES module and that the default export of this module corresponds to the `.default` property of the exported object.
504
528
  *
505
- * - `true`: Always add the property when using named exports mode, which is similar to what other tools do.
506
- * - `"if-default-prop"`: Only add the property when using named exports mode and there also is a default export. The subtle difference is that if there is no default export, consumers of the CommonJS version of your library will get all named exports as default export instead of an error or `undefined`.
529
+ * - `true`: Always add the property when using {@link OutputOptions.exports | named exports mode}, which is similar to what other tools do.
530
+ * - `"if-default-prop"`: Only add the property when using {@link OutputOptions.exports | named exports mode} and there also is a default export. The subtle difference is that if there is no default export, consumers of the CommonJS version of your library will get all named exports as default export instead of an error or `undefined`.
507
531
  * - `false`: Never add the property even if the default export would become a property `.default`.
508
532
  *
509
533
  * @default 'if-default-prop'
@@ -558,18 +582,6 @@ interface OutputOptions {
558
582
  */
559
583
  chunkFileNames?: string | ChunkFileNamesFunction;
560
584
  /**
561
- * @default '[name].css'
562
- * @experimental
563
- * @hidden not ready for public usage yet
564
- */
565
- cssEntryFileNames?: string | ChunkFileNamesFunction;
566
- /**
567
- * @default '[name]-[hash].css'
568
- * @experimental
569
- * @hidden not ready for public usage yet
570
- */
571
- cssChunkFileNames?: string | ChunkFileNamesFunction;
572
- /**
573
585
  * Whether to enable chunk name sanitization (removal of non-URL-safe characters like `\0`, `?` and `*`).
574
586
  *
575
587
  * Set `false` to disable the sanitization. You can also provide a custom sanitization function.
@@ -591,7 +603,7 @@ interface OutputOptions {
591
603
  */
592
604
  minify?: boolean | "dce-only" | MinifyOptions;
593
605
  /**
594
- * Specifies the global variable name that contains the exports of `umd` / `iife` bundles.
606
+ * Specifies the global variable name that contains the exports of `umd` / `iife` {@link OutputOptions.format | formats}.
595
607
  *
596
608
  * @example
597
609
  * ```js
@@ -613,7 +625,7 @@ interface OutputOptions {
613
625
  */
614
626
  name?: string;
615
627
  /**
616
- * Specifies `id: variableName` pairs necessary for external imports in `umd` / `iife` bundles.
628
+ * Specifies `id: variableName` pairs necessary for {@link InputOptions.external | external} imports in `umd` / `iife` {@link OutputOptions.format | formats}.
617
629
  *
618
630
  * @example
619
631
  * ```js
@@ -641,7 +653,7 @@ interface OutputOptions {
641
653
  */
642
654
  globals?: Record<string, string> | GlobalsFunction;
643
655
  /**
644
- * Maps external module IDs to paths.
656
+ * Maps {@link InputOptions.external | external} module IDs to paths.
645
657
  *
646
658
  * Allows customizing the path used when importing external dependencies.
647
659
  * This is particularly useful for loading dependencies from CDNs or custom locations.
@@ -678,7 +690,7 @@ interface OutputOptions {
678
690
  */
679
691
  generatedCode?: Partial<GeneratedCodeOptions>;
680
692
  /**
681
- * Whether to generate code to support live bindings for external imports.
693
+ * Whether to generate code to support live bindings for {@link InputOptions.external | external} imports.
682
694
  *
683
695
  * With the default value of `true`, Rolldown will generate code to support live bindings for external imports.
684
696
  *
@@ -763,6 +775,8 @@ interface OutputOptions {
763
775
  *
764
776
  * For deeper understanding, please refer to the in-depth [documentation](https://rolldown.rs/in-depth/manual-code-splitting).
765
777
  *
778
+ *
779
+ *
766
780
  * @example
767
781
  * **Basic vendor chunk**
768
782
  * ```js
@@ -804,13 +818,32 @@ interface OutputOptions {
804
818
  groups?: CodeSplittingGroup[];
805
819
  };
806
820
  /**
807
- * Control comments in the output.
821
+ * Controls how legal comments are preserved in the output.
808
822
  *
809
- * - `none`: no comments
810
- * - `inline`: preserve comments that contain `@license`, `@preserve` or starts with `//!` `/*!`
823
+ * - `none`: no legal comments
824
+ * - `inline`: preserve legal comments that contain `@license`, `@preserve` or starts with `//!` `/*!`
825
+ *
826
+ * @deprecated Use `comments.legal` instead. When both `legalComments` and `comments.legal` are set, `comments.legal` takes priority.
811
827
  */
812
828
  legalComments?: "none" | "inline";
813
829
  /**
830
+ * Control which comments are preserved in the output.
831
+ *
832
+ * - `true`: Preserve legal, annotation, and JSDoc comments (default)
833
+ * - `false`: Strip all comments
834
+ * - Object: Granular control over comment categories
835
+ *
836
+ * Note: Regular line and block comments without these markers
837
+ * are always removed regardless of this option.
838
+ *
839
+ * When both `legalComments` and `comments.legal` are set, `comments.legal` takes priority.
840
+ *
841
+ *
842
+ *
843
+ * @default true
844
+ */
845
+ comments?: boolean | CommentsOptions;
846
+ /**
814
847
  * The list of plugins to use only for this output.
815
848
  *
816
849
  * @see {@linkcode InputOptions.plugins | plugins}
@@ -838,13 +871,13 @@ interface OutputOptions {
838
871
  */
839
872
  preserveModules?: boolean;
840
873
  /**
841
- * Specifies the directory name for "virtual" files that might be emitted by plugins when using preserve modules mode.
874
+ * Specifies the directory name for "virtual" files that might be emitted by plugins when using {@link OutputOptions.preserveModules | preserve modules mode}.
842
875
  *
843
876
  * @default '_virtual'
844
877
  */
845
878
  virtualDirname?: string;
846
879
  /**
847
- * A directory path to input modules that should be stripped away from {@linkcode dir | output.dir} when using preserve modules mode.
880
+ * A directory path to input modules that should be stripped away from {@linkcode dir | output.dir} when using {@link OutputOptions.preserveModules | preserve modules mode}.
848
881
  *
849
882
  *
850
883
  */
@@ -1038,6 +1071,36 @@ type CodeSplittingGroup = {
1038
1071
  * @default 0
1039
1072
  */
1040
1073
  minModuleSize?: number;
1074
+ /**
1075
+ * When `false` (default), all matching modules are merged into a single chunk.
1076
+ * Every entry that uses any of these modules must load the entire chunk — even
1077
+ * modules it doesn't need.
1078
+ *
1079
+ * When `true`, matching modules are grouped by which entries actually import them.
1080
+ * Modules shared by the same set of entries go into the same chunk, while modules
1081
+ * shared by a different set go into a separate chunk. This way, each entry only
1082
+ * loads the code it actually uses.
1083
+ *
1084
+ * Example: entries A, B, C all match a `"vendor"` group.
1085
+ * - `moduleX` is used by A, B, C
1086
+ * - `moduleY` is used by A, B only
1087
+ *
1088
+ * With `entriesAware: false` → one `vendor.js` chunk with both modules; C loads `moduleY` unnecessarily.
1089
+ * With `entriesAware: true` → `vendor.js` (moduleX, loaded by all) + `vendor2.js` (moduleY, loaded by A and B only).
1090
+ *
1091
+ * @default false
1092
+ */
1093
+ entriesAware?: boolean;
1094
+ /**
1095
+ * Size threshold in bytes for merging small `entriesAware` subgroups into the
1096
+ * closest neighboring subgroup.
1097
+ *
1098
+ * This option only works when {@linkcode CodeSplittingGroup.entriesAware | entriesAware}
1099
+ * is `true`. Set to `0` to disable subgroup merging.
1100
+ *
1101
+ * @default 0
1102
+ */
1103
+ entriesAwareMergeThreshold?: number;
1041
1104
  };
1042
1105
  /**
1043
1106
  * Alias for {@linkcode CodeSplittingGroup}. Use this type for the `codeSplitting.groups` option.
@@ -1467,6 +1530,16 @@ interface ChecksOptions {
1467
1530
  * @default true
1468
1531
  * */
1469
1532
  duplicateShebang?: boolean;
1533
+ /**
1534
+ * Whether to emit warnings when a tsconfig option or combination of options is not supported.
1535
+ * @default true
1536
+ * */
1537
+ unsupportedTsconfigOption?: boolean;
1538
+ /**
1539
+ * Whether to emit warnings when a module is dynamically imported but also statically imported, making the dynamic import ineffective for code splitting.
1540
+ * @default true
1541
+ * */
1542
+ ineffectiveDynamicImport?: boolean;
1470
1543
  }
1471
1544
  //#endregion
1472
1545
  //#region src/options/transform-options.d.ts
@@ -1626,10 +1699,6 @@ interface NormalizedOutputOptions {
1626
1699
  sourcemap: boolean | "inline" | "hidden";
1627
1700
  /** @see {@linkcode OutputOptions.sourcemapBaseUrl | sourcemapBaseUrl} */
1628
1701
  sourcemapBaseUrl: string | undefined;
1629
- /** @see {@linkcode OutputOptions.cssEntryFileNames | cssEntryFileNames} */
1630
- cssEntryFileNames: string | ChunkFileNamesFunction;
1631
- /** @see {@linkcode OutputOptions.cssChunkFileNames | cssChunkFileNames} */
1632
- cssChunkFileNames: string | ChunkFileNamesFunction;
1633
1702
  /** @see {@linkcode OutputOptions.codeSplitting | codeSplitting} */
1634
1703
  codeSplitting: boolean;
1635
1704
  /** @deprecated Use `codeSplitting` instead. */
@@ -1668,8 +1737,13 @@ interface NormalizedOutputOptions {
1668
1737
  sourcemapPathTransform: SourcemapPathTransformOption | undefined;
1669
1738
  /** @see {@linkcode OutputOptions.minify | minify} */
1670
1739
  minify: false | MinifyOptions | "dce-only";
1671
- /** @see {@linkcode OutputOptions.legalComments | legalComments} */
1740
+ /**
1741
+ * @deprecated Use `comments.legal` instead.
1742
+ * @see {@linkcode OutputOptions.legalComments | legalComments}
1743
+ */
1672
1744
  legalComments: "none" | "inline";
1745
+ /** @see {@linkcode OutputOptions.comments | comments} */
1746
+ comments: Required<CommentsOptions>;
1673
1747
  /** @see {@linkcode OutputOptions.polyfillRequire | polyfillRequire} */
1674
1748
  polyfillRequire: boolean;
1675
1749
  /** @see {@linkcode OutputOptions.plugins | plugins} */
@@ -2294,7 +2368,7 @@ type TreeshakingOptions = {
2294
2368
  *
2295
2369
  * See [related Oxc documentation](https://oxc.rs/docs/guide/usage/minifier/dead-code-elimination#ignoring-invalid-import-statement-side-effects) for more details.
2296
2370
  *
2297
- * @default true
2371
+ * @default false
2298
2372
  */
2299
2373
  invalidImportSideEffects?: boolean;
2300
2374
  /**
@@ -2357,7 +2431,7 @@ interface ExistingRawSourceMap {
2357
2431
  /** @inline @category Plugin APIs */
2358
2432
  type SourceMapInput = ExistingRawSourceMap | string | null;
2359
2433
  //#endregion
2360
- //#region src/version.d.ts
2434
+ //#region src/constants/version.d.ts
2361
2435
  /**
2362
2436
  * The version of Rolldown.
2363
2437
  * @example `'1.0.0'`
@@ -2366,6 +2440,12 @@ type SourceMapInput = ExistingRawSourceMap | string | null;
2366
2440
  */
2367
2441
  declare const VERSION: string;
2368
2442
  //#endregion
2443
+ //#region src/constants/index.d.ts
2444
+ /**
2445
+ * Runtime helper module ID
2446
+ */
2447
+ declare const RUNTIME_MODULE_ID = "\0rolldown/runtime.js";
2448
+ //#endregion
2369
2449
  //#region src/builtin-plugin/utils.d.ts
2370
2450
  declare class BuiltinPlugin {
2371
2451
  name: BindingBuiltinPluginName;
@@ -2409,6 +2489,29 @@ type OverrideFilterObject = {
2409
2489
  load?: HookFilterExtension<"load">["filter"];
2410
2490
  pluginNamePattern?: StringOrRegExp[];
2411
2491
  };
2492
+ /**
2493
+ * A helper function to add plugin hook filters to a plugin or an array of plugins.
2494
+ *
2495
+ * @example
2496
+ * ```ts
2497
+ * import yaml from '@rollup/plugin-yaml';
2498
+ * import { defineConfig } from 'rolldown';
2499
+ * import { withFilter } from 'rolldown/filter';
2500
+ *
2501
+ * export default defineConfig({
2502
+ * plugins: [
2503
+ * // Run the transform hook of the `yaml` plugin
2504
+ * // only for modules which end in `.yaml`
2505
+ * withFilter(
2506
+ * yaml({}),
2507
+ * { transform: { id: /\.yaml$/ } },
2508
+ * ),
2509
+ * ],
2510
+ * });
2511
+ * ```
2512
+ *
2513
+ * @category Config
2514
+ */
2412
2515
  declare function withFilter<A, T extends RolldownPluginOption<A>>(pluginOption: T, filterObject: OverrideFilterObject | OverrideFilterObject[]): T;
2413
2516
  //#endregion
2414
2517
  //#region src/plugin/index.d.ts
@@ -2630,6 +2733,8 @@ interface FunctionPluginHooks {
2630
2733
  *
2631
2734
  * You can use {@linkcode PluginContext.getModuleInfo | this.getModuleInfo()} to find out the previous values of `meta`, `moduleSideEffects` inside this hook.
2632
2735
  *
2736
+ *
2737
+ *
2633
2738
  * @group Build Hooks
2634
2739
  */
2635
2740
  [DEFINED_HOOK_NAMES.transform]: (this: TransformPluginContext, code: string, id: string, meta: BindingTransformHookExtraArgs & {
@@ -2891,7 +2996,7 @@ type InputOption = string | string[] | Record<string, string>;
2891
2996
  type ExternalOptionFunction = (id: string, parentId: string | undefined, isResolved: boolean) => NullValue<boolean>;
2892
2997
  /** @inline */
2893
2998
  type ExternalOption = StringOrRegExp | StringOrRegExp[] | ExternalOptionFunction;
2894
- type ModuleTypes = Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | "css" | "asset">;
2999
+ type ModuleTypes = Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | "css" | "asset" | "copy">;
2895
3000
  interface WatcherOptions {
2896
3001
  /**
2897
3002
  * Whether to skip the {@linkcode RolldownBuild.write | bundle.write()} step when a rebuild is triggered.
@@ -3608,4 +3713,4 @@ declare function defineConfig(config: RolldownOptions[]): RolldownOptions[];
3608
3713
  declare function defineConfig(config: RolldownOptionsFunction): RolldownOptionsFunction;
3609
3714
  declare function defineConfig(config: ConfigExport): ConfigExport;
3610
3715
  //#endregion
3611
- export { BufferEncoding as $, TransformResult as A, MinifyOptions as At, EmittedChunk as B, RenderedModule as Bt, Plugin as C, ChunkingContext as Ct, RolldownPlugin as D, GeneratedCodeOptions as Dt, ResolvedId as E, CodeSplittingOptions as Et, SourceMapInput as F, PartialNull as Ft, PluginContextResolveOptions as G, SourcemapIgnoreListOption as Gt, EmittedPrebuiltChunk as H, SourceMap as Ht, OutputBundle as I, StringOrRegExp as It, MinimalPluginContext as J, DefineParallelPluginResult as K, TreeshakingOptions as L, OutputAsset as Lt, BuiltinPlugin as M, OutputOptions as Mt, VERSION as N, PreRenderedAsset as Nt, RolldownPluginOption as O, GeneratedCodePreset as Ot, ExistingRawSourceMap as P, MaybePromise as Pt, ModuleTypeFilter as Q, TransformPluginContext as R, OutputChunk as Rt, PartialResolvedId as S, ChunkFileNamesFunction as St, ResolveIdResult as T, CodeSplittingNameFunction as Tt, GetModuleInfo as U, freeExternalMemory as Ut, EmittedFile as V, RolldownOutput as Vt, PluginContext as W, ModuleInfo as Wt, GeneralHookFilter as X, PluginContextMeta as Y, HookFilter as Z, LoadResult as _, BuildOptions as _t, ExternalOption as a, NormalizedInputOptions as at, ObjectHook as b, AdvancedChunksGroup as bt, InputOptions as c, LoggingFunction as ct, WatcherOptions as d, RolldownWatcher as dt, RolldownDirectoryEntry as et, AsyncPluginHooks as f, RolldownWatcherEvent as ft, ImportKind as g, RolldownBuild as gt, HookFilterExtension as h, rolldown as ht, RolldownOptions as i, NormalizedOutputOptions as it, withFilter as j, ModuleFormat as jt, SourceDescription as k, GlobalsFunction as kt, ModuleTypes as l, WarningHandlerWithDefault as lt, FunctionPluginHooks as m, WatchOptions as mt, RolldownOptionsFunction as n, RolldownFsModule as nt, ExternalOptionFunction as o, TransformOptions as ot, CustomPluginOptions as p, RolldownWatcherWatcherEventMap as pt, defineParallelPlugin as q, defineConfig as r, InternalModuleFormat as rt, InputOption as s, ChecksOptions as st, ConfigExport as t, RolldownFileStats as tt, OptimizationOptions as u, watch as ut, ModuleOptions as v, build as vt, ResolveIdExtraOptions as w, CodeSplittingGroup as wt, ParallelPluginHooks as x, AdvancedChunksOptions as xt, ModuleType as y, AddonFunction as yt, EmittedAsset as z, RenderedChunk as zt };
3716
+ export { ModuleTypeFilter as $, TransformResult as A, GeneratedCodePreset as At, EmittedAsset as B, OutputChunk as Bt, Plugin as C, ChunkFileNamesFunction as Ct, RolldownPlugin as D, CodeSplittingOptions as Dt, ResolvedId as E, CodeSplittingNameFunction as Et, ExistingRawSourceMap as F, PreRenderedAsset as Ft, PluginContext as G, freeExternalMemory as Gt, EmittedFile as H, RenderedModule as Ht, SourceMapInput as I, MaybePromise as It, defineParallelPlugin as J, PluginContextResolveOptions as K, ModuleInfo as Kt, OutputBundle as L, PartialNull as Lt, BuiltinPlugin as M, MinifyOptions as Mt, RUNTIME_MODULE_ID as N, ModuleFormat as Nt, RolldownPluginOption as O, CommentsOptions as Ot, VERSION as P, OutputOptions as Pt, HookFilter as Q, TreeshakingOptions as R, StringOrRegExp as Rt, PartialResolvedId as S, AdvancedChunksOptions as St, ResolveIdResult as T, CodeSplittingGroup as Tt, EmittedPrebuiltChunk as U, RolldownOutput as Ut, EmittedChunk as V, RenderedChunk as Vt, GetModuleInfo as W, SourceMap as Wt, PluginContextMeta as X, MinimalPluginContext as Y, GeneralHookFilter as Z, LoadResult as _, RolldownBuild as _t, ExternalOption as a, NormalizedOutputOptions as at, ObjectHook as b, AddonFunction as bt, InputOptions as c, ChecksOptions as ct, WatcherOptions as d, watch as dt, BufferEncoding as et, AsyncPluginHooks as f, RolldownWatcher as ft, ImportKind as g, rolldown as gt, HookFilterExtension as h, WatchOptions as ht, RolldownOptions as i, InternalModuleFormat as it, withFilter as j, GlobalsFunction as jt, SourceDescription as k, GeneratedCodeOptions as kt, ModuleTypes as l, LoggingFunction as lt, FunctionPluginHooks as m, RolldownWatcherWatcherEventMap as mt, RolldownOptionsFunction as n, RolldownFileStats as nt, ExternalOptionFunction as o, NormalizedInputOptions as ot, CustomPluginOptions as p, RolldownWatcherEvent as pt, DefineParallelPluginResult as q, SourcemapIgnoreListOption as qt, defineConfig as r, RolldownFsModule as rt, InputOption as s, TransformOptions as st, ConfigExport as t, RolldownDirectoryEntry as tt, OptimizationOptions as u, WarningHandlerWithDefault as ut, ModuleOptions as v, BuildOptions as vt, ResolveIdExtraOptions as w, ChunkingContext as wt, ParallelPluginHooks as x, AdvancedChunksGroup as xt, ModuleType as y, build as yt, TransformPluginContext as z, OutputAsset as zt };
@@ -0,0 +1,90 @@
1
+ import { n as __toESM, t as require_binding } from "./binding-D25Pz9Tj.mjs";
2
+
3
+ //#region src/types/sourcemap.ts
4
+ function bindingifySourcemap(map) {
5
+ if (map == null) return;
6
+ return { inner: typeof map === "string" ? map : {
7
+ file: map.file ?? void 0,
8
+ mappings: map.mappings,
9
+ sourceRoot: "sourceRoot" in map ? map.sourceRoot ?? void 0 : void 0,
10
+ sources: map.sources?.map((s) => s ?? void 0),
11
+ sourcesContent: map.sourcesContent?.map((s) => s ?? void 0),
12
+ names: map.names,
13
+ x_google_ignoreList: map.x_google_ignoreList,
14
+ debugId: "debugId" in map ? map.debugId : void 0
15
+ } };
16
+ }
17
+
18
+ //#endregion
19
+ //#region src/utils/error.ts
20
+ var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
21
+ function unwrapBindingResult(container) {
22
+ if (typeof container === "object" && container !== null && "isBindingErrors" in container && container.isBindingErrors) throw aggregateBindingErrorsIntoJsError(container.errors);
23
+ return container;
24
+ }
25
+ function normalizeBindingResult(container) {
26
+ if (typeof container === "object" && container !== null && "isBindingErrors" in container && container.isBindingErrors) return aggregateBindingErrorsIntoJsError(container.errors);
27
+ return container;
28
+ }
29
+ function normalizeBindingError(e) {
30
+ return e.type === "JsError" ? e.field0 : Object.assign(/* @__PURE__ */ new Error(), {
31
+ code: e.field0.kind,
32
+ kind: e.field0.kind,
33
+ message: e.field0.message,
34
+ id: e.field0.id,
35
+ exporter: e.field0.exporter,
36
+ loc: e.field0.loc,
37
+ pos: e.field0.pos,
38
+ stack: void 0
39
+ });
40
+ }
41
+ function aggregateBindingErrorsIntoJsError(rawErrors) {
42
+ const errors = rawErrors.map(normalizeBindingError);
43
+ let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
44
+ for (let i = 0; i < errors.length; i++) {
45
+ summary += "\n";
46
+ if (i >= 5) {
47
+ summary += "...";
48
+ break;
49
+ }
50
+ summary += getErrorMessage(errors[i]);
51
+ }
52
+ const wrapper = new Error(summary);
53
+ Object.defineProperty(wrapper, "errors", {
54
+ configurable: true,
55
+ enumerable: true,
56
+ get: () => errors,
57
+ set: (value) => Object.defineProperty(wrapper, "errors", {
58
+ configurable: true,
59
+ enumerable: true,
60
+ value
61
+ })
62
+ });
63
+ return wrapper;
64
+ }
65
+ function getErrorMessage(e) {
66
+ if (Object.hasOwn(e, "kind")) return e.message;
67
+ let s = "";
68
+ if (e.plugin) s += `[plugin ${e.plugin}]`;
69
+ const id = e.id ?? e.loc?.file;
70
+ if (id) {
71
+ s += " " + id;
72
+ if (e.loc) s += `:${e.loc.line}:${e.loc.column}`;
73
+ }
74
+ if (s) s += "\n";
75
+ const message = `${e.name ?? "Error"}: ${e.message}`;
76
+ s += message;
77
+ if (e.frame) s = joinNewLine(s, e.frame);
78
+ if (e.stack) s = joinNewLine(s, e.stack.replace(message, ""));
79
+ if (e.cause) {
80
+ s = joinNewLine(s, "Caused by:");
81
+ s = joinNewLine(s, getErrorMessage(e.cause).split("\n").map((line) => " " + line).join("\n"));
82
+ }
83
+ return s;
84
+ }
85
+ function joinNewLine(s1, s2) {
86
+ return s1.replace(/\n+$/, "") + "\n" + s2.replace(/^\n+/, "");
87
+ }
88
+
89
+ //#endregion
90
+ export { bindingifySourcemap as a, unwrapBindingResult as i, normalizeBindingError as n, normalizeBindingResult as r, aggregateBindingErrorsIntoJsError as t };
@@ -0,0 +1,35 @@
1
+ import { a as RolldownLog } from "./logging-C6h4g8dA.mjs";
2
+
3
+ //#region src/get-log-filter.d.ts
4
+ /**
5
+ * @param filters A list of log filters to apply
6
+ * @returns A function that tests whether a log should be output
7
+ *
8
+ * @category Config
9
+ */
10
+ type GetLogFilter = (filters: string[]) => (log: RolldownLog) => boolean;
11
+ /**
12
+ * A helper function to generate log filters using the same syntax as the CLI.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * import { defineConfig } from 'rolldown';
17
+ * import { getLogFilter } from 'rolldown/getLogFilter';
18
+ *
19
+ * const logFilter = getLogFilter(['code:FOO', 'code:BAR']);
20
+ *
21
+ * export default defineConfig({
22
+ * input: 'main.js',
23
+ * onLog(level, log, handler) {
24
+ * if (logFilter(log)) {
25
+ * handler(level, log);
26
+ * }
27
+ * }
28
+ * });
29
+ * ```
30
+ *
31
+ * @category Config
32
+ */
33
+ declare const getLogFilter: GetLogFilter;
34
+ //#endregion
35
+ export { getLogFilter as n, GetLogFilter as t };
@@ -1,9 +1,9 @@
1
- import { t as rolldown } from "./rolldown-5hTSdYMy.mjs";
1
+ import { t as rolldown } from "./rolldown-CZ1SIh-x.mjs";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import { readdir } from "node:fs/promises";
5
- import { pathToFileURL } from "node:url";
6
5
  import { cwd } from "node:process";
6
+ import { pathToFileURL } from "node:url";
7
7
 
8
8
  //#region src/utils/load-config.ts
9
9
  async function bundleTsConfig(configFile, isEsm) {
@@ -99,6 +99,14 @@ function tryStatSync(file) {
99
99
  return fs.statSync(file, { throwIfNoEntry: false });
100
100
  } catch {}
101
101
  }
102
+ /**
103
+ * Load config from a file in a way that Rolldown does.
104
+ *
105
+ * @param configPath The path to the config file. If empty, it will look for `rolldown.config` with supported extensions in the current working directory.
106
+ * @returns The loaded config export
107
+ *
108
+ * @category Config
109
+ */
102
110
  async function loadConfig(configPath) {
103
111
  const ext = path.extname(configPath = configPath || await findConfigFileNameInCwd());
104
112
  try {
@@ -148,7 +148,7 @@ function error(base) {
148
148
  if (!(base instanceof Error)) {
149
149
  base = Object.assign(new Error(base.message), base);
150
150
  Object.defineProperty(base, "name", {
151
- value: "RollupError",
151
+ value: "RolldownError",
152
152
  writable: true
153
153
  });
154
154
  }
@@ -1,5 +1,5 @@
1
- import { n as __toESM, t as require_binding } from "./binding-9QXxzPo6.mjs";
2
- import { c as logPluginError, n as error } from "./logs-NH298mHo.mjs";
1
+ import { n as __toESM, t as require_binding } from "./binding-D25Pz9Tj.mjs";
2
+ import { c as logPluginError, n as error } from "./logs-CCc_0vhs.mjs";
3
3
 
4
4
  //#region src/builtin-plugin/utils.ts
5
5
  var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);