@rolldown/browser 1.0.0-beta.57 → 1.0.0-beta.58
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.
- package/dist/cli.mjs +8 -8
- package/dist/config.d.mts +1 -1
- package/dist/config.mjs +6 -6
- package/dist/{constructors-hZ5LHCkF.js → constructors-BuqTjXTF.js} +1 -1
- package/dist/experimental-index.browser.mjs +3 -3
- package/dist/experimental-index.d.mts +4 -4
- package/dist/experimental-index.mjs +5 -5
- package/dist/filter-index.d.mts +1 -1
- package/dist/get-log-filter.d.mts +1 -1
- package/dist/index.browser.mjs +4 -2
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +6 -6
- package/dist/{normalize-string-or-regex-DewaIpuo.js → normalize-string-or-regex-3ql5-z8-.js} +3 -2
- package/dist/parallel-plugin-worker.mjs +3 -3
- package/dist/parallel-plugin.d.mts +2 -2
- package/dist/parse-ast-index.d.mts +1 -1
- package/dist/parse-ast-index.mjs +1 -1
- package/dist/plugins-index.browser.mjs +2 -2
- package/dist/plugins-index.d.mts +3 -3
- package/dist/plugins-index.mjs +2 -2
- package/dist/rolldown-binding.wasi.cjs +1 -1
- package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
- package/dist/{rolldown-build-32P3iU2U.js → rolldown-build-CRqas5jO.js} +12 -5
- package/dist/shared/{binding-CDyF6W3D.d.mts → binding-MAEzB4KA.d.mts} +10 -0
- package/dist/shared/{bindingify-input-options-CwdDrVAR.mjs → bindingify-input-options--qcSYuhh.mjs} +7 -3
- package/dist/shared/{constructors-B0L_9ar3.d.mts → constructors-CQP6o3cR.d.mts} +2 -2
- package/dist/shared/{constructors-Ch7pGFBC.mjs → constructors-kOch67Sb.mjs} +1 -1
- package/dist/shared/{define-config-Bho_aQn8.d.mts → define-config-yInAJbA1.d.mts} +471 -130
- package/dist/shared/{load-config-DUtgyO78.mjs → load-config-BZhApFJg.mjs} +1 -1
- package/dist/shared/{logging-BpAvp7KV.d.mts → logging-B4x9qar8.d.mts} +1 -0
- package/dist/shared/{normalize-string-or-regex-Dt2VqAqy.mjs → normalize-string-or-regex-CIiT1lMg.mjs} +3 -2
- package/dist/shared/{parse-ast-index-DZPue_kI.mjs → parse-ast-index-CgzK6cxG.mjs} +1 -1
- package/dist/shared/{rolldown-D1ymUD73.mjs → rolldown-Vl5SnJ_J.mjs} +2 -1
- package/dist/shared/{rolldown-build-rs9zb03O.mjs → rolldown-build-7kWB1jqY.mjs} +6 -3
- package/dist/shared/{utils-B3dcnHc8.d.mts → utils-BGxZdOXA.d.mts} +2 -2
- package/dist/shared/{watch-CbHTfwHk.mjs → watch-CGYro6go.mjs} +4 -3
- package/package.json +16 -16
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as RollupLog, i as RollupError, n as LogLevelOption, o as RollupLogWithString, r as LogOrStringHandler, t as LogLevel } from "./logging-
|
|
2
|
-
import { A as BindingWatcherBundler, B as ParserOptions, F as JsxOptions, I as MinifyOptions$1, M as ExternalMemoryStatus, V as PreRenderedChunk, W as TransformOptions$1, a as BindingHookResolveIdExtraArgs, d as BindingTransformHookExtraArgs, j as BindingWatcherEvent, l as BindingRenderedChunk, s as BindingMagicString } from "./binding-
|
|
3
|
-
import { a as MakeAsync, c as NullValue, l as PartialNull, n as LoggingFunction, o as MaybeArray, r as LoggingFunctionWithPosition, s as MaybePromise, t as BuiltinPlugin, u as StringOrRegExp } from "./utils-
|
|
1
|
+
import { a as RollupLog, i as RollupError, n as LogLevelOption, o as RollupLogWithString, r as LogOrStringHandler, t as LogLevel } from "./logging-B4x9qar8.mjs";
|
|
2
|
+
import { A as BindingWatcherBundler, B as ParserOptions, F as JsxOptions, I as MinifyOptions$1, M as ExternalMemoryStatus, V as PreRenderedChunk, W as TransformOptions$1, a as BindingHookResolveIdExtraArgs, d as BindingTransformHookExtraArgs, j as BindingWatcherEvent, l as BindingRenderedChunk, s as BindingMagicString } from "./binding-MAEzB4KA.mjs";
|
|
3
|
+
import { a as MakeAsync, c as NullValue, l as PartialNull, n as LoggingFunction, o as MaybeArray, r as LoggingFunctionWithPosition, s as MaybePromise, t as BuiltinPlugin, u as StringOrRegExp } from "./utils-BGxZdOXA.mjs";
|
|
4
4
|
import { Program } from "@oxc-project/types";
|
|
5
5
|
import { TopLevelFilterExpression } from "@rolldown/pluginutils";
|
|
6
6
|
|
|
@@ -9,6 +9,7 @@ type SourcemapPathTransformOption = (relativeSourcePath: string, sourcemapPath:
|
|
|
9
9
|
type SourcemapIgnoreListOption = (relativeSourcePath: string, sourcemapPath: string) => boolean;
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/types/module-info.d.ts
|
|
12
|
+
/** @category Plugin APIs */
|
|
12
13
|
interface ModuleInfo extends ModuleOptions {
|
|
13
14
|
/**
|
|
14
15
|
* Unsupported at rolldown
|
|
@@ -79,6 +80,7 @@ interface ExternalMemoryHandle {
|
|
|
79
80
|
declare function freeExternalMemory(handle: ExternalMemoryHandle, keepDataAlive?: boolean): ExternalMemoryStatus;
|
|
80
81
|
//#endregion
|
|
81
82
|
//#region src/types/rolldown-output.d.ts
|
|
83
|
+
/** @category Plugin APIs */
|
|
82
84
|
interface OutputAsset extends ExternalMemoryHandle {
|
|
83
85
|
type: "asset";
|
|
84
86
|
fileName: string;
|
|
@@ -90,6 +92,7 @@ interface OutputAsset extends ExternalMemoryHandle {
|
|
|
90
92
|
name: string | undefined;
|
|
91
93
|
names: string[];
|
|
92
94
|
}
|
|
95
|
+
/** @category Plugin APIs */
|
|
93
96
|
interface SourceMap {
|
|
94
97
|
file: string;
|
|
95
98
|
mappings: string;
|
|
@@ -102,11 +105,13 @@ interface SourceMap {
|
|
|
102
105
|
toString(): string;
|
|
103
106
|
toUrl(): string;
|
|
104
107
|
}
|
|
108
|
+
/** @category Plugin APIs */
|
|
105
109
|
interface RenderedModule {
|
|
106
110
|
readonly code: string | null;
|
|
107
111
|
renderedLength: number;
|
|
108
112
|
renderedExports: string[];
|
|
109
113
|
}
|
|
114
|
+
/** @category Plugin APIs */
|
|
110
115
|
interface RenderedChunk extends Omit<BindingRenderedChunk, "modules"> {
|
|
111
116
|
type: "chunk";
|
|
112
117
|
modules: {
|
|
@@ -122,6 +127,7 @@ interface RenderedChunk extends Omit<BindingRenderedChunk, "modules"> {
|
|
|
122
127
|
imports: Array<string>;
|
|
123
128
|
dynamicImports: Array<string>;
|
|
124
129
|
}
|
|
130
|
+
/** @category Plugin APIs */
|
|
125
131
|
interface OutputChunk extends ExternalMemoryHandle {
|
|
126
132
|
type: "chunk";
|
|
127
133
|
code: string;
|
|
@@ -141,6 +147,7 @@ interface OutputChunk extends ExternalMemoryHandle {
|
|
|
141
147
|
sourcemapFileName: string | null;
|
|
142
148
|
preliminaryFileName: string;
|
|
143
149
|
}
|
|
150
|
+
/** @category Programmatic APIs */
|
|
144
151
|
interface RolldownOutput extends ExternalMemoryHandle {
|
|
145
152
|
output: [OutputChunk, ...(OutputChunk | OutputAsset)[]];
|
|
146
153
|
}
|
|
@@ -184,6 +191,7 @@ type ModuleFormat = "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | "umd
|
|
|
184
191
|
type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
|
|
185
192
|
type ChunkFileNamesFunction = (chunkInfo: PreRenderedChunk) => string;
|
|
186
193
|
type SanitizeFileNameFunction = (name: string) => string;
|
|
194
|
+
/** @category Plugin APIs */
|
|
187
195
|
interface PreRenderedAsset {
|
|
188
196
|
type: "asset";
|
|
189
197
|
name?: string;
|
|
@@ -322,6 +330,7 @@ interface OutputOptions {
|
|
|
322
330
|
generatedCode?: Partial<GeneratedCodeOptions>;
|
|
323
331
|
externalLiveBindings?: boolean;
|
|
324
332
|
inlineDynamicImports?: boolean;
|
|
333
|
+
dynamicImportInCjs?: boolean;
|
|
325
334
|
/**
|
|
326
335
|
* - Type: `((moduleId: string, meta: { getModuleInfo: (moduleId: string) => ModuleInfo | null }) => string | NullValue)`
|
|
327
336
|
* - Object form is not supported.
|
|
@@ -606,6 +615,7 @@ interface BuildOptions extends InputOptions {
|
|
|
606
615
|
write?: boolean;
|
|
607
616
|
output?: OutputOptions;
|
|
608
617
|
}
|
|
618
|
+
/** @category Programmatic APIs */
|
|
609
619
|
declare function build(options: BuildOptions): Promise<RolldownOutput>;
|
|
610
620
|
/**
|
|
611
621
|
* Build multiple outputs __sequentially__.
|
|
@@ -613,6 +623,7 @@ declare function build(options: BuildOptions): Promise<RolldownOutput>;
|
|
|
613
623
|
declare function build(options: BuildOptions[]): Promise<RolldownOutput[]>;
|
|
614
624
|
//#endregion
|
|
615
625
|
//#region src/api/rolldown/rolldown-build.d.ts
|
|
626
|
+
/** @category Programmatic APIs */
|
|
616
627
|
declare class RolldownBuild {
|
|
617
628
|
#private;
|
|
618
629
|
static asyncRuntimeShutdown: boolean;
|
|
@@ -629,9 +640,11 @@ declare class RolldownBuild {
|
|
|
629
640
|
}
|
|
630
641
|
//#endregion
|
|
631
642
|
//#region src/api/rolldown/index.d.ts
|
|
643
|
+
/** @category Programmatic APIs */
|
|
632
644
|
declare const rolldown: (input: InputOptions) => Promise<RolldownBuild>;
|
|
633
645
|
//#endregion
|
|
634
646
|
//#region src/options/watch-options.d.ts
|
|
647
|
+
/** @category Programmatic APIs */
|
|
635
648
|
interface WatchOptions extends InputOptions {
|
|
636
649
|
output?: OutputOptions | OutputOptions[];
|
|
637
650
|
}
|
|
@@ -640,6 +653,7 @@ interface WatchOptions extends InputOptions {
|
|
|
640
653
|
type WatcherEvent = "close" | "event" | "restart" | "change";
|
|
641
654
|
type ChangeEvent$1 = "create" | "update" | "delete";
|
|
642
655
|
type RolldownWatchBuild = BindingWatcherBundler;
|
|
656
|
+
/** @category Programmatic APIs */
|
|
643
657
|
type RolldownWatcherEvent = {
|
|
644
658
|
code: "START";
|
|
645
659
|
} | {
|
|
@@ -670,12 +684,99 @@ declare class WatcherEmitter {
|
|
|
670
684
|
onEvent(event: BindingWatcherEvent): Promise<void>;
|
|
671
685
|
close(): Promise<void>;
|
|
672
686
|
}
|
|
687
|
+
/** @category Programmatic APIs */
|
|
673
688
|
type RolldownWatcher = WatcherEmitter;
|
|
674
689
|
//#endregion
|
|
675
690
|
//#region src/api/watch/index.d.ts
|
|
691
|
+
/** @category Programmatic APIs */
|
|
676
692
|
declare const watch: (input: WatchOptions | WatchOptions[]) => RolldownWatcher;
|
|
677
693
|
//#endregion
|
|
694
|
+
//#region src/options/generated/checks-options.d.ts
|
|
695
|
+
interface ChecksOptions {
|
|
696
|
+
/**
|
|
697
|
+
* Whether to emit warning when detecting circular dependency
|
|
698
|
+
* @default false
|
|
699
|
+
* */
|
|
700
|
+
circularDependency?: boolean;
|
|
701
|
+
/**
|
|
702
|
+
* Whether to emit warning when detecting eval
|
|
703
|
+
* @default true
|
|
704
|
+
* */
|
|
705
|
+
eval?: boolean;
|
|
706
|
+
/**
|
|
707
|
+
* Whether to emit warning when detecting missing global name
|
|
708
|
+
* @default true
|
|
709
|
+
* */
|
|
710
|
+
missingGlobalName?: boolean;
|
|
711
|
+
/**
|
|
712
|
+
* Whether to emit warning when detecting missing name option for iife export
|
|
713
|
+
* @default true
|
|
714
|
+
* */
|
|
715
|
+
missingNameOptionForIifeExport?: boolean;
|
|
716
|
+
/**
|
|
717
|
+
* Whether to emit warning when detecting mixed exports
|
|
718
|
+
* @default true
|
|
719
|
+
* */
|
|
720
|
+
mixedExports?: boolean;
|
|
721
|
+
/**
|
|
722
|
+
* Whether to emit warning when detecting unresolved entry
|
|
723
|
+
* @default true
|
|
724
|
+
* */
|
|
725
|
+
unresolvedEntry?: boolean;
|
|
726
|
+
/**
|
|
727
|
+
* Whether to emit warning when detecting unresolved import
|
|
728
|
+
* @default true
|
|
729
|
+
* */
|
|
730
|
+
unresolvedImport?: boolean;
|
|
731
|
+
/**
|
|
732
|
+
* Whether to emit warning when detecting filename conflict
|
|
733
|
+
* @default true
|
|
734
|
+
* */
|
|
735
|
+
filenameConflict?: boolean;
|
|
736
|
+
/**
|
|
737
|
+
* Whether to emit warning when detecting common js variable in esm
|
|
738
|
+
* @default true
|
|
739
|
+
* */
|
|
740
|
+
commonJsVariableInEsm?: boolean;
|
|
741
|
+
/**
|
|
742
|
+
* Whether to emit warning when detecting import is undefined
|
|
743
|
+
* @default true
|
|
744
|
+
* */
|
|
745
|
+
importIsUndefined?: boolean;
|
|
746
|
+
/**
|
|
747
|
+
* Whether to emit warning when detecting empty import meta
|
|
748
|
+
* @default true
|
|
749
|
+
* */
|
|
750
|
+
emptyImportMeta?: boolean;
|
|
751
|
+
/**
|
|
752
|
+
* Whether to emit warning when detecting cannot call namespace
|
|
753
|
+
* @default true
|
|
754
|
+
* */
|
|
755
|
+
cannotCallNamespace?: boolean;
|
|
756
|
+
/**
|
|
757
|
+
* Whether to emit warning when detecting configuration field conflict
|
|
758
|
+
* @default true
|
|
759
|
+
* */
|
|
760
|
+
configurationFieldConflict?: boolean;
|
|
761
|
+
/**
|
|
762
|
+
* Whether to emit warning when detecting prefer builtin feature
|
|
763
|
+
* @default true
|
|
764
|
+
* */
|
|
765
|
+
preferBuiltinFeature?: boolean;
|
|
766
|
+
/**
|
|
767
|
+
* Whether to emit warning when detecting could not clean directory
|
|
768
|
+
* @default true
|
|
769
|
+
* */
|
|
770
|
+
couldNotCleanDirectory?: boolean;
|
|
771
|
+
/**
|
|
772
|
+
* Whether to emit warning when detecting plugin timings
|
|
773
|
+
* @default true
|
|
774
|
+
* */
|
|
775
|
+
pluginTimings?: boolean;
|
|
776
|
+
}
|
|
777
|
+
//#endregion
|
|
678
778
|
//#region src/options/normalized-input-options.d.ts
|
|
779
|
+
/** @category Plugin APIs */
|
|
679
780
|
interface NormalizedInputOptions {
|
|
680
781
|
input: string[] | Record<string, string>;
|
|
681
782
|
cwd: string;
|
|
@@ -686,7 +787,9 @@ interface NormalizedInputOptions {
|
|
|
686
787
|
//#endregion
|
|
687
788
|
//#region src/options/normalized-output-options.d.ts
|
|
688
789
|
type PathsFunction = (id: string) => string;
|
|
790
|
+
/** @category Plugin APIs */
|
|
689
791
|
type InternalModuleFormat = "es" | "cjs" | "iife" | "umd";
|
|
792
|
+
/** @category Plugin APIs */
|
|
690
793
|
interface NormalizedOutputOptions {
|
|
691
794
|
name: string | undefined;
|
|
692
795
|
file: string | undefined;
|
|
@@ -701,6 +804,7 @@ interface NormalizedOutputOptions {
|
|
|
701
804
|
cssEntryFileNames: string | ChunkFileNamesFunction;
|
|
702
805
|
cssChunkFileNames: string | ChunkFileNamesFunction;
|
|
703
806
|
inlineDynamicImports: boolean;
|
|
807
|
+
dynamicImportInCjs: boolean;
|
|
704
808
|
externalLiveBindings: boolean;
|
|
705
809
|
banner: AddonFunction;
|
|
706
810
|
footer: AddonFunction;
|
|
@@ -728,6 +832,7 @@ interface NormalizedOutputOptions {
|
|
|
728
832
|
}
|
|
729
833
|
//#endregion
|
|
730
834
|
//#region src/plugin/fs.d.ts
|
|
835
|
+
/** @category Plugin APIs */
|
|
731
836
|
interface RolldownFsModule {
|
|
732
837
|
appendFile(path: string, data: string | Uint8Array, options?: {
|
|
733
838
|
encoding?: BufferEncoding | null;
|
|
@@ -770,13 +875,16 @@ interface RolldownFsModule {
|
|
|
770
875
|
flag?: string | number;
|
|
771
876
|
}): Promise<void>;
|
|
772
877
|
}
|
|
878
|
+
/** @category Plugin APIs */
|
|
773
879
|
type BufferEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "base64" | "base64url" | "latin1" | "binary" | "hex";
|
|
880
|
+
/** @category Plugin APIs */
|
|
774
881
|
interface RolldownDirectoryEntry {
|
|
775
882
|
isFile(): boolean;
|
|
776
883
|
isDirectory(): boolean;
|
|
777
884
|
isSymbolicLink(): boolean;
|
|
778
885
|
name: string;
|
|
779
886
|
}
|
|
887
|
+
/** @category Plugin APIs */
|
|
780
888
|
interface RolldownFileStats {
|
|
781
889
|
isFile(): boolean;
|
|
782
890
|
isDirectory(): boolean;
|
|
@@ -789,6 +897,7 @@ interface RolldownFileStats {
|
|
|
789
897
|
}
|
|
790
898
|
//#endregion
|
|
791
899
|
//#region src/plugin/hook-filter.d.ts
|
|
900
|
+
/** @category Plugin APIs */
|
|
792
901
|
type GeneralHookFilter<Value = StringOrRegExp> = MaybeArray<Value> | {
|
|
793
902
|
include?: MaybeArray<Value>;
|
|
794
903
|
exclude?: MaybeArray<Value>;
|
|
@@ -796,7 +905,9 @@ type GeneralHookFilter<Value = StringOrRegExp> = MaybeArray<Value> | {
|
|
|
796
905
|
interface FormalModuleTypeFilter {
|
|
797
906
|
include?: ModuleType[];
|
|
798
907
|
}
|
|
908
|
+
/** @category Plugin APIs */
|
|
799
909
|
type ModuleTypeFilter = ModuleType[] | FormalModuleTypeFilter;
|
|
910
|
+
/** @category Plugin APIs */
|
|
800
911
|
interface HookFilter {
|
|
801
912
|
/**
|
|
802
913
|
* This filter is used to do a pre-test to determine whether the hook should be called.
|
|
@@ -837,11 +948,13 @@ interface HookFilter {
|
|
|
837
948
|
type TUnionWithTopLevelFilterExpressionArray<T> = T | TopLevelFilterExpression[];
|
|
838
949
|
//#endregion
|
|
839
950
|
//#region src/plugin/minimal-plugin-context.d.ts
|
|
951
|
+
/** @category Plugin APIs */
|
|
840
952
|
interface PluginContextMeta {
|
|
841
953
|
rollupVersion: string;
|
|
842
954
|
rolldownVersion: string;
|
|
843
955
|
watchMode: boolean;
|
|
844
956
|
}
|
|
957
|
+
/** @category Plugin APIs */
|
|
845
958
|
interface MinimalPluginContext {
|
|
846
959
|
readonly pluginName: string;
|
|
847
960
|
error: (e: RollupError | string) => never;
|
|
@@ -853,16 +966,17 @@ interface MinimalPluginContext {
|
|
|
853
966
|
//#endregion
|
|
854
967
|
//#region src/plugin/parallel-plugin.d.ts
|
|
855
968
|
type ParallelPlugin = {
|
|
856
|
-
/** @internal */
|
|
857
969
|
_parallel: {
|
|
858
970
|
fileUrl: string;
|
|
859
971
|
options: unknown;
|
|
860
972
|
};
|
|
861
973
|
};
|
|
974
|
+
/** @internal */
|
|
862
975
|
type DefineParallelPluginResult<Options> = (options: Options) => ParallelPlugin;
|
|
863
976
|
declare function defineParallelPlugin<Options>(pluginPath: string): DefineParallelPluginResult<Options>;
|
|
864
977
|
//#endregion
|
|
865
978
|
//#region src/plugin/plugin-context.d.ts
|
|
979
|
+
/** @category Plugin APIs */
|
|
866
980
|
interface EmittedAsset {
|
|
867
981
|
type: "asset";
|
|
868
982
|
name?: string;
|
|
@@ -886,13 +1000,16 @@ interface EmittedPrebuiltChunk {
|
|
|
886
1000
|
map?: SourceMap;
|
|
887
1001
|
sourcemapFileName?: string;
|
|
888
1002
|
}
|
|
1003
|
+
/** @category Plugin APIs */
|
|
889
1004
|
type EmittedFile = EmittedAsset | EmittedChunk | EmittedPrebuiltChunk;
|
|
890
1005
|
interface PluginContextResolveOptions {
|
|
891
1006
|
isEntry?: boolean;
|
|
892
1007
|
skipSelf?: boolean;
|
|
893
1008
|
custom?: CustomPluginOptions;
|
|
894
1009
|
}
|
|
1010
|
+
/** @category Plugin APIs */
|
|
895
1011
|
type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
|
|
1012
|
+
/** @category Plugin APIs */
|
|
896
1013
|
interface PluginContext extends MinimalPluginContext {
|
|
897
1014
|
fs: RolldownFsModule;
|
|
898
1015
|
emitFile(file: EmittedFile): string;
|
|
@@ -909,6 +1026,7 @@ interface PluginContext extends MinimalPluginContext {
|
|
|
909
1026
|
}
|
|
910
1027
|
//#endregion
|
|
911
1028
|
//#region src/plugin/transform-plugin-context.d.ts
|
|
1029
|
+
/** @category Plugin APIs */
|
|
912
1030
|
interface TransformPluginContext extends PluginContext {
|
|
913
1031
|
debug: LoggingFunctionWithPosition;
|
|
914
1032
|
info: LoggingFunctionWithPosition;
|
|
@@ -927,17 +1045,132 @@ interface ModuleSideEffectsRule {
|
|
|
927
1045
|
sideEffects: boolean;
|
|
928
1046
|
}
|
|
929
1047
|
type ModuleSideEffectsOption = boolean | readonly string[] | ModuleSideEffectsRule[] | ((id: string, external: boolean) => boolean | undefined) | "no-external";
|
|
1048
|
+
/**
|
|
1049
|
+
* When passing an object, you can fine-tune the tree-shaking behavior.
|
|
1050
|
+
*/
|
|
930
1051
|
type TreeshakingOptions = {
|
|
1052
|
+
/**
|
|
1053
|
+
* **Values:**
|
|
1054
|
+
*
|
|
1055
|
+
* - **`true`**: All modules are assumed to have side effects and will be included in the bundle even if none of their exports are used.
|
|
1056
|
+
* - **`false`**: No modules have side effects. This enables aggressive tree-shaking, removing any modules whose exports are not used.
|
|
1057
|
+
* - **`string[]`**: Array of module IDs that have side effects. Only modules in this list will be preserved if unused; all others can be tree-shaken when their exports are unused.
|
|
1058
|
+
* - **`'no-external'`**: Assumes no external modules have side effects while preserving the default behavior for local modules.
|
|
1059
|
+
* - **`ModuleSideEffectsRule[]`**: Array of rules with `test`, `external`, and `sideEffects` properties for fine-grained control.
|
|
1060
|
+
* - **`function`**: Function that receives `(id, external)` and returns whether the module has side effects.
|
|
1061
|
+
*
|
|
1062
|
+
* **Important:** Setting this to `false` or using an array/string assumes that your modules and their dependencies have no side effects other than their exports. Only use this if you're certain that removing unused modules won't break your application.
|
|
1063
|
+
*
|
|
1064
|
+
* > [!NOTE]
|
|
1065
|
+
* > **Performance: Prefer `ModuleSideEffectsRule[]` over functions**
|
|
1066
|
+
* >
|
|
1067
|
+
* > When possible, use rule-based configuration instead of functions. Rules are processed entirely in Rust, while JavaScript functions require runtime calls between Rust and JavaScript, which can hurt CPU utilization during builds.
|
|
1068
|
+
* >
|
|
1069
|
+
* > **Functions should be a last resort**: Only use the function signature when your logic cannot be expressed with patterns or simple string matching.
|
|
1070
|
+
* >
|
|
1071
|
+
* > **Rule advantages**: `ModuleSideEffectsRule[]` provides better performance by avoiding Rust-JavaScript runtime calls, clearer intent, and easier maintenance.
|
|
1072
|
+
*
|
|
1073
|
+
* @example
|
|
1074
|
+
* ```js
|
|
1075
|
+
* // Assume no modules have side effects (aggressive tree-shaking)
|
|
1076
|
+
* treeshake: {
|
|
1077
|
+
* moduleSideEffects: false
|
|
1078
|
+
* }
|
|
1079
|
+
*
|
|
1080
|
+
* // Only specific modules have side effects (string array)
|
|
1081
|
+
* treeshake: {
|
|
1082
|
+
* moduleSideEffects: [
|
|
1083
|
+
* 'lodash',
|
|
1084
|
+
* 'react-dom',
|
|
1085
|
+
* ]
|
|
1086
|
+
* }
|
|
1087
|
+
*
|
|
1088
|
+
* // Use rules for pattern matching and granular control
|
|
1089
|
+
* treeshake: {
|
|
1090
|
+
* moduleSideEffects: [
|
|
1091
|
+
* { test: /^node:/, sideEffects: true },
|
|
1092
|
+
* { test: /\.css$/, sideEffects: true },
|
|
1093
|
+
* { test: /some-package/, sideEffects: false, external: false },
|
|
1094
|
+
* ]
|
|
1095
|
+
* }
|
|
1096
|
+
*
|
|
1097
|
+
* // Custom function to determine side effects
|
|
1098
|
+
* treeshake: {
|
|
1099
|
+
* moduleSideEffects: (id, external) => {
|
|
1100
|
+
* if (external) return false; // external modules have no side effects
|
|
1101
|
+
* return id.includes('/side-effects/') || id.endsWith('.css');
|
|
1102
|
+
* }
|
|
1103
|
+
* }
|
|
1104
|
+
*
|
|
1105
|
+
* // Assume no external modules have side effects
|
|
1106
|
+
* treeshake: {
|
|
1107
|
+
* moduleSideEffects: 'no-external',
|
|
1108
|
+
* }
|
|
1109
|
+
* ```
|
|
1110
|
+
*
|
|
1111
|
+
* **Common Use Cases:**
|
|
1112
|
+
* - **CSS files**: `{ test: /\.css$/, sideEffects: true }` - preserve CSS imports
|
|
1113
|
+
* - **Polyfills**: Add specific polyfill modules to the array
|
|
1114
|
+
* - **Plugins**: Modules that register themselves globally on import
|
|
1115
|
+
* - **Library development**: Set to `false` for libraries where unused exports should be removed
|
|
1116
|
+
* @default true
|
|
1117
|
+
*/
|
|
931
1118
|
moduleSideEffects?: ModuleSideEffectsOption;
|
|
1119
|
+
/**
|
|
1120
|
+
* Whether to respect `/*@__PURE__*\/` annotations and other tree-shaking hints in the code.
|
|
1121
|
+
* @default true
|
|
1122
|
+
*/
|
|
932
1123
|
annotations?: boolean;
|
|
1124
|
+
/**
|
|
1125
|
+
* Array of function names that should be considered pure (no side effects) even if they can't be automatically detected as pure
|
|
1126
|
+
*
|
|
1127
|
+
* @example
|
|
1128
|
+
* ```js
|
|
1129
|
+
* treeshake: {
|
|
1130
|
+
* manualPureFunctions: ['console.log', 'debug.trace']
|
|
1131
|
+
* }
|
|
1132
|
+
* ```
|
|
1133
|
+
* @default []
|
|
1134
|
+
*/
|
|
933
1135
|
manualPureFunctions?: readonly string[];
|
|
1136
|
+
/**
|
|
1137
|
+
* Whether to assume that accessing unknown global properties might have side effects.
|
|
1138
|
+
* @default true
|
|
1139
|
+
*/
|
|
934
1140
|
unknownGlobalSideEffects?: boolean;
|
|
1141
|
+
/**
|
|
1142
|
+
* Whether to enable tree-shaking for CommonJS modules. When `true`, unused exports from CommonJS modules can be eliminated from the bundle, similar to ES modules. When disabled, CommonJS modules will always be included in their entirety.
|
|
1143
|
+
*
|
|
1144
|
+
* This option allows rolldown to analyze `exports.property` assignments in CommonJS modules and remove unused exports while preserving the module's side effects.
|
|
1145
|
+
*
|
|
1146
|
+
* @example
|
|
1147
|
+
* ```js
|
|
1148
|
+
* // source.js (CommonJS)
|
|
1149
|
+
* exports.used = 'This will be kept';
|
|
1150
|
+
* exports.unused = 'This will be tree-shaken away';
|
|
1151
|
+
*
|
|
1152
|
+
* // main.js
|
|
1153
|
+
* import { used } from './source.js';
|
|
1154
|
+
* // With commonjs: true, only the 'used' export is included in the bundle
|
|
1155
|
+
* // With commonjs: false, both exports are included
|
|
1156
|
+
* ```
|
|
1157
|
+
* @default true
|
|
1158
|
+
*/
|
|
935
1159
|
commonjs?: boolean;
|
|
1160
|
+
/**
|
|
1161
|
+
* Controls whether reading properties from objects is considered to have side effects. Set to `always` for more conservative behavior.
|
|
1162
|
+
* @default false
|
|
1163
|
+
*/
|
|
936
1164
|
propertyReadSideEffects?: false | "always";
|
|
1165
|
+
/**
|
|
1166
|
+
* Controls whether writing properties to objects is considered to have side effects. Set to `always` for conservative behavior.
|
|
1167
|
+
* @default 'always'
|
|
1168
|
+
*/
|
|
937
1169
|
propertyWriteSideEffects?: false | "always";
|
|
938
1170
|
};
|
|
939
1171
|
//#endregion
|
|
940
1172
|
//#region src/types/output-bundle.d.ts
|
|
1173
|
+
/** @category Plugin APIs */
|
|
941
1174
|
interface OutputBundle {
|
|
942
1175
|
[fileName: string]: OutputAsset | OutputChunk;
|
|
943
1176
|
}
|
|
@@ -946,6 +1179,7 @@ interface OutputBundle {
|
|
|
946
1179
|
type RolldownOptionsFunction = (commandLineArguments: Record<string, any>) => MaybePromise<RolldownOptions | RolldownOptions[]>;
|
|
947
1180
|
//#endregion
|
|
948
1181
|
//#region src/types/sourcemap.d.ts
|
|
1182
|
+
/** @category Plugin APIs */
|
|
949
1183
|
interface ExistingRawSourceMap {
|
|
950
1184
|
file?: string | null;
|
|
951
1185
|
mappings: string;
|
|
@@ -959,6 +1193,7 @@ interface ExistingRawSourceMap {
|
|
|
959
1193
|
type SourceMapInput = ExistingRawSourceMap | string | null;
|
|
960
1194
|
//#endregion
|
|
961
1195
|
//#region src/version.d.ts
|
|
1196
|
+
/** @category Plugin APIs */
|
|
962
1197
|
declare const VERSION: string;
|
|
963
1198
|
//#endregion
|
|
964
1199
|
//#region src/constants/plugin.d.ts
|
|
@@ -975,7 +1210,7 @@ declare const ENUMERATED_PLUGIN_HOOK_NAMES: [...typeof ENUMERATED_INPUT_PLUGIN_H
|
|
|
975
1210
|
* }
|
|
976
1211
|
* ```
|
|
977
1212
|
*/
|
|
978
|
-
type DefinedHookNames = { readonly [K in typeof ENUMERATED_PLUGIN_HOOK_NAMES[number]]: K };
|
|
1213
|
+
type DefinedHookNames = { readonly [K in (typeof ENUMERATED_PLUGIN_HOOK_NAMES)[number]]: K };
|
|
979
1214
|
/**
|
|
980
1215
|
* Names of all defined hooks. It's like
|
|
981
1216
|
* ```js
|
|
@@ -999,43 +1234,55 @@ declare function withFilter<A, T extends RolldownPluginOption<A>>(pluginOption:
|
|
|
999
1234
|
//#endregion
|
|
1000
1235
|
//#region src/plugin/index.d.ts
|
|
1001
1236
|
type ModuleSideEffects = boolean | "no-treeshake" | null;
|
|
1237
|
+
/** @category Plugin APIs */
|
|
1002
1238
|
type ModuleType = "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | (string & {});
|
|
1239
|
+
/** @category Plugin APIs */
|
|
1003
1240
|
type ImportKind = BindingHookResolveIdExtraArgs["kind"];
|
|
1241
|
+
/** @category Plugin APIs */
|
|
1004
1242
|
interface CustomPluginOptions {
|
|
1005
1243
|
[plugin: string]: any;
|
|
1006
1244
|
}
|
|
1245
|
+
/** @category Plugin APIs */
|
|
1007
1246
|
interface ModuleOptions {
|
|
1008
1247
|
moduleSideEffects: ModuleSideEffects;
|
|
1009
1248
|
meta: CustomPluginOptions;
|
|
1010
1249
|
invalidate?: boolean;
|
|
1011
1250
|
packageJsonPath?: string;
|
|
1012
1251
|
}
|
|
1252
|
+
/** @category Plugin APIs */
|
|
1013
1253
|
interface ResolvedId extends ModuleOptions {
|
|
1014
1254
|
external: boolean | "absolute";
|
|
1015
1255
|
id: string;
|
|
1016
1256
|
}
|
|
1257
|
+
/** @category Plugin APIs */
|
|
1017
1258
|
interface PartialResolvedId extends Partial<PartialNull<ModuleOptions>> {
|
|
1018
1259
|
external?: boolean | "absolute" | "relative";
|
|
1019
1260
|
id: string;
|
|
1020
1261
|
}
|
|
1262
|
+
/** @category Plugin APIs */
|
|
1021
1263
|
interface SourceDescription extends Partial<PartialNull<ModuleOptions>> {
|
|
1022
1264
|
code: string;
|
|
1023
1265
|
map?: SourceMapInput;
|
|
1024
1266
|
moduleType?: ModuleType;
|
|
1025
1267
|
}
|
|
1268
|
+
/** @category Plugin APIs */
|
|
1026
1269
|
interface ResolveIdExtraOptions {
|
|
1027
1270
|
custom?: CustomPluginOptions;
|
|
1028
1271
|
isEntry: boolean;
|
|
1029
1272
|
kind: BindingHookResolveIdExtraArgs["kind"];
|
|
1030
1273
|
}
|
|
1274
|
+
/** @category Plugin APIs */
|
|
1031
1275
|
type ResolveIdResult = string | NullValue | false | PartialResolvedId;
|
|
1276
|
+
/** @category Plugin APIs */
|
|
1032
1277
|
type LoadResult = NullValue | string | SourceDescription;
|
|
1278
|
+
/** @category Plugin APIs */
|
|
1033
1279
|
type TransformResult = NullValue | string | (Omit<SourceDescription, "code"> & {
|
|
1034
1280
|
code?: string | BindingMagicString;
|
|
1035
1281
|
});
|
|
1036
1282
|
type RenderedChunkMeta = {
|
|
1037
1283
|
chunks: Record<string, RenderedChunk>;
|
|
1038
1284
|
};
|
|
1285
|
+
/** @category Plugin APIs */
|
|
1039
1286
|
interface FunctionPluginHooks {
|
|
1040
1287
|
[DEFINED_HOOK_NAMES.onLog]: (this: MinimalPluginContext, level: LogLevel, log: RollupLog) => NullValue | boolean;
|
|
1041
1288
|
[DEFINED_HOOK_NAMES.options]: (this: MinimalPluginContext, options: InputOptions) => NullValue | InputOptions;
|
|
@@ -1075,16 +1322,20 @@ type PluginOrder = "pre" | "post" | null;
|
|
|
1075
1322
|
type ObjectHookMeta = {
|
|
1076
1323
|
order?: PluginOrder;
|
|
1077
1324
|
};
|
|
1325
|
+
/** @category Plugin APIs */
|
|
1078
1326
|
type ObjectHook<T, O = {}> = T | ({
|
|
1079
1327
|
handler: T;
|
|
1080
1328
|
} & ObjectHookMeta & O);
|
|
1081
1329
|
type SyncPluginHooks = DefinedHookNames["augmentChunkHash" | "onLog" | "outputOptions"];
|
|
1330
|
+
/** @category Plugin APIs */
|
|
1082
1331
|
type AsyncPluginHooks = Exclude<keyof FunctionPluginHooks, SyncPluginHooks>;
|
|
1083
1332
|
type FirstPluginHooks = DefinedHookNames["load" | "resolveDynamicImport" | "resolveId"];
|
|
1084
1333
|
type SequentialPluginHooks = DefinedHookNames["augmentChunkHash" | "generateBundle" | "onLog" | "options" | "outputOptions" | "renderChunk" | "transform"];
|
|
1085
1334
|
type AddonHooks = DefinedHookNames["banner" | "footer" | "intro" | "outro"];
|
|
1086
1335
|
type OutputPluginHooks = DefinedHookNames["augmentChunkHash" | "generateBundle" | "outputOptions" | "renderChunk" | "renderError" | "renderStart" | "writeBundle"];
|
|
1336
|
+
/** @internal */
|
|
1087
1337
|
type ParallelPluginHooks = Exclude<keyof FunctionPluginHooks | AddonHooks, FirstPluginHooks | SequentialPluginHooks>;
|
|
1338
|
+
/** @category Plugin APIs */
|
|
1088
1339
|
type HookFilterExtension<K$1 extends keyof FunctionPluginHooks> = K$1 extends "transform" ? {
|
|
1089
1340
|
filter?: TUnionWithTopLevelFilterExpressionArray<HookFilter>;
|
|
1090
1341
|
} : K$1 extends "load" ? {
|
|
@@ -1109,6 +1360,7 @@ type AddonHook = string | AddonHookFunction;
|
|
|
1109
1360
|
interface OutputPlugin extends Partial<{ [K in keyof PluginHooks as K & OutputPluginHooks]: PluginHooks[K] }>, Partial<{ [K in AddonHooks]: ObjectHook<AddonHook> }> {
|
|
1110
1361
|
name: string;
|
|
1111
1362
|
}
|
|
1363
|
+
/** @category Plugin APIs */
|
|
1112
1364
|
interface Plugin<A = any> extends OutputPlugin, Partial<PluginHooks> {
|
|
1113
1365
|
api?: A;
|
|
1114
1366
|
}
|
|
@@ -1121,90 +1373,6 @@ type RolldownOutputPluginOption = MaybePromise<NullValue<RolldownOutputPlugin> |
|
|
|
1121
1373
|
name: string;
|
|
1122
1374
|
} | false | RolldownOutputPluginOption[]>;
|
|
1123
1375
|
//#endregion
|
|
1124
|
-
//#region src/options/generated/checks-options.d.ts
|
|
1125
|
-
interface ChecksOptions {
|
|
1126
|
-
/**
|
|
1127
|
-
* Whether to emit warning when detecting circular dependency
|
|
1128
|
-
* @default false
|
|
1129
|
-
*/
|
|
1130
|
-
circularDependency?: boolean;
|
|
1131
|
-
/**
|
|
1132
|
-
* Whether to emit warning when detecting eval
|
|
1133
|
-
* @default true
|
|
1134
|
-
*/
|
|
1135
|
-
eval?: boolean;
|
|
1136
|
-
/**
|
|
1137
|
-
* Whether to emit warning when detecting missing global name
|
|
1138
|
-
* @default true
|
|
1139
|
-
*/
|
|
1140
|
-
missingGlobalName?: boolean;
|
|
1141
|
-
/**
|
|
1142
|
-
* Whether to emit warning when detecting missing name option for iife export
|
|
1143
|
-
* @default true
|
|
1144
|
-
*/
|
|
1145
|
-
missingNameOptionForIifeExport?: boolean;
|
|
1146
|
-
/**
|
|
1147
|
-
* Whether to emit warning when detecting mixed exports
|
|
1148
|
-
* @default true
|
|
1149
|
-
*/
|
|
1150
|
-
mixedExports?: boolean;
|
|
1151
|
-
/**
|
|
1152
|
-
* Whether to emit warning when detecting unresolved entry
|
|
1153
|
-
* @default true
|
|
1154
|
-
*/
|
|
1155
|
-
unresolvedEntry?: boolean;
|
|
1156
|
-
/**
|
|
1157
|
-
* Whether to emit warning when detecting unresolved import
|
|
1158
|
-
* @default true
|
|
1159
|
-
*/
|
|
1160
|
-
unresolvedImport?: boolean;
|
|
1161
|
-
/**
|
|
1162
|
-
* Whether to emit warning when detecting filename conflict
|
|
1163
|
-
* @default true
|
|
1164
|
-
*/
|
|
1165
|
-
filenameConflict?: boolean;
|
|
1166
|
-
/**
|
|
1167
|
-
* Whether to emit warning when detecting common js variable in esm
|
|
1168
|
-
* @default true
|
|
1169
|
-
*/
|
|
1170
|
-
commonJsVariableInEsm?: boolean;
|
|
1171
|
-
/**
|
|
1172
|
-
* Whether to emit warning when detecting import is undefined
|
|
1173
|
-
* @default true
|
|
1174
|
-
*/
|
|
1175
|
-
importIsUndefined?: boolean;
|
|
1176
|
-
/**
|
|
1177
|
-
* Whether to emit warning when detecting empty import meta
|
|
1178
|
-
* @default true
|
|
1179
|
-
*/
|
|
1180
|
-
emptyImportMeta?: boolean;
|
|
1181
|
-
/**
|
|
1182
|
-
* Whether to emit warning when detecting cannot call namespace
|
|
1183
|
-
* @default true
|
|
1184
|
-
*/
|
|
1185
|
-
cannotCallNamespace?: boolean;
|
|
1186
|
-
/**
|
|
1187
|
-
* Whether to emit warning when detecting configuration field conflict
|
|
1188
|
-
* @default true
|
|
1189
|
-
*/
|
|
1190
|
-
configurationFieldConflict?: boolean;
|
|
1191
|
-
/**
|
|
1192
|
-
* Whether to emit warning when detecting prefer builtin feature
|
|
1193
|
-
* @default true
|
|
1194
|
-
*/
|
|
1195
|
-
preferBuiltinFeature?: boolean;
|
|
1196
|
-
/**
|
|
1197
|
-
* Whether to emit warning when detecting could not clean directory
|
|
1198
|
-
* @default true
|
|
1199
|
-
*/
|
|
1200
|
-
couldNotCleanDirectory?: boolean;
|
|
1201
|
-
/**
|
|
1202
|
-
* Whether to emit warning when detecting plugin timings
|
|
1203
|
-
* @default true
|
|
1204
|
-
*/
|
|
1205
|
-
pluginTimings?: boolean;
|
|
1206
|
-
}
|
|
1207
|
-
//#endregion
|
|
1208
1376
|
//#region src/options/transform-options.d.ts
|
|
1209
1377
|
interface TransformOptions extends Omit<TransformOptions$1, "sourceType" | "lang" | "cwd" | "sourcemap" | "define" | "inject" | "jsx"> {
|
|
1210
1378
|
/**
|
|
@@ -1341,7 +1509,8 @@ type OptimizationOptions = {
|
|
|
1341
1509
|
*
|
|
1342
1510
|
* When enabled, constant values from imported modules will be inlined at their usage sites,
|
|
1343
1511
|
* potentially reducing bundle size and improving runtime performance by eliminating variable lookups.
|
|
1344
|
-
*
|
|
1512
|
+
*
|
|
1513
|
+
* **Options:**
|
|
1345
1514
|
* - `true`: equivalent to `{ mode: 'all', pass: 1 }`, enabling constant inlining for all eligible constants with a single pass.
|
|
1346
1515
|
* - `false`: Disable constant inlining
|
|
1347
1516
|
* - `{ mode: 'smart' | 'all', pass?: number }`:
|
|
@@ -1355,7 +1524,7 @@ type OptimizationOptions = {
|
|
|
1355
1524
|
* - `mode: 'all'`: Inline all imported constants wherever they are used.
|
|
1356
1525
|
* - `pass`: Number of passes to perform for inlining constants.
|
|
1357
1526
|
*
|
|
1358
|
-
*
|
|
1527
|
+
* @example
|
|
1359
1528
|
* ```js
|
|
1360
1529
|
* // Input files:
|
|
1361
1530
|
* // constants.js
|
|
@@ -1389,18 +1558,44 @@ type ChunkModulesOrder = "exec-order" | "module-id";
|
|
|
1389
1558
|
type OnLogFunction = (level: LogLevel, log: RollupLog, defaultHandler: LogOrStringHandler) => void;
|
|
1390
1559
|
type OnwarnFunction = (warning: RollupLog, defaultHandler: (warning: RollupLogWithString | (() => RollupLogWithString)) => void) => void;
|
|
1391
1560
|
interface InputOptions {
|
|
1561
|
+
/**
|
|
1562
|
+
* Defines entries and location(s) of entry modules for the bundle. Relative paths are resolved based on the `cwd` option.
|
|
1563
|
+
* {@include ./docs/input.md}
|
|
1564
|
+
*/
|
|
1392
1565
|
input?: InputOption;
|
|
1393
1566
|
plugins?: RolldownPluginOption;
|
|
1567
|
+
/**
|
|
1568
|
+
* Specifies which modules should be treated as external and not bundled. External modules will be left as import statements in the output.
|
|
1569
|
+
* {@include ./docs/external.md}
|
|
1570
|
+
*/
|
|
1394
1571
|
external?: ExternalOption;
|
|
1395
1572
|
resolve?: {
|
|
1396
1573
|
/**
|
|
1574
|
+
* @example
|
|
1575
|
+
* ```js
|
|
1576
|
+
* resolve: {
|
|
1577
|
+
* alias: {
|
|
1578
|
+
* '@': '/src',
|
|
1579
|
+
* 'utils': './src/utils',
|
|
1580
|
+
* }
|
|
1581
|
+
* }
|
|
1582
|
+
* ```
|
|
1397
1583
|
* > [!WARNING]
|
|
1398
1584
|
* > `resolve.alias` will not call `resolveId` hooks of other plugin.
|
|
1399
1585
|
* > If you want to call `resolveId` hooks of other plugin, use `viteAliasPlugin` from `rolldown/experimental` instead.
|
|
1400
1586
|
* > You could find more discussion in [this issue](https://github.com/rolldown/rolldown/issues/3615)
|
|
1401
1587
|
*/
|
|
1402
1588
|
alias?: Record<string, string[] | string | false>;
|
|
1589
|
+
/**
|
|
1590
|
+
* Fields in package.json to check for aliased paths.
|
|
1591
|
+
*/
|
|
1403
1592
|
aliasFields?: string[][];
|
|
1593
|
+
/**
|
|
1594
|
+
* Condition names to use when resolving exports in package.json. Defaults based on platform and import kind:
|
|
1595
|
+
* - **Browser platform**: `["import", "browser", "default"]` for import statements, `["require", "browser", "default"]` for require() calls
|
|
1596
|
+
* - **Node platform**: `["import", "node", "default"]` for import statements, `["require", "node", "default"]` for require() calls
|
|
1597
|
+
* - **Neutral platform**: `["import", "default"]` for import statements, `["require", "default"]` for require() calls
|
|
1598
|
+
*/
|
|
1404
1599
|
conditionNames?: string[];
|
|
1405
1600
|
/**
|
|
1406
1601
|
* Map of extensions to alternative extensions.
|
|
@@ -1409,17 +1604,46 @@ interface InputOptions {
|
|
|
1409
1604
|
* You can achieve this by setting: `extensionAlias: { '.js': ['.ts', '.js'] }`.
|
|
1410
1605
|
*/
|
|
1411
1606
|
extensionAlias?: Record<string, string[]>;
|
|
1607
|
+
/**
|
|
1608
|
+
* Fields in package.json to check for exports.
|
|
1609
|
+
*/
|
|
1412
1610
|
exportsFields?: string[][];
|
|
1611
|
+
/**
|
|
1612
|
+
* Extensions to try when resolving files. These are tried in order from first to last.
|
|
1613
|
+
* @default ['.tsx', '.ts', '.jsx', '.js', '.json']
|
|
1614
|
+
*/
|
|
1413
1615
|
extensions?: string[];
|
|
1616
|
+
/**
|
|
1617
|
+
* Fields in package.json to check for entry points. Defaults based on platform:
|
|
1618
|
+
* - **Node**: `['main', 'module']`
|
|
1619
|
+
* - **Browser**: `['browser', 'module', 'main']`
|
|
1620
|
+
* - **Neutral**: `[]` (relies on exports field)
|
|
1621
|
+
*/
|
|
1414
1622
|
mainFields?: string[];
|
|
1623
|
+
/**
|
|
1624
|
+
* Filenames to try when resolving directories.
|
|
1625
|
+
* @default ['index']
|
|
1626
|
+
*/
|
|
1415
1627
|
mainFiles?: string[];
|
|
1628
|
+
/**
|
|
1629
|
+
* Directories to search for modules.
|
|
1630
|
+
* @default ['node_modules']
|
|
1631
|
+
*/
|
|
1416
1632
|
modules?: string[];
|
|
1633
|
+
/**
|
|
1634
|
+
* Whether to follow symlinks when resolving modules.
|
|
1635
|
+
* @default true
|
|
1636
|
+
*/
|
|
1417
1637
|
symlinks?: boolean;
|
|
1418
1638
|
/**
|
|
1419
1639
|
* @deprecated Use the top-level `tsconfig` option instead.
|
|
1420
1640
|
*/
|
|
1421
1641
|
tsconfigFilename?: string;
|
|
1422
1642
|
};
|
|
1643
|
+
/**
|
|
1644
|
+
* The working directory to use when resolving relative paths in the configuration.
|
|
1645
|
+
* @default process.cwd()
|
|
1646
|
+
*/
|
|
1423
1647
|
cwd?: string;
|
|
1424
1648
|
/**
|
|
1425
1649
|
* Expected platform where the code run.
|
|
@@ -1432,55 +1656,147 @@ interface InputOptions {
|
|
|
1432
1656
|
* @default
|
|
1433
1657
|
* - 'node' if the format is 'cjs'
|
|
1434
1658
|
* - 'browser' for other formats
|
|
1659
|
+
* {@include ./docs/platform.md}
|
|
1435
1660
|
*/
|
|
1436
1661
|
platform?: "node" | "browser" | "neutral";
|
|
1662
|
+
/**
|
|
1663
|
+
* When `true`, creates shim variables for missing exports instead of throwing an error.
|
|
1664
|
+
* @default false
|
|
1665
|
+
* {@include ./docs/shim-missing-exports.md}
|
|
1666
|
+
*/
|
|
1437
1667
|
shimMissingExports?: boolean;
|
|
1668
|
+
/**
|
|
1669
|
+
* Controls tree-shaking (dead code elimination). When `true`, unused code will be removed from the bundle to reduce bundle size.
|
|
1670
|
+
* @default true
|
|
1671
|
+
*/
|
|
1438
1672
|
treeshake?: boolean | TreeshakingOptions;
|
|
1673
|
+
/**
|
|
1674
|
+
* Controls the verbosity of console logging during the build.
|
|
1675
|
+
* @default 'info'
|
|
1676
|
+
*/
|
|
1439
1677
|
logLevel?: LogLevelOption;
|
|
1678
|
+
/**
|
|
1679
|
+
* Custom handler for logs. Called for each log message before it's written to the console.
|
|
1680
|
+
*/
|
|
1440
1681
|
onLog?: OnLogFunction;
|
|
1682
|
+
/**
|
|
1683
|
+
* Custom handler for warnings during the build process.
|
|
1684
|
+
* @deprecated
|
|
1685
|
+
* :::: warning Deprecated
|
|
1686
|
+
* This is a legacy API. Consider using `onLog` instead for better control over all log types.
|
|
1687
|
+
* ::: details Migration to `onLog`
|
|
1688
|
+
* To migrate from `onwarn` to `onLog`, check the `level` parameter to filter for
|
|
1689
|
+
* warnings:
|
|
1690
|
+
* ```js
|
|
1691
|
+
* // Before: Using `onwarn`
|
|
1692
|
+
* export default {
|
|
1693
|
+
* onwarn(warning, defaultHandler) {
|
|
1694
|
+
* // Suppress certain warnings
|
|
1695
|
+
* if (warning.code === 'CIRCULAR_DEPENDENCY') return;
|
|
1696
|
+
* // Handle other warnings with default behavior
|
|
1697
|
+
* defaultHandler(warning);
|
|
1698
|
+
* },
|
|
1699
|
+
* };
|
|
1700
|
+
* ```
|
|
1701
|
+
* ```js
|
|
1702
|
+
* // After: Using `onLog`
|
|
1703
|
+
* export default {
|
|
1704
|
+
* onLog(level, log, defaultHandler) {
|
|
1705
|
+
* // Handle only warnings (same behavior as `onwarn`)
|
|
1706
|
+
* if (level === 'warn') {
|
|
1707
|
+
* // Suppress certain warnings
|
|
1708
|
+
* if (log.code === 'CIRCULAR_DEPENDENCY') return;
|
|
1709
|
+
* // Handle other warnings with default behavior
|
|
1710
|
+
* defaultHandler(level, log);
|
|
1711
|
+
* } else {
|
|
1712
|
+
* // Let other log levels pass through
|
|
1713
|
+
* defaultHandler(level, log);
|
|
1714
|
+
* }
|
|
1715
|
+
* },
|
|
1716
|
+
* };
|
|
1717
|
+
* ```
|
|
1718
|
+
* :::
|
|
1719
|
+
* ::::
|
|
1720
|
+
*/
|
|
1441
1721
|
onwarn?: OnwarnFunction;
|
|
1722
|
+
/**
|
|
1723
|
+
* Maps file patterns to module types, controlling how files are processed. This is conceptually similar to esbuild's loader option, allowing you to specify how different file extensions should be handled.
|
|
1724
|
+
*/
|
|
1442
1725
|
moduleTypes?: ModuleTypes;
|
|
1726
|
+
/**
|
|
1727
|
+
* Experimental features that may change in future releases and can introduce behavior change without a major version bump.
|
|
1728
|
+
*/
|
|
1443
1729
|
experimental?: {
|
|
1444
1730
|
/**
|
|
1445
1731
|
* Lets modules be executed in the order they are declared.
|
|
1446
1732
|
*
|
|
1447
|
-
* - Type: `boolean`
|
|
1448
|
-
* - Default: `false`
|
|
1449
|
-
*
|
|
1450
1733
|
* This is done by injecting runtime helpers to ensure that modules are executed in the order they are imported. External modules won't be affected.
|
|
1451
1734
|
*
|
|
1452
1735
|
* > [!WARNING]
|
|
1453
1736
|
* > Enabling this option may negatively increase bundle size. It is recommended to use this option only when absolutely necessary.
|
|
1737
|
+
* @default false
|
|
1454
1738
|
*/
|
|
1455
1739
|
strictExecutionOrder?: boolean;
|
|
1740
|
+
/**
|
|
1741
|
+
* Disable live bindings for exported variables.
|
|
1742
|
+
* @default false
|
|
1743
|
+
*/
|
|
1456
1744
|
disableLiveBindings?: boolean;
|
|
1745
|
+
/**
|
|
1746
|
+
* Enable Vite compatible mode.
|
|
1747
|
+
* @default false
|
|
1748
|
+
*/
|
|
1457
1749
|
viteMode?: boolean;
|
|
1750
|
+
/**
|
|
1751
|
+
* When enabled, `new URL()` calls will be transformed to a stable asset URL which includes the updated name and content hash.
|
|
1752
|
+
* It is necessary to pass `import.meta.url` as the second argument to the
|
|
1753
|
+
* `new URL` constructor, otherwise no transform will be applied.
|
|
1754
|
+
* :::warning
|
|
1755
|
+
* JavaScript and TypeScript files referenced via `new URL('./file.js', import.meta.url)` or `new URL('./file.ts', import.meta.url)` will **not** be transformed or bundled. The file will be copied as-is, meaning TypeScript files remain untransformed and dependencies are not resolved.
|
|
1756
|
+
*
|
|
1757
|
+
* The expected behavior for JS/TS files is still being discussed and may
|
|
1758
|
+
* change in future releases. See [#7258](https://github.com/rolldown/rolldown/issues/7258) for more context.
|
|
1759
|
+
* :::
|
|
1760
|
+
* @example
|
|
1761
|
+
* ```js
|
|
1762
|
+
* // main.js
|
|
1763
|
+
* const url = new URL('./styles.css', import.meta.url);
|
|
1764
|
+
* console.log(url);
|
|
1765
|
+
*
|
|
1766
|
+
* // Example output after bundling WITHOUT the option (default)
|
|
1767
|
+
* const url = new URL('./styles.css', import.meta.url);
|
|
1768
|
+
* console.log(url);
|
|
1769
|
+
*
|
|
1770
|
+
* // Example output after bundling WITH `experimental.resolveNewUrlToAsset` set to `true`
|
|
1771
|
+
* const url = new URL('assets/styles-CjdrdY7X.css', import.meta.url);
|
|
1772
|
+
* console.log(url);
|
|
1773
|
+
* ```
|
|
1774
|
+
* @default false
|
|
1775
|
+
*/
|
|
1458
1776
|
resolveNewUrlToAsset?: boolean;
|
|
1459
1777
|
devMode?: DevModeOptions;
|
|
1460
1778
|
/**
|
|
1461
|
-
* Control which order should use when rendering modules in chunk
|
|
1462
|
-
*
|
|
1463
|
-
* - Type: `'exec-order' | 'module-id'
|
|
1464
|
-
* - Default: `'exec-order'`
|
|
1779
|
+
* Control which order should use when rendering modules in chunk.
|
|
1465
1780
|
*
|
|
1781
|
+
* Available options:
|
|
1466
1782
|
* - `exec-order`: Almost equivalent to the topological order of the module graph, but specially handling when module graph has cycle.
|
|
1467
1783
|
* - `module-id`: This is more friendly for gzip compression, especially for some javascript static asset lib (e.g. icon library)
|
|
1468
1784
|
* > [!NOTE]
|
|
1469
1785
|
* > Try to sort the modules by their module id if possible(Since rolldown scope hoist all modules in the chunk, we only try to sort those modules by module id if we could ensure runtime behavior is correct after sorting).
|
|
1786
|
+
* @default 'exec-order'
|
|
1470
1787
|
*/
|
|
1471
1788
|
chunkModulesOrder?: ChunkModulesOrder;
|
|
1472
1789
|
/**
|
|
1473
1790
|
* Attach debug information to the output bundle.
|
|
1474
1791
|
*
|
|
1475
|
-
*
|
|
1476
|
-
* - Default: `'simple'`
|
|
1477
|
-
*
|
|
1792
|
+
* Available modes:
|
|
1478
1793
|
* - `none`: No debug information is attached.
|
|
1479
1794
|
* - `simple`: Attach comments indicating which files the bundled code comes from. These comments could be removed by the minifier.
|
|
1480
1795
|
* - `full`: Attach detailed debug information to the output bundle. These comments are using legal comment syntax, so they won't be removed by the minifier.
|
|
1481
1796
|
*
|
|
1482
1797
|
* > [!WARNING]
|
|
1483
1798
|
* > You shouldn't use `full` in the production build.
|
|
1799
|
+
* @default 'simple'
|
|
1484
1800
|
*/
|
|
1485
1801
|
attachDebugInfo?: AttachDebugOptions;
|
|
1486
1802
|
/**
|
|
@@ -1494,8 +1810,7 @@ interface InputOptions {
|
|
|
1494
1810
|
* (default `"/"`) can be applied to all paths. The resulting JSON is a valid import map and can be
|
|
1495
1811
|
* directly injected into HTML via `<script type="importmap">`.
|
|
1496
1812
|
*
|
|
1497
|
-
*
|
|
1498
|
-
*
|
|
1813
|
+
* @example
|
|
1499
1814
|
* ```js
|
|
1500
1815
|
* {
|
|
1501
1816
|
* experimental: {
|
|
@@ -1527,31 +1842,38 @@ interface InputOptions {
|
|
|
1527
1842
|
* }
|
|
1528
1843
|
* ```
|
|
1529
1844
|
*
|
|
1530
|
-
* > [!
|
|
1845
|
+
* > [!TIP]
|
|
1531
1846
|
* > If you want to learn more, you can check out the example here: [examples/chunk-import-map](https://github.com/rolldown/rolldown/tree/main/examples/chunk-import-map)
|
|
1847
|
+
* @default false
|
|
1532
1848
|
*/
|
|
1533
1849
|
chunkImportMap?: boolean | {
|
|
1534
1850
|
baseUrl?: string;
|
|
1535
1851
|
fileName?: string;
|
|
1536
1852
|
};
|
|
1853
|
+
/**
|
|
1854
|
+
* Enable on-demand wrapping of modules.
|
|
1855
|
+
* @default false
|
|
1856
|
+
*/
|
|
1537
1857
|
onDemandWrapping?: boolean;
|
|
1538
1858
|
/**
|
|
1539
|
-
* Required to be used with `watch` mode.
|
|
1859
|
+
* Enable incremental build support. Required to be used with `watch` mode.
|
|
1860
|
+
* @default false
|
|
1540
1861
|
*/
|
|
1541
1862
|
incrementalBuild?: boolean;
|
|
1863
|
+
/**
|
|
1864
|
+
* Enable high-resolution source maps for transform operations.
|
|
1865
|
+
* @default false
|
|
1866
|
+
*/
|
|
1542
1867
|
transformHiresSourcemap?: boolean | "boundary";
|
|
1543
1868
|
/**
|
|
1544
1869
|
* Use native Rust implementation of MagicString for source map generation.
|
|
1545
1870
|
*
|
|
1546
|
-
* - Type: `boolean`
|
|
1547
|
-
* - Default: `false`
|
|
1548
|
-
*
|
|
1549
1871
|
* [MagicString](https://github.com/rich-harris/magic-string) is a JavaScript library commonly used by bundlers
|
|
1550
1872
|
* for string manipulation and source map generation. When enabled, rolldown will use a native Rust
|
|
1551
1873
|
* implementation of MagicString instead of the JavaScript version, providing significantly better performance
|
|
1552
1874
|
* during source map generation and code transformation.
|
|
1553
1875
|
*
|
|
1554
|
-
*
|
|
1876
|
+
* **Benefits**
|
|
1555
1877
|
*
|
|
1556
1878
|
* - **Improved Performance**: The native Rust implementation is typically faster than the JavaScript version,
|
|
1557
1879
|
* especially for large codebases with extensive source maps.
|
|
@@ -1560,8 +1882,7 @@ interface InputOptions {
|
|
|
1560
1882
|
* reduce overall build times when working with JavaScript transform hooks.
|
|
1561
1883
|
* - **Better Integration**: Seamless integration with rolldown's native Rust architecture.
|
|
1562
1884
|
*
|
|
1563
|
-
*
|
|
1564
|
-
*
|
|
1885
|
+
* @example
|
|
1565
1886
|
* ```js
|
|
1566
1887
|
* export default {
|
|
1567
1888
|
* experimental: {
|
|
@@ -1577,6 +1898,7 @@ interface InputOptions {
|
|
|
1577
1898
|
* > This is an experimental feature. While it aims to provide identical behavior to the JavaScript
|
|
1578
1899
|
* > implementation, there may be edge cases. Please report any discrepancies you encounter.
|
|
1579
1900
|
* > For a complete working example, see [examples/native-magic-string](https://github.com/rolldown/rolldown/tree/main/examples/native-magic-string)
|
|
1901
|
+
* @default false
|
|
1580
1902
|
*/
|
|
1581
1903
|
nativeMagicString?: boolean;
|
|
1582
1904
|
};
|
|
@@ -1599,33 +1921,52 @@ interface InputOptions {
|
|
|
1599
1921
|
*/
|
|
1600
1922
|
transform?: TransformOptions;
|
|
1601
1923
|
watch?: WatcherOptions | false;
|
|
1924
|
+
/**
|
|
1925
|
+
* Controls which warnings are emitted during the build process. Each option can be set to `true` (emit warning) or `false` (suppress warning).
|
|
1926
|
+
*/
|
|
1602
1927
|
checks?: ChecksOptions;
|
|
1603
1928
|
makeAbsoluteExternalsRelative?: MakeAbsoluteExternalsRelative;
|
|
1604
|
-
|
|
1929
|
+
devtools?: {
|
|
1605
1930
|
sessionId?: string;
|
|
1606
1931
|
};
|
|
1932
|
+
/**
|
|
1933
|
+
* Controls how entry chunk exports are preserved. This determines whether Rolldown needs to create facade chunks (additional wrapper chunks) to maintain the exact export signatures of entry modules, or whether it can combine entry modules with other chunks for optimization.
|
|
1934
|
+
* @default 'strict'
|
|
1935
|
+
* {@include ./docs/preserve-entry-signatures.md}
|
|
1936
|
+
*/
|
|
1607
1937
|
preserveEntrySignatures?: false | "strict" | "allow-extension" | "exports-only";
|
|
1938
|
+
/**
|
|
1939
|
+
* Configure optimization features for the bundler.
|
|
1940
|
+
*/
|
|
1608
1941
|
optimization?: OptimizationOptions;
|
|
1942
|
+
/**
|
|
1943
|
+
* The value of `this` at the top level of each output chunk. For IIFE and UMD formats, this defaults to `'window'` or `'global'` depending on the platform.
|
|
1944
|
+
* @example
|
|
1945
|
+
* **Set custom context**
|
|
1946
|
+
* ```js
|
|
1947
|
+
* export default {
|
|
1948
|
+
* context: 'globalThis',
|
|
1949
|
+
* output: {
|
|
1950
|
+
* format: 'iife',
|
|
1951
|
+
* },
|
|
1952
|
+
* };
|
|
1953
|
+
* ```
|
|
1954
|
+
* **Use window for browser builds**
|
|
1955
|
+
* ```js
|
|
1956
|
+
* export default {
|
|
1957
|
+
* context: 'window',
|
|
1958
|
+
* platform: 'browser',
|
|
1959
|
+
* output: {
|
|
1960
|
+
* format: 'iife',
|
|
1961
|
+
* },
|
|
1962
|
+
* };
|
|
1963
|
+
* ```
|
|
1964
|
+
* {@include ./docs/context.md}
|
|
1965
|
+
*/
|
|
1609
1966
|
context?: string;
|
|
1610
1967
|
/**
|
|
1611
1968
|
* Configures TypeScript configuration file resolution and usage.
|
|
1612
|
-
*
|
|
1613
|
-
* ## Options
|
|
1614
|
-
*
|
|
1615
|
-
* - `true`: Auto-discovery mode (similar to Vite). For each module, both resolver and transformer
|
|
1616
|
-
* will find the nearest tsconfig.json. If the tsconfig has `references`, the file extension is
|
|
1617
|
-
* allowed, and the tsconfig's `include`/`exclude` patterns don't match the file, the referenced
|
|
1618
|
-
* tsconfigs will be searched for a match. Falls back to the original tsconfig if no match is found.
|
|
1619
|
-
* - `string`: Path to a specific tsconfig.json file (relative to cwd or absolute path).
|
|
1620
|
-
*
|
|
1621
|
-
* ## What's used from tsconfig
|
|
1622
|
-
*
|
|
1623
|
-
* - **Resolver**: Uses `compilerOptions.paths` and `compilerOptions.baseUrl` for path mapping
|
|
1624
|
-
* - **Transformer**: Uses select compiler options (jsx, decorators, typescript, etc.)
|
|
1625
|
-
*
|
|
1626
|
-
* > [!NOTE]
|
|
1627
|
-
* > Priority: Top-level `transform` options always take precedence over tsconfig settings.
|
|
1628
|
-
*
|
|
1969
|
+
* {@include ./docs/tsconfig.md}
|
|
1629
1970
|
* @default undefined (no tsconfig resolution)
|
|
1630
1971
|
*/
|
|
1631
1972
|
tsconfig?: true | string;
|
|
@@ -1648,4 +1989,4 @@ declare function defineConfig(config: RolldownOptions[]): RolldownOptions[];
|
|
|
1648
1989
|
declare function defineConfig(config: RolldownOptionsFunction): RolldownOptionsFunction;
|
|
1649
1990
|
declare function defineConfig(config: ConfigExport): ConfigExport;
|
|
1650
1991
|
//#endregion
|
|
1651
|
-
export { InternalModuleFormat as $, VERSION as A, GetModuleInfo as B, ResolveIdResult as C,
|
|
1992
|
+
export { InternalModuleFormat as $, VERSION as A, GetModuleInfo as B, ResolveIdResult as C, RenderedChunk as Ct, SourceDescription as D, freeExternalMemory as Dt, RolldownPluginOption as E, SourceMap as Et, TreeshakingOptions as F, PluginContextMeta as G, DefineParallelPluginResult as H, TransformPluginContext as I, ModuleTypeFilter as J, GeneralHookFilter as K, EmittedAsset as L, SourceMapInput as M, RolldownOptionsFunction as N, TransformResult as O, ModuleInfo as Ot, OutputBundle as P, RolldownFsModule as Q, EmittedFile as R, ResolveIdExtraOptions as S, OutputChunk as St, RolldownPlugin as T, RolldownOutput as Tt, defineParallelPlugin as U, PluginContext as V, MinimalPluginContext as W, RolldownDirectoryEntry as X, BufferEncoding as Y, RolldownFileStats as Z, ModuleType as _, MinifyOptions as _t, InputOption as a, RolldownWatcherEvent as at, PartialResolvedId as b, PreRenderedAsset as bt, OptimizationOptions as c, RolldownBuild as ct, CustomPluginOptions as d, AddonFunction as dt, NormalizedOutputOptions as et, FunctionPluginHooks as f, ChunkFileNamesFunction as ft, ModuleOptions as g, GlobalsFunction as gt, LoadResult as h, GeneratedCodePreset as ht, ExternalOption as i, RolldownWatcher as it, ExistingRawSourceMap as j, withFilter as k, SourcemapIgnoreListOption as kt, WatcherOptions as l, BuildOptions as lt, ImportKind as m, GeneratedCodeOptions as mt, ConfigExport as n, ChecksOptions as nt, InputOptions as o, WatchOptions as ot, HookFilterExtension as p, ChunkingContext as pt, HookFilter as q, RolldownOptions as r, watch as rt, ModuleTypes as s, rolldown as st, defineConfig as t, NormalizedInputOptions as tt, AsyncPluginHooks as u, build as ut, ObjectHook as v, ModuleFormat as vt, ResolvedId as w, RenderedModule as wt, Plugin as x, OutputAsset as xt, ParallelPluginHooks as y, OutputOptions as yt, EmittedPrebuiltChunk as z };
|