rolldown 1.0.0-beta.2-commit.5deb279 → 1.0.0-beta.21
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/bin/cli.mjs +2 -0
- package/dist/{cjs/cli.cjs → cli.cjs} +630 -603
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/{esm/cli.mjs → cli.mjs} +605 -575
- package/dist/config.cjs +12 -0
- package/dist/config.d.cts +10 -0
- package/dist/config.d.mts +10 -0
- package/dist/config.mjs +10 -0
- package/dist/experimental-index.cjs +107 -0
- package/dist/experimental-index.d.cts +63 -0
- package/dist/experimental-index.d.mts +63 -0
- package/dist/experimental-index.mjs +82 -0
- package/dist/experimental-runtime-types.d.ts +52 -0
- package/dist/filter-index.cjs +105 -0
- package/dist/filter-index.d.cts +4 -0
- package/dist/filter-index.d.mts +4 -0
- package/dist/filter-index.mjs +44 -0
- package/dist/index.cjs +9 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +5 -0
- package/dist/{cjs/parallel-plugin-worker.cjs → parallel-plugin-worker.cjs} +6 -14
- package/dist/parallel-plugin-worker.d.cts +1 -0
- package/dist/parallel-plugin-worker.d.mts +1 -0
- package/dist/{esm/parallel-plugin-worker.mjs → parallel-plugin-worker.mjs} +5 -12
- package/dist/{cjs/parallel-plugin.cjs → parallel-plugin.cjs} +1 -2
- package/dist/parallel-plugin.d.cts +14 -0
- package/dist/parallel-plugin.d.mts +14 -0
- package/dist/{esm/parallel-plugin.mjs → parallel-plugin.mjs} +0 -1
- package/dist/parse-ast-index.cjs +4 -0
- package/dist/parse-ast-index.d.cts +9 -0
- package/dist/parse-ast-index.d.mts +9 -0
- package/dist/parse-ast-index.mjs +3 -0
- package/dist/shared/binding--Ro_HG7S.d.mts +1246 -0
- package/dist/shared/binding-DBnJxycu.d.cts +1246 -0
- package/dist/shared/{chunk-qZFfknuJ.cjs → chunk-DDkG_k5U.cjs} +0 -1
- package/dist/shared/define-config-LuFmoc43.d.cts +1204 -0
- package/dist/shared/define-config-WLh0sQOM.d.mts +1204 -0
- package/dist/shared/load-config-DUa6Uqtc.mjs +119 -0
- package/dist/shared/load-config-juy1xxPU.cjs +125 -0
- package/dist/shared/misc-BKp5iIef.cjs +67 -0
- package/dist/shared/misc-BN0nse6C.mjs +25 -0
- package/dist/shared/parse-ast-index-CVVmsBjK.cjs +738 -0
- package/dist/shared/parse-ast-index-DW8kbzjr.mjs +616 -0
- package/dist/shared/{prompt-Nfm4Xz36.mjs → prompt-C5jz26Zn.mjs} +247 -246
- package/dist/shared/{prompt-B7tq3GL9.cjs → prompt-QNI93ne7.cjs} +250 -250
- package/dist/shared/src-LzfUVOSn.mjs +4647 -0
- package/dist/shared/src-ajsKFM6g.cjs +4851 -0
- package/package.json +65 -67
- package/bin/cli.js +0 -2
- package/dist/cjs/experimental-index.cjs +0 -79
- package/dist/cjs/index.cjs +0 -8
- package/dist/cjs/parse-ast-index.cjs +0 -57
- package/dist/esm/experimental-index.mjs +0 -56
- package/dist/esm/index.mjs +0 -4
- package/dist/esm/parse-ast-index.mjs +0 -55
- package/dist/shared/binding-l7VLSKnB.mjs +0 -610
- package/dist/shared/binding-orkvONpS.cjs +0 -661
- package/dist/shared/src-CV5Vk_cS.cjs +0 -2828
- package/dist/shared/src-CwOjWVUb.mjs +0 -2647
- package/dist/types/api/build.d.ts +0 -18
- package/dist/types/api/build.js +0 -22
- package/dist/types/api/experimental.d.ts +0 -7
- package/dist/types/api/experimental.js +0 -13
- package/dist/types/api/rolldown/index.d.ts +0 -3
- package/dist/types/api/rolldown/index.js +0 -7
- package/dist/types/api/rolldown/rolldown-build.d.ts +0 -12
- package/dist/types/api/rolldown/rolldown-build.js +0 -43
- package/dist/types/api/watch/index.d.ts +0 -3
- package/dist/types/api/watch/index.js +0 -8
- package/dist/types/api/watch/watch-emitter.d.ts +0 -31
- package/dist/types/api/watch/watch-emitter.js +0 -69
- package/dist/types/api/watch/watcher.d.ts +0 -13
- package/dist/types/api/watch/watcher.js +0 -66
- package/dist/types/binding.d.ts +0 -1327
- package/dist/types/builtin-plugin/alias-plugin.d.ts +0 -10
- package/dist/types/builtin-plugin/alias-plugin.js +0 -4
- package/dist/types/builtin-plugin/constructors.d.ts +0 -20
- package/dist/types/builtin-plugin/constructors.js +0 -68
- package/dist/types/builtin-plugin/replace-plugin.d.ts +0 -28
- package/dist/types/builtin-plugin/replace-plugin.js +0 -29
- package/dist/types/builtin-plugin/transform-plugin.d.ts +0 -9
- package/dist/types/builtin-plugin/transform-plugin.js +0 -16
- package/dist/types/builtin-plugin/utils.d.ts +0 -8
- package/dist/types/builtin-plugin/utils.js +0 -19
- package/dist/types/cli/arguments/alias.d.ts +0 -16
- package/dist/types/cli/arguments/alias.js +0 -63
- package/dist/types/cli/arguments/index.d.ts +0 -15
- package/dist/types/cli/arguments/index.js +0 -127
- package/dist/types/cli/arguments/normalize.d.ts +0 -12
- package/dist/types/cli/arguments/normalize.js +0 -48
- package/dist/types/cli/arguments/utils.d.ts +0 -8
- package/dist/types/cli/arguments/utils.js +0 -67
- package/dist/types/cli/colors.d.ts +0 -11
- package/dist/types/cli/colors.js +0 -17
- package/dist/types/cli/commands/bundle.d.ts +0 -3
- package/dist/types/cli/commands/bundle.js +0 -203
- package/dist/types/cli/commands/help.d.ts +0 -1
- package/dist/types/cli/commands/help.js +0 -88
- package/dist/types/cli/index.d.ts +0 -1
- package/dist/types/cli/index.js +0 -27
- package/dist/types/cli/load-config.d.ts +0 -3
- package/dist/types/cli/load-config.js +0 -95
- package/dist/types/cli/logger.d.ts +0 -5
- package/dist/types/cli/logger.js +0 -35
- package/dist/types/constants/plugin-context.d.ts +0 -7
- package/dist/types/constants/plugin-context.js +0 -7
- package/dist/types/constants/plugin.d.ts +0 -45
- package/dist/types/constants/plugin.js +0 -69
- package/dist/types/experimental-index.d.ts +0 -9
- package/dist/types/experimental-index.js +0 -9
- package/dist/types/index.d.ts +0 -28
- package/dist/types/index.js +0 -7
- package/dist/types/log/logHandler.d.ts +0 -4
- package/dist/types/log/logHandler.js +0 -25
- package/dist/types/log/logger.d.ts +0 -6
- package/dist/types/log/logger.js +0 -107
- package/dist/types/log/logging.d.ts +0 -11
- package/dist/types/log/logging.js +0 -11
- package/dist/types/log/logs.d.ts +0 -18
- package/dist/types/log/logs.js +0 -86
- package/dist/types/options/input-options.d.ts +0 -170
- package/dist/types/options/input-options.js +0 -1
- package/dist/types/options/normalized-input-options.d.ts +0 -18
- package/dist/types/options/normalized-input-options.js +0 -21
- package/dist/types/options/normalized-output-options.d.ts +0 -67
- package/dist/types/options/normalized-output-options.js +0 -99
- package/dist/types/options/output-options.d.ts +0 -86
- package/dist/types/options/output-options.js +0 -1
- package/dist/types/options/watch-options.d.ts +0 -5
- package/dist/types/options/watch-options.js +0 -1
- package/dist/types/parallel-plugin-worker.d.ts +0 -1
- package/dist/types/parallel-plugin-worker.js +0 -31
- package/dist/types/parallel-plugin.d.ts +0 -1
- package/dist/types/parallel-plugin.js +0 -1
- package/dist/types/parse-ast-index.d.ts +0 -4
- package/dist/types/parse-ast-index.js +0 -73
- package/dist/types/plugin/bindingify-build-hooks.d.ts +0 -10
- package/dist/types/plugin/bindingify-build-hooks.js +0 -213
- package/dist/types/plugin/bindingify-hook-filter.d.ts +0 -7
- package/dist/types/plugin/bindingify-hook-filter.js +0 -39
- package/dist/types/plugin/bindingify-output-hooks.d.ts +0 -14
- package/dist/types/plugin/bindingify-output-hooks.js +0 -189
- package/dist/types/plugin/bindingify-plugin-hook-meta.d.ts +0 -8
- package/dist/types/plugin/bindingify-plugin-hook-meta.js +0 -19
- package/dist/types/plugin/bindingify-plugin.d.ts +0 -15
- package/dist/types/plugin/bindingify-plugin.js +0 -124
- package/dist/types/plugin/bindingify-watch-hooks.d.ts +0 -5
- package/dist/types/plugin/bindingify-watch-hooks.js +0 -29
- package/dist/types/plugin/hook-filter.d.ts +0 -48
- package/dist/types/plugin/hook-filter.js +0 -1
- package/dist/types/plugin/index.d.ts +0 -126
- package/dist/types/plugin/index.js +0 -1
- package/dist/types/plugin/minimal-plugin-context.d.ts +0 -15
- package/dist/types/plugin/minimal-plugin-context.js +0 -25
- package/dist/types/plugin/parallel-plugin-implementation.d.ts +0 -10
- package/dist/types/plugin/parallel-plugin-implementation.js +0 -3
- package/dist/types/plugin/parallel-plugin.d.ts +0 -9
- package/dist/types/plugin/parallel-plugin.js +0 -6
- package/dist/types/plugin/plugin-context-data.d.ts +0 -16
- package/dist/types/plugin/plugin-context-data.js +0 -55
- package/dist/types/plugin/plugin-context.d.ts +0 -52
- package/dist/types/plugin/plugin-context.js +0 -108
- package/dist/types/plugin/plugin-driver.d.ts +0 -8
- package/dist/types/plugin/plugin-driver.js +0 -88
- package/dist/types/plugin/transform-plugin-context.d.ts +0 -17
- package/dist/types/plugin/transform-plugin-context.js +0 -37
- package/dist/types/types/assert.d.ts +0 -13
- package/dist/types/types/assert.js +0 -1
- package/dist/types/types/config-export.d.ts +0 -5
- package/dist/types/types/config-export.js +0 -1
- package/dist/types/types/misc.d.ts +0 -40
- package/dist/types/types/misc.js +0 -1
- package/dist/types/types/module-info.d.ts +0 -15
- package/dist/types/types/module-info.js +0 -1
- package/dist/types/types/module-side-effects.d.ts +0 -10
- package/dist/types/types/module-side-effects.js +0 -1
- package/dist/types/types/output-bundle.d.ts +0 -4
- package/dist/types/types/output-bundle.js +0 -1
- package/dist/types/types/rolldown-options.d.ts +0 -5
- package/dist/types/types/rolldown-options.js +0 -1
- package/dist/types/types/rolldown-output.d.ts +0 -63
- package/dist/types/types/rolldown-output.js +0 -1
- package/dist/types/types/schema.d.ts +0 -33
- package/dist/types/types/schema.js +0 -1
- package/dist/types/types/sourcemap.d.ts +0 -13
- package/dist/types/types/sourcemap.js +0 -16
- package/dist/types/types/utils.d.ts +0 -13
- package/dist/types/types/utils.js +0 -1
- package/dist/types/utils/asset-source.d.ts +0 -4
- package/dist/types/utils/asset-source.js +0 -8
- package/dist/types/utils/async-flatten.d.ts +0 -1
- package/dist/types/utils/async-flatten.js +0 -7
- package/dist/types/utils/bindingify-input-options.d.ts +0 -7
- package/dist/types/utils/bindingify-input-options.js +0 -225
- package/dist/types/utils/bindingify-output-options.d.ts +0 -3
- package/dist/types/utils/bindingify-output-options.js +0 -92
- package/dist/types/utils/code-frame.d.ts +0 -1
- package/dist/types/utils/code-frame.js +0 -46
- package/dist/types/utils/compose-js-plugins.d.ts +0 -2
- package/dist/types/utils/compose-js-plugins.js +0 -400
- package/dist/types/utils/create-bundler-option.d.ts +0 -11
- package/dist/types/utils/create-bundler-option.js +0 -53
- package/dist/types/utils/create-bundler.d.ts +0 -8
- package/dist/types/utils/create-bundler.js +0 -15
- package/dist/types/utils/define-config.d.ts +0 -5
- package/dist/types/utils/define-config.js +0 -3
- package/dist/types/utils/error.d.ts +0 -2
- package/dist/types/utils/error.js +0 -65
- package/dist/types/utils/initialize-parallel-plugins.d.ts +0 -19
- package/dist/types/utils/initialize-parallel-plugins.js +0 -54
- package/dist/types/utils/misc.d.ts +0 -6
- package/dist/types/utils/misc.js +0 -22
- package/dist/types/utils/normalize-hook.d.ts +0 -7
- package/dist/types/utils/normalize-hook.js +0 -21
- package/dist/types/utils/normalize-plugin-option.d.ts +0 -13
- package/dist/types/utils/normalize-plugin-option.js +0 -35
- package/dist/types/utils/normalize-string-or-regex.d.ts +0 -2
- package/dist/types/utils/normalize-string-or-regex.js +0 -14
- package/dist/types/utils/plugin/index.d.ts +0 -2
- package/dist/types/utils/plugin/index.js +0 -7
- package/dist/types/utils/transform-module-info.d.ts +0 -4
- package/dist/types/utils/transform-module-info.js +0 -19
- package/dist/types/utils/transform-rendered-chunk.d.ts +0 -4
- package/dist/types/utils/transform-rendered-chunk.js +0 -43
- package/dist/types/utils/transform-rendered-module.d.ts +0 -3
- package/dist/types/utils/transform-rendered-module.js +0 -10
- package/dist/types/utils/transform-side-effects.d.ts +0 -3
- package/dist/types/utils/transform-side-effects.js +0 -16
- package/dist/types/utils/transform-sourcemap.d.ts +0 -3
- package/dist/types/utils/transform-sourcemap.js +0 -29
- package/dist/types/utils/transform-to-rollup-output.d.ts +0 -11
- package/dist/types/utils/transform-to-rollup-output.js +0 -165
- package/dist/types/utils/validator.d.ts +0 -7
- package/dist/types/utils/validator.js +0 -275
|
@@ -0,0 +1,1204 @@
|
|
|
1
|
+
import { BindingAssetPluginConfig, BindingBuildImportAnalysisPluginConfig, BindingBuiltinPluginName, BindingBundlerImpl, BindingDynamicImportVarsPluginConfig, BindingHmrOutputPatch, BindingHookResolveIdExtraArgs, BindingImportGlobPluginConfig, BindingIsolatedDeclarationPluginConfig, BindingJsonPluginConfig, BindingManifestPluginConfig, BindingMfManifest, BindingMinifyOptions, BindingModuleFederationPluginOption, BindingModulePreloadPolyfillPluginConfig, BindingRemote, BindingRenderedChunk, BindingReporterPluginConfig, BindingTransformHookExtraArgs, BindingViteResolvePluginConfig, BindingWatcherEvent, ParserOptions, PreRenderedChunk, TransformOptions } from "./binding--Ro_HG7S.mjs";
|
|
2
|
+
import { TopLevelFilterExpression } from "@rolldown/pluginutils";
|
|
3
|
+
import { Program } from "@oxc-project/types";
|
|
4
|
+
|
|
5
|
+
//#region src/log/logging.d.ts
|
|
6
|
+
type LogLevel = "info" | "debug" | "warn";
|
|
7
|
+
type LogLevelOption = LogLevel | "silent";
|
|
8
|
+
type LogLevelWithError = LogLevel | "error";
|
|
9
|
+
interface RollupLog {
|
|
10
|
+
binding?: string;
|
|
11
|
+
cause?: unknown;
|
|
12
|
+
code?: string;
|
|
13
|
+
exporter?: string;
|
|
14
|
+
frame?: string;
|
|
15
|
+
hook?: string;
|
|
16
|
+
id?: string;
|
|
17
|
+
ids?: string[];
|
|
18
|
+
loc?: {
|
|
19
|
+
column: number;
|
|
20
|
+
file?: string;
|
|
21
|
+
line: number;
|
|
22
|
+
};
|
|
23
|
+
message: string;
|
|
24
|
+
meta?: any;
|
|
25
|
+
names?: string[];
|
|
26
|
+
plugin?: string;
|
|
27
|
+
pluginCode?: unknown;
|
|
28
|
+
pos?: number;
|
|
29
|
+
reexporter?: string;
|
|
30
|
+
stack?: string;
|
|
31
|
+
url?: string;
|
|
32
|
+
}
|
|
33
|
+
type RollupLogWithString = RollupLog | string;
|
|
34
|
+
interface RollupError extends RollupLog {
|
|
35
|
+
name?: string;
|
|
36
|
+
stack?: string;
|
|
37
|
+
watchFiles?: string[];
|
|
38
|
+
}
|
|
39
|
+
type LogOrStringHandler = (level: LogLevelWithError, log: RollupLogWithString) => void;
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/types/misc.d.ts
|
|
42
|
+
type SourcemapPathTransformOption = (relativeSourcePath: string, sourcemapPath: string) => string;
|
|
43
|
+
type SourcemapIgnoreListOption = (relativeSourcePath: string, sourcemapPath: string) => boolean;
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/utils/asset-source.d.ts
|
|
46
|
+
type AssetSource = string | Uint8Array;
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/types/rolldown-output.d.ts
|
|
49
|
+
interface OutputAsset {
|
|
50
|
+
type: "asset";
|
|
51
|
+
fileName: string;
|
|
52
|
+
/** @deprecated Use "originalFileNames" instead. */
|
|
53
|
+
originalFileName: string | null;
|
|
54
|
+
originalFileNames: string[];
|
|
55
|
+
source: AssetSource;
|
|
56
|
+
/** @deprecated Use "names" instead. */
|
|
57
|
+
name: string | undefined;
|
|
58
|
+
names: string[];
|
|
59
|
+
}
|
|
60
|
+
interface SourceMap {
|
|
61
|
+
file: string;
|
|
62
|
+
mappings: string;
|
|
63
|
+
names: string[];
|
|
64
|
+
sources: string[];
|
|
65
|
+
sourcesContent: string[];
|
|
66
|
+
version: number;
|
|
67
|
+
debugId?: string;
|
|
68
|
+
x_google_ignoreList?: number[];
|
|
69
|
+
toString(): string;
|
|
70
|
+
toUrl(): string;
|
|
71
|
+
}
|
|
72
|
+
interface RenderedModule {
|
|
73
|
+
readonly code: string | null;
|
|
74
|
+
renderedLength: number;
|
|
75
|
+
renderedExports: string[];
|
|
76
|
+
}
|
|
77
|
+
interface RenderedChunk extends Omit<BindingRenderedChunk, "modules"> {
|
|
78
|
+
type: "chunk";
|
|
79
|
+
modules: {
|
|
80
|
+
[id: string]: RenderedModule;
|
|
81
|
+
};
|
|
82
|
+
name: string;
|
|
83
|
+
isEntry: boolean;
|
|
84
|
+
isDynamicEntry: boolean;
|
|
85
|
+
facadeModuleId: string | null;
|
|
86
|
+
moduleIds: Array<string>;
|
|
87
|
+
exports: Array<string>;
|
|
88
|
+
fileName: string;
|
|
89
|
+
imports: Array<string>;
|
|
90
|
+
dynamicImports: Array<string>;
|
|
91
|
+
}
|
|
92
|
+
interface OutputChunk {
|
|
93
|
+
type: "chunk";
|
|
94
|
+
code: string;
|
|
95
|
+
name: string;
|
|
96
|
+
isEntry: boolean;
|
|
97
|
+
exports: string[];
|
|
98
|
+
fileName: string;
|
|
99
|
+
modules: {
|
|
100
|
+
[id: string]: RenderedModule;
|
|
101
|
+
};
|
|
102
|
+
imports: string[];
|
|
103
|
+
dynamicImports: string[];
|
|
104
|
+
facadeModuleId: string | null;
|
|
105
|
+
isDynamicEntry: boolean;
|
|
106
|
+
moduleIds: string[];
|
|
107
|
+
map: SourceMap | null;
|
|
108
|
+
sourcemapFileName: string | null;
|
|
109
|
+
preliminaryFileName: string;
|
|
110
|
+
}
|
|
111
|
+
interface RolldownOutput {
|
|
112
|
+
output: [OutputChunk, ...(OutputChunk | OutputAsset)[]];
|
|
113
|
+
}
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/types/utils.d.ts
|
|
116
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
117
|
+
type NullValue<T = void> = T | undefined | null | void;
|
|
118
|
+
type PartialNull<T> = { [P in keyof T]: T[P] | null };
|
|
119
|
+
type MakeAsync<Function_> = Function_ extends ((this: infer This, ...parameters: infer Arguments) => infer Return) ? (this: This, ...parameters: Arguments) => Return | Promise<Return> : never;
|
|
120
|
+
type MaybeArray<T> = T | T[];
|
|
121
|
+
type StringOrRegExp = string | RegExp;
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/options/output-options.d.ts
|
|
124
|
+
type ModuleFormat = "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | "umd";
|
|
125
|
+
type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
|
|
126
|
+
type ChunkFileNamesFunction = (chunkInfo: PreRenderedChunk) => string;
|
|
127
|
+
interface PreRenderedAsset {
|
|
128
|
+
names: string[];
|
|
129
|
+
originalFileNames: string[];
|
|
130
|
+
source: string | Uint8Array;
|
|
131
|
+
type: "asset";
|
|
132
|
+
}
|
|
133
|
+
type AssetFileNamesFunction = (chunkInfo: PreRenderedAsset) => string;
|
|
134
|
+
type GlobalsFunction = (name: string) => string;
|
|
135
|
+
type MinifyOptions = BindingMinifyOptions;
|
|
136
|
+
interface OutputOptions {
|
|
137
|
+
dir?: string;
|
|
138
|
+
file?: string;
|
|
139
|
+
exports?: "auto" | "named" | "default" | "none";
|
|
140
|
+
hashCharacters?: "base64" | "base36" | "hex";
|
|
141
|
+
/**
|
|
142
|
+
* Expected format of generated code.
|
|
143
|
+
* - `'es'`, `'esm'` and `'module'` are the same format, all stand for ES module.
|
|
144
|
+
* - `'cjs'` and `'commonjs'` are the same format, all stand for CommonJS module.
|
|
145
|
+
* - `'iife'` stands for [Immediately Invoked Function Expression](https://developer.mozilla.org/en-US/docs/Glossary/IIFE).
|
|
146
|
+
* - `'umd'` stands for [Universal Module Definition](https://github.com/umdjs/umd).
|
|
147
|
+
*
|
|
148
|
+
* @default 'esm'
|
|
149
|
+
*/
|
|
150
|
+
format?: ModuleFormat;
|
|
151
|
+
sourcemap?: boolean | "inline" | "hidden";
|
|
152
|
+
sourcemapDebugIds?: boolean;
|
|
153
|
+
sourcemapIgnoreList?: boolean | SourcemapIgnoreListOption;
|
|
154
|
+
sourcemapPathTransform?: SourcemapPathTransformOption;
|
|
155
|
+
banner?: string | AddonFunction;
|
|
156
|
+
footer?: string | AddonFunction;
|
|
157
|
+
intro?: string | AddonFunction;
|
|
158
|
+
outro?: string | AddonFunction;
|
|
159
|
+
extend?: boolean;
|
|
160
|
+
esModule?: boolean | "if-default-prop";
|
|
161
|
+
assetFileNames?: string | AssetFileNamesFunction;
|
|
162
|
+
entryFileNames?: string | ChunkFileNamesFunction;
|
|
163
|
+
chunkFileNames?: string | ChunkFileNamesFunction;
|
|
164
|
+
cssEntryFileNames?: string | ChunkFileNamesFunction;
|
|
165
|
+
cssChunkFileNames?: string | ChunkFileNamesFunction;
|
|
166
|
+
sanitizeFileName?: boolean | ((name: string) => string);
|
|
167
|
+
minify?: boolean | "dce-only" | MinifyOptions;
|
|
168
|
+
name?: string;
|
|
169
|
+
globals?: Record<string, string> | GlobalsFunction;
|
|
170
|
+
externalLiveBindings?: boolean;
|
|
171
|
+
inlineDynamicImports?: boolean;
|
|
172
|
+
/**
|
|
173
|
+
* - Type: `((moduleId: string) => string | NullValue)`
|
|
174
|
+
* - Object form is not supported.
|
|
175
|
+
*
|
|
176
|
+
* :::warning
|
|
177
|
+
* - This option is deprecated. Please use `advancedChunks` instead.
|
|
178
|
+
* - If `manualChunks` and `advancedChunks` are both specified, `manualChunks` option will be ignored.
|
|
179
|
+
* :::
|
|
180
|
+
*
|
|
181
|
+
* You could use this option for migration purpose. Under the hood,
|
|
182
|
+
*
|
|
183
|
+
* ```js
|
|
184
|
+
* {
|
|
185
|
+
* manualChunks: (moduleId, meta) => {
|
|
186
|
+
* if (moduleId.includes('node_modules')) {
|
|
187
|
+
* return 'vendor';
|
|
188
|
+
* }
|
|
189
|
+
* return null;
|
|
190
|
+
* }
|
|
191
|
+
* }
|
|
192
|
+
* ```
|
|
193
|
+
*
|
|
194
|
+
* will be transformed to
|
|
195
|
+
*
|
|
196
|
+
* ```js
|
|
197
|
+
* {
|
|
198
|
+
* advancedChunks: {
|
|
199
|
+
* groups: [
|
|
200
|
+
* {
|
|
201
|
+
* name(moduleId) {
|
|
202
|
+
* if (moduleId.includes('node_modules')) {
|
|
203
|
+
* return 'vendor';
|
|
204
|
+
* }
|
|
205
|
+
* return null;
|
|
206
|
+
* },
|
|
207
|
+
* },
|
|
208
|
+
* ],
|
|
209
|
+
* }
|
|
210
|
+
* }
|
|
211
|
+
*
|
|
212
|
+
* ```
|
|
213
|
+
*
|
|
214
|
+
* @deprecated Please use `advancedChunks` instead.
|
|
215
|
+
*/
|
|
216
|
+
manualChunks?: (moduleId: string, meta: {}) => string | NullValue;
|
|
217
|
+
/**
|
|
218
|
+
* Allows you to do manual chunking. For deeper understanding, please refer to the in-depth [documentation](https://rolldown.rs/guide/in-depth/advanced-chunks).
|
|
219
|
+
*/
|
|
220
|
+
advancedChunks?: {
|
|
221
|
+
/**
|
|
222
|
+
* - Type: `number`
|
|
223
|
+
*
|
|
224
|
+
* Global fallback of [`{group}.minSize`](#advancedchunks-groups-minsize), if it's not specified in the group.
|
|
225
|
+
*/
|
|
226
|
+
minSize?: number;
|
|
227
|
+
/**
|
|
228
|
+
* - Type: `number`
|
|
229
|
+
*
|
|
230
|
+
* Global fallback of [`{group}.maxSize`](#advancedchunks-groups-maxsize), if it's not specified in the group.
|
|
231
|
+
*/
|
|
232
|
+
maxSize?: number;
|
|
233
|
+
/**
|
|
234
|
+
* - Type: `number`
|
|
235
|
+
*
|
|
236
|
+
* Global fallback of [`{group}.maxModuleSize`](#advancedchunks-groups-maxmodulesize), if it's not specified in the group.
|
|
237
|
+
*/
|
|
238
|
+
maxModuleSize?: number;
|
|
239
|
+
/**
|
|
240
|
+
* - Type: `number`
|
|
241
|
+
*
|
|
242
|
+
* Global fallback of [`{group}.minModuleSize`](#advancedchunks-groups-minmodulesize), if it's not specified in the group.
|
|
243
|
+
*/
|
|
244
|
+
minModuleSize?: number;
|
|
245
|
+
/**
|
|
246
|
+
* - Type: `number`
|
|
247
|
+
*
|
|
248
|
+
* Global fallback of [`{group}.minShareCount`](#advancedchunks-groups-minsharecount), if it's not specified in the group.
|
|
249
|
+
*/
|
|
250
|
+
minShareCount?: number;
|
|
251
|
+
/**
|
|
252
|
+
* Groups to be used for advanced chunking.
|
|
253
|
+
*/
|
|
254
|
+
groups?: {
|
|
255
|
+
/**
|
|
256
|
+
* - Type: `string | ((moduleId: string) => string | NullValue)`
|
|
257
|
+
*
|
|
258
|
+
* Name of the group. It will be also used as the name of the chunk and replaced the `[name]` placeholder in the `chunkFileNames` option.
|
|
259
|
+
*
|
|
260
|
+
* For example,
|
|
261
|
+
*
|
|
262
|
+
* ```js
|
|
263
|
+
* import { defineConfig } from 'rolldown';
|
|
264
|
+
*
|
|
265
|
+
* export default defineConfig({
|
|
266
|
+
* advancedChunks: {
|
|
267
|
+
* groups: [
|
|
268
|
+
* {
|
|
269
|
+
* name: 'libs',
|
|
270
|
+
* test: /node_modules/,
|
|
271
|
+
* },
|
|
272
|
+
* ],
|
|
273
|
+
* },
|
|
274
|
+
* });
|
|
275
|
+
* ```
|
|
276
|
+
* will create a chunk named `libs-[hash].js` in the end.
|
|
277
|
+
*
|
|
278
|
+
* It's ok to have the same name for different groups. Rolldown will deduplicate the chunk names if necessary.
|
|
279
|
+
*
|
|
280
|
+
* # Dynamic `name()`
|
|
281
|
+
*
|
|
282
|
+
* If `name` is a function, it will be called with the module id as the argument. The function should return a string or `null`. If it returns `null`, the module will be ignored by this group.
|
|
283
|
+
*
|
|
284
|
+
* Notice, each returned new name will be treated as a separate group.
|
|
285
|
+
*
|
|
286
|
+
* For example,
|
|
287
|
+
*
|
|
288
|
+
* ```js
|
|
289
|
+
* import { defineConfig } from 'rolldown';
|
|
290
|
+
*
|
|
291
|
+
* export default defineConfig({
|
|
292
|
+
* advancedChunks: {
|
|
293
|
+
* groups: [
|
|
294
|
+
* {
|
|
295
|
+
* name: (moduleId) => moduleId.includes('node_modules') ? 'libs' : 'app',
|
|
296
|
+
* minSize: 100 * 1024,
|
|
297
|
+
* },
|
|
298
|
+
* ],
|
|
299
|
+
* },
|
|
300
|
+
* });
|
|
301
|
+
* ```
|
|
302
|
+
*
|
|
303
|
+
* :::warning
|
|
304
|
+
* Constraints like `minSize`, `maxSize`, etc. are applied separately for different names returned by the function.
|
|
305
|
+
* :::
|
|
306
|
+
*/
|
|
307
|
+
name: string | ((moduleId: string) => string | NullValue);
|
|
308
|
+
/**
|
|
309
|
+
* - Type: `string | RegExp | ((id: string) => boolean | undefined | void);`
|
|
310
|
+
*
|
|
311
|
+
* Controls which modules are captured in this group.
|
|
312
|
+
*
|
|
313
|
+
* - If `test` is a string, the module whose id contains the string will be captured.
|
|
314
|
+
* - If `test` is a regular expression, the module whose id matches the regular expression will be captured.
|
|
315
|
+
* - If `test` is a function, modules for which `test(id)` returns `true` will be captured.
|
|
316
|
+
* - If `test` is empty, any module will be considered as matched.
|
|
317
|
+
*
|
|
318
|
+
* :::warning
|
|
319
|
+
* When using regular expression, it's recommended to use `[\\/]` to match the path separator instead of `/` to avoid potential issues on Windows.
|
|
320
|
+
* - ✅ Recommended: `/node_modules[\\/]react/`
|
|
321
|
+
* - ❌ Not recommended: `/node_modules/react/`
|
|
322
|
+
* :::
|
|
323
|
+
*/
|
|
324
|
+
test?: StringOrRegExp | ((id: string) => boolean | undefined | void);
|
|
325
|
+
/**
|
|
326
|
+
* - Type: `number`
|
|
327
|
+
* - Default: `0`
|
|
328
|
+
*
|
|
329
|
+
* Priority of the group. Group with higher priority will be chosen first to match modules and create chunks. When converting the group to a chunk, modules of that group will be removed from other groups.
|
|
330
|
+
*
|
|
331
|
+
* If two groups have the same priority, the group whose index is smaller will be chosen.
|
|
332
|
+
*
|
|
333
|
+
* For example,
|
|
334
|
+
*
|
|
335
|
+
* ```js
|
|
336
|
+
* import { defineConfig } from 'rolldown';
|
|
337
|
+
*
|
|
338
|
+
* export default defineConfig({
|
|
339
|
+
* advancedChunks: {
|
|
340
|
+
* groups: [
|
|
341
|
+
* {
|
|
342
|
+
* name: 'react',
|
|
343
|
+
* test: /node_modules[\\/]react/,
|
|
344
|
+
* priority: 1,
|
|
345
|
+
* },
|
|
346
|
+
* {
|
|
347
|
+
* name: 'other-libs',
|
|
348
|
+
* test: /node_modules/,
|
|
349
|
+
* priority: 2,
|
|
350
|
+
* },
|
|
351
|
+
* ],
|
|
352
|
+
* });
|
|
353
|
+
* ```
|
|
354
|
+
*
|
|
355
|
+
* This is a clearly __incorrect__ example. Though `react` group is defined before `other-libs`, it has a lower priority, so the modules in `react` group will be captured in `other-libs` group.
|
|
356
|
+
*/
|
|
357
|
+
priority?: number;
|
|
358
|
+
/**
|
|
359
|
+
* - Type: `number`
|
|
360
|
+
* - Default: `0`
|
|
361
|
+
*
|
|
362
|
+
* Minimum size in bytes of the desired chunk. If the accumulated size of the captured modules by this group is smaller than this value, it will be ignored. Modules in this group will fall back to the `automatic chunking` if they are not captured by any other group.
|
|
363
|
+
*/
|
|
364
|
+
minSize?: number;
|
|
365
|
+
/**
|
|
366
|
+
* - Type: `number`
|
|
367
|
+
* - Default: `1`
|
|
368
|
+
*
|
|
369
|
+
* Controls if a module should be captured based on how many entry chunks reference it.
|
|
370
|
+
*/
|
|
371
|
+
minShareCount?: number;
|
|
372
|
+
/**
|
|
373
|
+
* - Type: `number`
|
|
374
|
+
* - Default: `Infinity`
|
|
375
|
+
*
|
|
376
|
+
* If the accumulated size in bytes of the captured modules by this group is larger than this value, this group will be split into multiple groups that each has size close to this value.
|
|
377
|
+
*/
|
|
378
|
+
maxSize?: number;
|
|
379
|
+
/**
|
|
380
|
+
* - Type: `number`
|
|
381
|
+
* - Default: `Infinity`
|
|
382
|
+
*
|
|
383
|
+
* Controls a module could only be captured if its size in bytes is smaller or equal than this value.
|
|
384
|
+
*/
|
|
385
|
+
maxModuleSize?: number;
|
|
386
|
+
/**
|
|
387
|
+
* - Type: `number`
|
|
388
|
+
* - Default: `0`
|
|
389
|
+
*
|
|
390
|
+
* Controls a module could only be captured if its size in bytes is larger or equal than this value.
|
|
391
|
+
*/
|
|
392
|
+
minModuleSize?: number;
|
|
393
|
+
}[];
|
|
394
|
+
};
|
|
395
|
+
/**
|
|
396
|
+
* Control comments in the output.
|
|
397
|
+
*
|
|
398
|
+
* - `none`: no comments
|
|
399
|
+
* - `inline`: preserve comments that contain `@license`, `@preserve` or starts with `//!` `/*!`
|
|
400
|
+
*/
|
|
401
|
+
legalComments?: "none" | "inline";
|
|
402
|
+
plugins?: RolldownOutputPluginOption;
|
|
403
|
+
polyfillRequire?: boolean;
|
|
404
|
+
hoistTransitiveImports?: false;
|
|
405
|
+
preserveModules?: boolean;
|
|
406
|
+
virtualDirname?: string;
|
|
407
|
+
preserveModulesRoot?: string;
|
|
408
|
+
}
|
|
409
|
+
//#endregion
|
|
410
|
+
//#region src/api/build.d.ts
|
|
411
|
+
interface BuildOptions extends InputOptions {
|
|
412
|
+
/**
|
|
413
|
+
* Write the output to the file system
|
|
414
|
+
*
|
|
415
|
+
* @default true
|
|
416
|
+
*/
|
|
417
|
+
write?: boolean;
|
|
418
|
+
output?: OutputOptions;
|
|
419
|
+
}
|
|
420
|
+
declare function build(options: BuildOptions): Promise<RolldownOutput>;
|
|
421
|
+
/**
|
|
422
|
+
* Build multiple outputs __sequentially__.
|
|
423
|
+
*/
|
|
424
|
+
declare function build(options: BuildOptions[]): Promise<RolldownOutput[]>;
|
|
425
|
+
//#endregion
|
|
426
|
+
//#region src/api/rolldown/rolldown-build.d.ts
|
|
427
|
+
declare class RolldownBuild {
|
|
428
|
+
#private;
|
|
429
|
+
constructor(inputOptions: InputOptions);
|
|
430
|
+
get closed(): boolean;
|
|
431
|
+
generate(outputOptions?: OutputOptions): Promise<RolldownOutput>;
|
|
432
|
+
write(outputOptions?: OutputOptions): Promise<RolldownOutput>;
|
|
433
|
+
close(): Promise<void>;
|
|
434
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
435
|
+
generateHmrPatch(changedFiles: string[]): Promise<BindingHmrOutputPatch>;
|
|
436
|
+
hmrInvalidate(file: string, firstInvalidatedBy?: string): Promise<BindingHmrOutputPatch>;
|
|
437
|
+
// TODO(underfin)
|
|
438
|
+
// The `watchFiles` method returns a promise, but Rollup does not.
|
|
439
|
+
// Converting it to a synchronous API might cause a deadlock if the user calls `write` and `watchFiles` simultaneously.
|
|
440
|
+
get watchFiles(): Promise<string[]>;
|
|
441
|
+
}
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region src/api/rolldown/index.d.ts
|
|
444
|
+
// `async` here is intentional to be compatible with `rollup.rollup`.
|
|
445
|
+
declare const rolldown: (input: InputOptions) => Promise<RolldownBuild>;
|
|
446
|
+
//#endregion
|
|
447
|
+
//#region src/options/watch-options.d.ts
|
|
448
|
+
interface WatchOptions extends InputOptions {
|
|
449
|
+
output?: OutputOptions | OutputOptions[];
|
|
450
|
+
}
|
|
451
|
+
//#endregion
|
|
452
|
+
//#region src/api/watch/watch-emitter.d.ts
|
|
453
|
+
type WatcherEvent = "close" | "event" | "restart" | "change";
|
|
454
|
+
type ChangeEvent$1 = "create" | "update" | "delete";
|
|
455
|
+
// TODO: find a way use `RolldownBuild` instead of `Bundler`.
|
|
456
|
+
type RolldownWatchBuild = BindingBundlerImpl;
|
|
457
|
+
type RolldownWatcherEvent = {
|
|
458
|
+
code: "START";
|
|
459
|
+
} | {
|
|
460
|
+
code: "BUNDLE_START";
|
|
461
|
+
} | {
|
|
462
|
+
code: "BUNDLE_END";
|
|
463
|
+
duration: number;
|
|
464
|
+
// input?: InputOption
|
|
465
|
+
output: readonly string[];
|
|
466
|
+
result: RolldownWatchBuild;
|
|
467
|
+
} | {
|
|
468
|
+
code: "END";
|
|
469
|
+
} | {
|
|
470
|
+
code: "ERROR";
|
|
471
|
+
error: Error;
|
|
472
|
+
result: RolldownWatchBuild;
|
|
473
|
+
};
|
|
474
|
+
declare class WatcherEmitter {
|
|
475
|
+
listeners: Map<WatcherEvent, Array<(...parameters: any[]) => MaybePromise<void>>>;
|
|
476
|
+
timer: any;
|
|
477
|
+
constructor();
|
|
478
|
+
on(event: "change", listener: (id: string, change: {
|
|
479
|
+
event: ChangeEvent$1;
|
|
480
|
+
}) => MaybePromise<void>): this;
|
|
481
|
+
on(event: "event", listener: (data: RolldownWatcherEvent) => MaybePromise<void>): this;
|
|
482
|
+
on(event: "restart" | "close", listener: () => MaybePromise<void>): this;
|
|
483
|
+
off(event: WatcherEvent, listener: (...parameters: any[]) => MaybePromise<void>): this;
|
|
484
|
+
onEvent(event: BindingWatcherEvent): Promise<void>;
|
|
485
|
+
close(): Promise<void>;
|
|
486
|
+
}
|
|
487
|
+
type RolldownWatcher = WatcherEmitter;
|
|
488
|
+
//#endregion
|
|
489
|
+
//#region src/api/watch/index.d.ts
|
|
490
|
+
// Compat to `rollup.watch`
|
|
491
|
+
declare const watch: (input: WatchOptions | WatchOptions[]) => RolldownWatcher;
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region src/log/log-handler.d.ts
|
|
494
|
+
type LoggingFunction = (log: RollupLog | string | (() => RollupLog | string)) => void;
|
|
495
|
+
type LoggingFunctionWithPosition = (log: RollupLog | string | (() => RollupLog | string), pos?: number | {
|
|
496
|
+
column: number;
|
|
497
|
+
line: number;
|
|
498
|
+
}) => void;
|
|
499
|
+
type WarningHandlerWithDefault = (warning: RollupLog, defaultHandler: LoggingFunction) => void;
|
|
500
|
+
//#endregion
|
|
501
|
+
//#region src/options/normalized-input-options.d.ts
|
|
502
|
+
interface NormalizedInputOptions {
|
|
503
|
+
input: string[] | Record<string, string>;
|
|
504
|
+
cwd: string | undefined;
|
|
505
|
+
platform: InputOptions["platform"];
|
|
506
|
+
shimMissingExports: boolean;
|
|
507
|
+
}
|
|
508
|
+
// TODO: I guess we make these getters enumerable so it act more like a plain object
|
|
509
|
+
//#endregion
|
|
510
|
+
//#region src/options/normalized-output-options.d.ts
|
|
511
|
+
type InternalModuleFormat = "es" | "cjs" | "iife" | "umd";
|
|
512
|
+
interface NormalizedOutputOptions {
|
|
513
|
+
name: string | undefined;
|
|
514
|
+
file: string | undefined;
|
|
515
|
+
dir: string | undefined;
|
|
516
|
+
entryFileNames: string | ChunkFileNamesFunction;
|
|
517
|
+
chunkFileNames: string | ChunkFileNamesFunction;
|
|
518
|
+
assetFileNames: string | AssetFileNamesFunction;
|
|
519
|
+
format: InternalModuleFormat;
|
|
520
|
+
exports: NonNullable<OutputOptions["exports"]>;
|
|
521
|
+
sourcemap: boolean | "inline" | "hidden";
|
|
522
|
+
cssEntryFileNames: string | ChunkFileNamesFunction;
|
|
523
|
+
cssChunkFileNames: string | ChunkFileNamesFunction;
|
|
524
|
+
inlineDynamicImports: boolean;
|
|
525
|
+
externalLiveBindings: boolean;
|
|
526
|
+
banner: AddonFunction;
|
|
527
|
+
footer: AddonFunction;
|
|
528
|
+
intro: AddonFunction;
|
|
529
|
+
outro: AddonFunction;
|
|
530
|
+
esModule: boolean | "if-default-prop";
|
|
531
|
+
extend: boolean;
|
|
532
|
+
globals: Record<string, string> | GlobalsFunction;
|
|
533
|
+
hashCharacters: "base64" | "base36" | "hex";
|
|
534
|
+
sourcemapDebugIds: boolean;
|
|
535
|
+
sourcemapIgnoreList: SourcemapIgnoreListOption;
|
|
536
|
+
sourcemapPathTransform: SourcemapPathTransformOption | undefined;
|
|
537
|
+
minify: false | BindingMinifyOptions;
|
|
538
|
+
legalComments: "none" | "inline";
|
|
539
|
+
polyfillRequire: boolean;
|
|
540
|
+
plugins: RolldownPlugin[];
|
|
541
|
+
preserveModules: boolean;
|
|
542
|
+
virtualDirname: string;
|
|
543
|
+
preserveModulesRoot?: string;
|
|
544
|
+
}
|
|
545
|
+
// TODO: I guess we make these getters enumerable so it act more like a plain object
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region src/plugin/hook-filter.d.ts
|
|
548
|
+
type GeneralHookFilter<Value = StringOrRegExp> = MaybeArray<Value> | {
|
|
549
|
+
include?: MaybeArray<Value>;
|
|
550
|
+
exclude?: MaybeArray<Value>;
|
|
551
|
+
};
|
|
552
|
+
interface FormalModuleTypeFilter {
|
|
553
|
+
include?: ModuleType[];
|
|
554
|
+
}
|
|
555
|
+
type ModuleTypeFilter = ModuleType[] | FormalModuleTypeFilter;
|
|
556
|
+
interface HookFilter {
|
|
557
|
+
/**
|
|
558
|
+
* This filter is used to do a pre-test to determine whether the hook should be called.
|
|
559
|
+
*
|
|
560
|
+
* @example
|
|
561
|
+
* Include all `id`s that contain `node_modules` in the path.
|
|
562
|
+
* ```js
|
|
563
|
+
* { id: '**'+'/node_modules/**' }
|
|
564
|
+
* ```
|
|
565
|
+
* @example
|
|
566
|
+
* Include all `id`s that contain `node_modules` or `src` in the path.
|
|
567
|
+
* ```js
|
|
568
|
+
* { id: ['**'+'/node_modules/**', '**'+'/src/**'] }
|
|
569
|
+
* ```
|
|
570
|
+
* @example
|
|
571
|
+
* Include all `id`s that start with `http`
|
|
572
|
+
* ```js
|
|
573
|
+
* { id: /^http/ }
|
|
574
|
+
* ```
|
|
575
|
+
* @example
|
|
576
|
+
* Exclude all `id`s that contain `node_modules` in the path.
|
|
577
|
+
* ```js
|
|
578
|
+
* { id: { exclude: '**'+'/node_modules/**' } }
|
|
579
|
+
* ```
|
|
580
|
+
* @example
|
|
581
|
+
* Formal pattern to define includes and excludes.
|
|
582
|
+
* ```
|
|
583
|
+
* { id : {
|
|
584
|
+
* include: ['**'+'/foo/**', /bar/],
|
|
585
|
+
* exclude: ['**'+'/baz/**', /qux/]
|
|
586
|
+
* }}
|
|
587
|
+
* ```
|
|
588
|
+
*/
|
|
589
|
+
id?: GeneralHookFilter;
|
|
590
|
+
moduleType?: ModuleTypeFilter;
|
|
591
|
+
code?: GeneralHookFilter;
|
|
592
|
+
}
|
|
593
|
+
type TUnionWithTopLevelFilterExpressionArray<T> = T | TopLevelFilterExpression[];
|
|
594
|
+
//#endregion
|
|
595
|
+
//#region src/plugin/minimal-plugin-context.d.ts
|
|
596
|
+
interface PluginContextMeta {
|
|
597
|
+
rollupVersion: string;
|
|
598
|
+
rolldownVersion: string;
|
|
599
|
+
watchMode: boolean;
|
|
600
|
+
}
|
|
601
|
+
interface MinimalPluginContext {
|
|
602
|
+
readonly pluginName: string;
|
|
603
|
+
error: (e: RollupError | string) => never;
|
|
604
|
+
info: LoggingFunction;
|
|
605
|
+
warn: LoggingFunction;
|
|
606
|
+
debug: LoggingFunction;
|
|
607
|
+
meta: PluginContextMeta;
|
|
608
|
+
}
|
|
609
|
+
//#endregion
|
|
610
|
+
//#region src/plugin/parallel-plugin.d.ts
|
|
611
|
+
type ParallelPlugin = {
|
|
612
|
+
/** @internal */
|
|
613
|
+
_parallel: {
|
|
614
|
+
fileUrl: string;
|
|
615
|
+
options: unknown;
|
|
616
|
+
};
|
|
617
|
+
};
|
|
618
|
+
type DefineParallelPluginResult<Options> = (options: Options) => ParallelPlugin;
|
|
619
|
+
declare function defineParallelPlugin<Options>(pluginPath: string): DefineParallelPluginResult<Options>;
|
|
620
|
+
//#endregion
|
|
621
|
+
//#region src/types/module-info.d.ts
|
|
622
|
+
interface ModuleInfo extends ModuleOptions {
|
|
623
|
+
/**
|
|
624
|
+
* Unsupported at rolldown
|
|
625
|
+
*/
|
|
626
|
+
ast: any;
|
|
627
|
+
code: string | null;
|
|
628
|
+
id: string;
|
|
629
|
+
importers: string[];
|
|
630
|
+
dynamicImporters: string[];
|
|
631
|
+
importedIds: string[];
|
|
632
|
+
dynamicallyImportedIds: string[];
|
|
633
|
+
exports: string[];
|
|
634
|
+
isEntry: boolean;
|
|
635
|
+
}
|
|
636
|
+
//#endregion
|
|
637
|
+
//#region src/plugin/plugin-context.d.ts
|
|
638
|
+
interface EmittedAsset {
|
|
639
|
+
type: "asset";
|
|
640
|
+
name?: string;
|
|
641
|
+
fileName?: string;
|
|
642
|
+
originalFileName?: string | null;
|
|
643
|
+
source: AssetSource;
|
|
644
|
+
}
|
|
645
|
+
interface EmittedChunk {
|
|
646
|
+
type: "chunk";
|
|
647
|
+
name?: string;
|
|
648
|
+
fileName?: string;
|
|
649
|
+
preserveSignature?: "strict" | "allow-extension" | "exports-only" | false;
|
|
650
|
+
id: string;
|
|
651
|
+
importer?: string;
|
|
652
|
+
}
|
|
653
|
+
type EmittedFile = EmittedAsset | EmittedChunk;
|
|
654
|
+
interface PluginContextResolveOptions {
|
|
655
|
+
skipSelf?: boolean;
|
|
656
|
+
custom?: CustomPluginOptions;
|
|
657
|
+
}
|
|
658
|
+
type GetModuleInfo = (moduleId: string) => ModuleInfo | null;
|
|
659
|
+
interface PluginContext extends MinimalPluginContext {
|
|
660
|
+
emitFile(file: EmittedFile): string;
|
|
661
|
+
getFileName(referenceId: string): string;
|
|
662
|
+
getModuleIds(): IterableIterator<string>;
|
|
663
|
+
getModuleInfo: GetModuleInfo;
|
|
664
|
+
addWatchFile(id: string): void;
|
|
665
|
+
load(options: {
|
|
666
|
+
id: string;
|
|
667
|
+
resolveDependencies?: boolean;
|
|
668
|
+
} & Partial<PartialNull<ModuleOptions>>): Promise<ModuleInfo>;
|
|
669
|
+
parse(input: string, options?: ParserOptions | undefined | null): Program;
|
|
670
|
+
resolve(source: string, importer?: string, options?: PluginContextResolveOptions): Promise<ResolvedId | null>;
|
|
671
|
+
}
|
|
672
|
+
//#endregion
|
|
673
|
+
//#region src/plugin/transform-plugin-context.d.ts
|
|
674
|
+
interface TransformPluginContext extends PluginContext {
|
|
675
|
+
debug: LoggingFunctionWithPosition;
|
|
676
|
+
info: LoggingFunctionWithPosition;
|
|
677
|
+
warn: LoggingFunctionWithPosition;
|
|
678
|
+
error(e: RollupError | string, pos?: number | {
|
|
679
|
+
column: number;
|
|
680
|
+
line: number;
|
|
681
|
+
}): never;
|
|
682
|
+
getCombinedSourcemap(): SourceMap;
|
|
683
|
+
}
|
|
684
|
+
//#endregion
|
|
685
|
+
//#region src/types/module-side-effects.d.ts
|
|
686
|
+
interface ModuleSideEffectsRule {
|
|
687
|
+
test?: RegExp;
|
|
688
|
+
external?: boolean;
|
|
689
|
+
sideEffects: boolean;
|
|
690
|
+
}
|
|
691
|
+
type ModuleSideEffectsOption = boolean | ModuleSideEffectsRule[] | ((id: string, isResolved: boolean) => boolean | undefined) | "no-external";
|
|
692
|
+
type TreeshakingOptions = {
|
|
693
|
+
moduleSideEffects?: ModuleSideEffectsOption;
|
|
694
|
+
annotations?: boolean;
|
|
695
|
+
manualPureFunctions?: string[];
|
|
696
|
+
unknownGlobalSideEffects?: boolean;
|
|
697
|
+
} | boolean;
|
|
698
|
+
//#endregion
|
|
699
|
+
//#region src/types/output-bundle.d.ts
|
|
700
|
+
interface OutputBundle {
|
|
701
|
+
[fileName: string]: OutputAsset | OutputChunk;
|
|
702
|
+
}
|
|
703
|
+
//#endregion
|
|
704
|
+
//#region src/types/sourcemap.d.ts
|
|
705
|
+
interface ExistingRawSourceMap {
|
|
706
|
+
file?: string | null;
|
|
707
|
+
mappings: string;
|
|
708
|
+
names?: string[];
|
|
709
|
+
sources?: (string | null)[];
|
|
710
|
+
sourcesContent?: (string | null)[];
|
|
711
|
+
sourceRoot?: string;
|
|
712
|
+
version?: number;
|
|
713
|
+
x_google_ignoreList?: number[];
|
|
714
|
+
}
|
|
715
|
+
type SourceMapInput = ExistingRawSourceMap | string | null;
|
|
716
|
+
//#endregion
|
|
717
|
+
//#region src/index.d.ts
|
|
718
|
+
declare const VERSION: string;
|
|
719
|
+
//#endregion
|
|
720
|
+
//#region src/builtin-plugin/constructors.d.ts
|
|
721
|
+
declare class BuiltinPlugin {
|
|
722
|
+
name: BindingBuiltinPluginName;
|
|
723
|
+
// NOTE: has `_` to avoid conflict with `options` hook
|
|
724
|
+
_options?: unknown;
|
|
725
|
+
constructor(name: BindingBuiltinPluginName, _options?: unknown);
|
|
726
|
+
}
|
|
727
|
+
declare function modulePreloadPolyfillPlugin(config?: BindingModulePreloadPolyfillPluginConfig): BuiltinPlugin;
|
|
728
|
+
declare function dynamicImportVarsPlugin(config?: BindingDynamicImportVarsPluginConfig): BuiltinPlugin;
|
|
729
|
+
declare function importGlobPlugin(config?: BindingImportGlobPluginConfig): BuiltinPlugin;
|
|
730
|
+
declare function reporterPlugin(config?: BindingReporterPluginConfig): BuiltinPlugin;
|
|
731
|
+
declare function manifestPlugin(config?: BindingManifestPluginConfig): BuiltinPlugin;
|
|
732
|
+
declare function wasmHelperPlugin(): BuiltinPlugin;
|
|
733
|
+
declare function wasmFallbackPlugin(): BuiltinPlugin;
|
|
734
|
+
declare function loadFallbackPlugin(): BuiltinPlugin;
|
|
735
|
+
declare function jsonPlugin(config?: BindingJsonPluginConfig): BuiltinPlugin;
|
|
736
|
+
declare function buildImportAnalysisPlugin(config: BindingBuildImportAnalysisPluginConfig): BuiltinPlugin;
|
|
737
|
+
declare function viteResolvePlugin(config: BindingViteResolvePluginConfig): BuiltinPlugin;
|
|
738
|
+
type ModuleFederationPluginOption = Omit<BindingModuleFederationPluginOption, "remotes"> & {
|
|
739
|
+
remotes?: Record<string, string | BindingRemote>;
|
|
740
|
+
manifest?: boolean | BindingMfManifest;
|
|
741
|
+
};
|
|
742
|
+
declare function moduleFederationPlugin(config: ModuleFederationPluginOption): BuiltinPlugin;
|
|
743
|
+
declare function isolatedDeclarationPlugin(config?: BindingIsolatedDeclarationPluginConfig): BuiltinPlugin;
|
|
744
|
+
declare function assetPlugin(config?: BindingAssetPluginConfig): BuiltinPlugin;
|
|
745
|
+
declare function webWorkerPostPlugin(): BuiltinPlugin;
|
|
746
|
+
//#endregion
|
|
747
|
+
//#region src/constants/plugin.d.ts
|
|
748
|
+
declare const ENUMERATED_INPUT_PLUGIN_HOOK_NAMES: readonly ["options", "buildStart", "resolveId", "load", "transform", "moduleParsed", "buildEnd", "onLog", "resolveDynamicImport", "closeBundle", "closeWatcher", "watchChange"];
|
|
749
|
+
declare const ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES: readonly ["augmentChunkHash", "outputOptions", "renderChunk", "renderStart", "renderError", "writeBundle", "generateBundle"];
|
|
750
|
+
declare const ENUMERATED_PLUGIN_HOOK_NAMES: [...typeof ENUMERATED_INPUT_PLUGIN_HOOK_NAMES, ...typeof ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES, "footer", "banner", "intro", "outro"];
|
|
751
|
+
type EnumeratedPluginHookNames = typeof ENUMERATED_PLUGIN_HOOK_NAMES;
|
|
752
|
+
/**
|
|
753
|
+
* Names of all hooks in a `Plugin` object. Does not include `name` and `api`, since they are not hooks.
|
|
754
|
+
*/
|
|
755
|
+
type PluginHookNames = EnumeratedPluginHookNames[number];
|
|
756
|
+
/**
|
|
757
|
+
* Names of all defined hooks. It's like
|
|
758
|
+
* ```ts
|
|
759
|
+
* type DefinedHookNames = {
|
|
760
|
+
* options: 'options',
|
|
761
|
+
* buildStart: 'buildStart',
|
|
762
|
+
* ...
|
|
763
|
+
* }
|
|
764
|
+
* ```
|
|
765
|
+
*/
|
|
766
|
+
type DefinedHookNames = { readonly [K in PluginHookNames]: K };
|
|
767
|
+
/**
|
|
768
|
+
* Names of all defined hooks. It's like
|
|
769
|
+
* ```js
|
|
770
|
+
* const DEFINED_HOOK_NAMES ={
|
|
771
|
+
* options: 'options',
|
|
772
|
+
* buildStart: 'buildStart',
|
|
773
|
+
* ...
|
|
774
|
+
* }
|
|
775
|
+
* ```
|
|
776
|
+
*/
|
|
777
|
+
declare const DEFINED_HOOK_NAMES: DefinedHookNames;
|
|
778
|
+
//#endregion
|
|
779
|
+
//#region src/plugin/with-filter.d.ts
|
|
780
|
+
type OverrideFilterObject = {
|
|
781
|
+
transform?: HookFilterExtension<"transform">["filter"];
|
|
782
|
+
resolveId?: HookFilterExtension<"resolveId">["filter"];
|
|
783
|
+
load?: HookFilterExtension<"load">["filter"];
|
|
784
|
+
pluginNamePattern?: StringOrRegExp[];
|
|
785
|
+
};
|
|
786
|
+
declare function withFilter<A, T extends RolldownPluginOption<A>>(pluginOption: T, filterObject: OverrideFilterObject | OverrideFilterObject[]): T;
|
|
787
|
+
//#endregion
|
|
788
|
+
//#region src/plugin/index.d.ts
|
|
789
|
+
type ModuleSideEffects = boolean | "no-treeshake" | null;
|
|
790
|
+
// ref: https://github.com/microsoft/TypeScript/issues/33471#issuecomment-1376364329
|
|
791
|
+
type ModuleType = "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | (string & {});
|
|
792
|
+
type ImportKind = BindingHookResolveIdExtraArgs["kind"];
|
|
793
|
+
interface CustomPluginOptions {
|
|
794
|
+
[plugin: string]: any;
|
|
795
|
+
}
|
|
796
|
+
interface ModuleOptions {
|
|
797
|
+
moduleSideEffects: ModuleSideEffects;
|
|
798
|
+
meta: CustomPluginOptions;
|
|
799
|
+
// flag used to check if user directly modified the `ModuleInfo`
|
|
800
|
+
// this is used to sync state between rust and js
|
|
801
|
+
invalidate?: boolean;
|
|
802
|
+
}
|
|
803
|
+
interface ResolvedId extends ModuleOptions {
|
|
804
|
+
external: boolean | "absolute";
|
|
805
|
+
id: string;
|
|
806
|
+
}
|
|
807
|
+
interface PartialResolvedId extends Partial<PartialNull<ModuleOptions>> {
|
|
808
|
+
external?: boolean | "absolute" | "relative";
|
|
809
|
+
id: string;
|
|
810
|
+
}
|
|
811
|
+
interface SourceDescription extends Partial<PartialNull<ModuleOptions>> {
|
|
812
|
+
code: string;
|
|
813
|
+
map?: SourceMapInput;
|
|
814
|
+
moduleType?: ModuleType;
|
|
815
|
+
}
|
|
816
|
+
interface ResolveIdExtraOptions {
|
|
817
|
+
custom?: CustomPluginOptions;
|
|
818
|
+
isEntry: boolean;
|
|
819
|
+
kind: BindingHookResolveIdExtraArgs["kind"];
|
|
820
|
+
}
|
|
821
|
+
type ResolveIdResult = string | NullValue | false | PartialResolvedId;
|
|
822
|
+
type LoadResult = NullValue | string | SourceDescription;
|
|
823
|
+
type TransformResult = NullValue | string | Partial<SourceDescription>;
|
|
824
|
+
type RenderedChunkMeta = {
|
|
825
|
+
chunks: Record<string, RenderedChunk>;
|
|
826
|
+
};
|
|
827
|
+
interface FunctionPluginHooks {
|
|
828
|
+
[DEFINED_HOOK_NAMES.onLog]: (this: MinimalPluginContext, level: LogLevel, log: RollupLog) => NullValue | boolean;
|
|
829
|
+
[DEFINED_HOOK_NAMES.options]: (this: MinimalPluginContext, options: InputOptions) => NullValue | InputOptions;
|
|
830
|
+
// TODO find a way to make `this: PluginContext` work.
|
|
831
|
+
[DEFINED_HOOK_NAMES.outputOptions]: (this: MinimalPluginContext, options: OutputOptions) => NullValue | OutputOptions;
|
|
832
|
+
// --- Build hooks ---
|
|
833
|
+
[DEFINED_HOOK_NAMES.buildStart]: (this: PluginContext, options: NormalizedInputOptions) => void;
|
|
834
|
+
[DEFINED_HOOK_NAMES.resolveId]: (this: PluginContext, source: string, importer: string | undefined, extraOptions: ResolveIdExtraOptions) => ResolveIdResult;
|
|
835
|
+
/**
|
|
836
|
+
* @deprecated
|
|
837
|
+
* This hook is only for rollup plugin compatibility. Please use `resolveId` instead.
|
|
838
|
+
*/
|
|
839
|
+
[DEFINED_HOOK_NAMES.resolveDynamicImport]: (this: PluginContext, source: string, importer: string | undefined) => ResolveIdResult;
|
|
840
|
+
[DEFINED_HOOK_NAMES.load]: (this: PluginContext, id: string) => MaybePromise<LoadResult>;
|
|
841
|
+
[DEFINED_HOOK_NAMES.transform]: (this: TransformPluginContext, code: string, id: string, meta: BindingTransformHookExtraArgs & {
|
|
842
|
+
moduleType: ModuleType;
|
|
843
|
+
}) => TransformResult;
|
|
844
|
+
[DEFINED_HOOK_NAMES.moduleParsed]: (this: PluginContext, moduleInfo: ModuleInfo) => void;
|
|
845
|
+
[DEFINED_HOOK_NAMES.buildEnd]: (this: PluginContext, err?: Error) => void;
|
|
846
|
+
// --- Generate hooks ---
|
|
847
|
+
[DEFINED_HOOK_NAMES.renderStart]: (this: PluginContext, outputOptions: NormalizedOutputOptions, inputOptions: NormalizedInputOptions) => void;
|
|
848
|
+
[DEFINED_HOOK_NAMES.renderChunk]: (this: PluginContext, code: string, chunk: RenderedChunk, outputOptions: NormalizedOutputOptions, meta: RenderedChunkMeta) => NullValue | string | {
|
|
849
|
+
code: string;
|
|
850
|
+
map?: SourceMapInput;
|
|
851
|
+
};
|
|
852
|
+
[DEFINED_HOOK_NAMES.augmentChunkHash]: (this: PluginContext, chunk: RenderedChunk) => string | void;
|
|
853
|
+
[DEFINED_HOOK_NAMES.renderError]: (this: PluginContext, error: Error) => void;
|
|
854
|
+
[DEFINED_HOOK_NAMES.generateBundle]: (this: PluginContext, outputOptions: NormalizedOutputOptions, bundle: OutputBundle, isWrite: boolean) => void;
|
|
855
|
+
[DEFINED_HOOK_NAMES.writeBundle]: (this: PluginContext, outputOptions: NormalizedOutputOptions, bundle: OutputBundle) => void;
|
|
856
|
+
[DEFINED_HOOK_NAMES.closeBundle]: (this: PluginContext) => void;
|
|
857
|
+
// --- watch hooks ---
|
|
858
|
+
[DEFINED_HOOK_NAMES.watchChange]: (this: PluginContext, id: string, event: {
|
|
859
|
+
event: ChangeEvent;
|
|
860
|
+
}) => void;
|
|
861
|
+
[DEFINED_HOOK_NAMES.closeWatcher]: (this: PluginContext) => void;
|
|
862
|
+
}
|
|
863
|
+
type ChangeEvent = "create" | "update" | "delete";
|
|
864
|
+
type PluginOrder = "pre" | "post" | null;
|
|
865
|
+
type ObjectHookMeta = {
|
|
866
|
+
order?: PluginOrder;
|
|
867
|
+
};
|
|
868
|
+
type ObjectHook<T, O = {}> = T | ({
|
|
869
|
+
handler: T;
|
|
870
|
+
} & ObjectHookMeta & O);
|
|
871
|
+
type SyncPluginHooks = DefinedHookNames["augmentChunkHash" | "onLog" | "outputOptions"];
|
|
872
|
+
// | 'renderDynamicImport'
|
|
873
|
+
// | 'resolveFileUrl'
|
|
874
|
+
// | 'resolveImportMeta'
|
|
875
|
+
type AsyncPluginHooks = Exclude<keyof FunctionPluginHooks, SyncPluginHooks>;
|
|
876
|
+
type FirstPluginHooks = DefinedHookNames["load" | "resolveDynamicImport" | "resolveId"];
|
|
877
|
+
// | 'resolveImportMeta'
|
|
878
|
+
// | 'shouldTransformCachedModule'
|
|
879
|
+
type SequentialPluginHooks = DefinedHookNames["augmentChunkHash" | "generateBundle" | "onLog" | "options" | "outputOptions" | "renderChunk" | "transform"];
|
|
880
|
+
type AddonHooks = DefinedHookNames["banner" | "footer" | "intro" | "outro"];
|
|
881
|
+
type OutputPluginHooks = DefinedHookNames["augmentChunkHash" | "generateBundle" | "outputOptions" | "renderChunk" | "renderError" | "renderStart" | "writeBundle"];
|
|
882
|
+
type ParallelPluginHooks = Exclude<keyof FunctionPluginHooks | AddonHooks, FirstPluginHooks | SequentialPluginHooks>;
|
|
883
|
+
type HookFilterExtension<K extends keyof FunctionPluginHooks> = K extends "transform" ? {
|
|
884
|
+
filter?: TUnionWithTopLevelFilterExpressionArray<HookFilter>;
|
|
885
|
+
} : K extends "load" ? {
|
|
886
|
+
filter?: TUnionWithTopLevelFilterExpressionArray<Pick<HookFilter, "id">>;
|
|
887
|
+
} : K extends "resolveId" ? {
|
|
888
|
+
filter?: TUnionWithTopLevelFilterExpressionArray<{
|
|
889
|
+
id?: GeneralHookFilter<RegExp>;
|
|
890
|
+
}>;
|
|
891
|
+
} : K extends "renderChunk" ? {
|
|
892
|
+
filter?: TUnionWithTopLevelFilterExpressionArray<Pick<HookFilter, "code">>;
|
|
893
|
+
} : {};
|
|
894
|
+
type PluginHooks = { [K in keyof FunctionPluginHooks]: ObjectHook<K extends AsyncPluginHooks ? MakeAsync<FunctionPluginHooks[K]> : FunctionPluginHooks[K], HookFilterExtension<K> & (K extends ParallelPluginHooks ? {
|
|
895
|
+
/**
|
|
896
|
+
* @deprecated
|
|
897
|
+
* this is only for rollup Plugin type compatibility.
|
|
898
|
+
* hooks always work as `sequential: true`.
|
|
899
|
+
*/
|
|
900
|
+
sequential?: boolean;
|
|
901
|
+
} : {})> };
|
|
902
|
+
type AddonHookFunction = (this: PluginContext, chunk: RenderedChunk) => string | Promise<string>;
|
|
903
|
+
type AddonHook = string | AddonHookFunction;
|
|
904
|
+
interface OutputPlugin extends Partial<{ [K in OutputPluginHooks]: PluginHooks[K] }>, Partial<{ [K in AddonHooks]: ObjectHook<AddonHook> }> {
|
|
905
|
+
// cacheKey?: string
|
|
906
|
+
name: string;
|
|
907
|
+
}
|
|
908
|
+
interface Plugin<A = any> extends OutputPlugin, Partial<PluginHooks> {
|
|
909
|
+
// for inter-plugin communication
|
|
910
|
+
api?: A;
|
|
911
|
+
}
|
|
912
|
+
type RolldownPlugin<A = any> = Plugin<A> | BuiltinPlugin | ParallelPlugin;
|
|
913
|
+
type RolldownPluginOption<A = any> = MaybePromise<NullValue<RolldownPlugin<A>> | {
|
|
914
|
+
name: string;
|
|
915
|
+
} | false | RolldownPluginOption[]>;
|
|
916
|
+
type RolldownOutputPlugin = OutputPlugin | BuiltinPlugin;
|
|
917
|
+
type RolldownOutputPluginOption = MaybePromise<NullValue<RolldownOutputPlugin> | {
|
|
918
|
+
name: string;
|
|
919
|
+
} | false | RolldownOutputPluginOption[]>;
|
|
920
|
+
//#endregion
|
|
921
|
+
//#region src/options/generated/checks-options.d.ts
|
|
922
|
+
// Auto-generated code, DO NOT EDIT DIRECTLY!
|
|
923
|
+
// To edit this generated file you have to edit `tasks/generator/src/generators/checks.rs`
|
|
924
|
+
interface ChecksOptions {
|
|
925
|
+
/**
|
|
926
|
+
* Whether to emit warning when detecting circular dependency
|
|
927
|
+
* @default false
|
|
928
|
+
*/
|
|
929
|
+
circularDependency?: boolean;
|
|
930
|
+
/**
|
|
931
|
+
* Whether to emit warning when detecting eval
|
|
932
|
+
* @default true
|
|
933
|
+
*/
|
|
934
|
+
eval?: boolean;
|
|
935
|
+
/**
|
|
936
|
+
* Whether to emit warning when detecting missing global name
|
|
937
|
+
* @default true
|
|
938
|
+
*/
|
|
939
|
+
missingGlobalName?: boolean;
|
|
940
|
+
/**
|
|
941
|
+
* Whether to emit warning when detecting missing name option for iife export
|
|
942
|
+
* @default true
|
|
943
|
+
*/
|
|
944
|
+
missingNameOptionForIifeExport?: boolean;
|
|
945
|
+
/**
|
|
946
|
+
* Whether to emit warning when detecting mixed export
|
|
947
|
+
* @default true
|
|
948
|
+
*/
|
|
949
|
+
mixedExport?: boolean;
|
|
950
|
+
/**
|
|
951
|
+
* Whether to emit warning when detecting unresolved entry
|
|
952
|
+
* @default true
|
|
953
|
+
*/
|
|
954
|
+
unresolvedEntry?: boolean;
|
|
955
|
+
/**
|
|
956
|
+
* Whether to emit warning when detecting unresolved import
|
|
957
|
+
* @default true
|
|
958
|
+
*/
|
|
959
|
+
unresolvedImport?: boolean;
|
|
960
|
+
/**
|
|
961
|
+
* Whether to emit warning when detecting filename conflict
|
|
962
|
+
* @default true
|
|
963
|
+
*/
|
|
964
|
+
filenameConflict?: boolean;
|
|
965
|
+
/**
|
|
966
|
+
* Whether to emit warning when detecting common js variable in esm
|
|
967
|
+
* @default true
|
|
968
|
+
*/
|
|
969
|
+
commonJsVariableInEsm?: boolean;
|
|
970
|
+
/**
|
|
971
|
+
* Whether to emit warning when detecting import is undefined
|
|
972
|
+
* @default true
|
|
973
|
+
*/
|
|
974
|
+
importIsUndefined?: boolean;
|
|
975
|
+
/**
|
|
976
|
+
* Whether to emit warning when detecting configuration field conflict
|
|
977
|
+
* @default true
|
|
978
|
+
*/
|
|
979
|
+
configurationFieldConflict?: boolean;
|
|
980
|
+
}
|
|
981
|
+
//#endregion
|
|
982
|
+
//#region src/options/input-options.d.ts
|
|
983
|
+
type InputOption = string | string[] | Record<string, string>;
|
|
984
|
+
// Omit those key that are part of rolldown option
|
|
985
|
+
type OxcTransformOption = Omit<TransformOptions, "sourceType" | "lang" | "cwd" | "sourcemap" | "define" | "inject">;
|
|
986
|
+
type ExternalOption = StringOrRegExp | StringOrRegExp[] | ((id: string, parentId: string | undefined, isResolved: boolean) => NullValue<boolean>);
|
|
987
|
+
type ModuleTypes = Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | "css" | "asset">;
|
|
988
|
+
interface WatcherOptions {
|
|
989
|
+
skipWrite?: boolean;
|
|
990
|
+
buildDelay?: number;
|
|
991
|
+
notify?: {
|
|
992
|
+
pollInterval?: number;
|
|
993
|
+
compareContents?: boolean;
|
|
994
|
+
};
|
|
995
|
+
include?: StringOrRegExp | StringOrRegExp[];
|
|
996
|
+
exclude?: StringOrRegExp | StringOrRegExp[];
|
|
997
|
+
}
|
|
998
|
+
type MakeAbsoluteExternalsRelative = boolean | "ifRelativeSource";
|
|
999
|
+
type HmrOptions = boolean | {
|
|
1000
|
+
host?: string;
|
|
1001
|
+
port?: number;
|
|
1002
|
+
implement?: string;
|
|
1003
|
+
};
|
|
1004
|
+
type AttachDebugOptions = "none" | "simple" | "full";
|
|
1005
|
+
interface RollupJsxOptions {
|
|
1006
|
+
mode?: "classic" | "automatic" | "preserve";
|
|
1007
|
+
factory?: string;
|
|
1008
|
+
fragment?: string;
|
|
1009
|
+
importSource?: string;
|
|
1010
|
+
jsxImportSource?: string;
|
|
1011
|
+
}
|
|
1012
|
+
interface InputOptions {
|
|
1013
|
+
input?: InputOption;
|
|
1014
|
+
plugins?: RolldownPluginOption;
|
|
1015
|
+
external?: ExternalOption;
|
|
1016
|
+
resolve?: {
|
|
1017
|
+
/**
|
|
1018
|
+
* > [!WARNING]
|
|
1019
|
+
* > `resolve.alias` will not call `resolveId` hooks of other plugin.
|
|
1020
|
+
* > If you want to call `resolveId` hooks of other plugin, use `aliasPlugin` from `rolldown/experimental` instead.
|
|
1021
|
+
* > You could find more discussion in [this issue](https://github.com/rolldown/rolldown/issues/3615)
|
|
1022
|
+
*/
|
|
1023
|
+
alias?: Record<string, string[] | string>;
|
|
1024
|
+
aliasFields?: string[][];
|
|
1025
|
+
conditionNames?: string[];
|
|
1026
|
+
/**
|
|
1027
|
+
* Map of extensions to alternative extensions.
|
|
1028
|
+
*
|
|
1029
|
+
* With writing `import './foo.js'` in a file, you want to resolve it to `foo.ts` instead of `foo.js`.
|
|
1030
|
+
* You can achieve this by setting: `extensionAlias: { '.js': ['.ts', '.js'] }`.
|
|
1031
|
+
*/
|
|
1032
|
+
extensionAlias?: Record<string, string[]>;
|
|
1033
|
+
exportsFields?: string[][];
|
|
1034
|
+
extensions?: string[];
|
|
1035
|
+
mainFields?: string[];
|
|
1036
|
+
mainFiles?: string[];
|
|
1037
|
+
modules?: string[];
|
|
1038
|
+
symlinks?: boolean;
|
|
1039
|
+
tsconfigFilename?: string;
|
|
1040
|
+
};
|
|
1041
|
+
cwd?: string;
|
|
1042
|
+
/**
|
|
1043
|
+
* Expected platform where the code run.
|
|
1044
|
+
*
|
|
1045
|
+
* @default
|
|
1046
|
+
* - 'node' if the format is 'cjs'
|
|
1047
|
+
* - 'browser' for other formats
|
|
1048
|
+
*/
|
|
1049
|
+
platform?: "node" | "browser" | "neutral";
|
|
1050
|
+
shimMissingExports?: boolean;
|
|
1051
|
+
treeshake?: boolean | TreeshakingOptions;
|
|
1052
|
+
logLevel?: LogLevelOption;
|
|
1053
|
+
onLog?: (level: LogLevel, log: RollupLog, defaultHandler: LogOrStringHandler) => void;
|
|
1054
|
+
onwarn?: (warning: RollupLog, defaultHandler: (warning: RollupLogWithString | (() => RollupLogWithString)) => void) => void;
|
|
1055
|
+
moduleTypes?: ModuleTypes;
|
|
1056
|
+
experimental?: {
|
|
1057
|
+
enableComposingJsPlugins?: boolean;
|
|
1058
|
+
strictExecutionOrder?: boolean;
|
|
1059
|
+
disableLiveBindings?: boolean;
|
|
1060
|
+
viteMode?: boolean;
|
|
1061
|
+
resolveNewUrlToAsset?: boolean;
|
|
1062
|
+
hmr?: HmrOptions;
|
|
1063
|
+
/**
|
|
1064
|
+
* Attach debug information to the output bundle.
|
|
1065
|
+
*
|
|
1066
|
+
* - Type: `'none' | 'simple' | 'full'`
|
|
1067
|
+
* - Default: `'simple'`
|
|
1068
|
+
*
|
|
1069
|
+
* - `none`: No debug information is attached.
|
|
1070
|
+
* - `simple`: Attach comments indicating which files the bundled code comes from. These comments could be removed by the minifier.
|
|
1071
|
+
* - `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.
|
|
1072
|
+
*
|
|
1073
|
+
* > [!WARNING]
|
|
1074
|
+
* > You shouldn't use `full` in the production build.
|
|
1075
|
+
*/
|
|
1076
|
+
attachDebugInfo?: AttachDebugOptions;
|
|
1077
|
+
};
|
|
1078
|
+
/**
|
|
1079
|
+
* Replace global variables or [property accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors) with the provided values.
|
|
1080
|
+
*
|
|
1081
|
+
* # Examples
|
|
1082
|
+
*
|
|
1083
|
+
* - Replace the global variable `IS_PROD` with `true`
|
|
1084
|
+
*
|
|
1085
|
+
* ```js rolldown.config.js
|
|
1086
|
+
* export default defineConfig({ define: { IS_PROD: 'true' // or JSON.stringify(true) } })
|
|
1087
|
+
* ```
|
|
1088
|
+
*
|
|
1089
|
+
* Result:
|
|
1090
|
+
*
|
|
1091
|
+
* ```js
|
|
1092
|
+
* // Input
|
|
1093
|
+
* if (IS_PROD) {
|
|
1094
|
+
* console.log('Production mode')
|
|
1095
|
+
* }
|
|
1096
|
+
*
|
|
1097
|
+
* // After bundling
|
|
1098
|
+
* if (true) {
|
|
1099
|
+
* console.log('Production mode')
|
|
1100
|
+
* }
|
|
1101
|
+
* ```
|
|
1102
|
+
*
|
|
1103
|
+
* - Replace the property accessor `process.env.NODE_ENV` with `'production'`
|
|
1104
|
+
*
|
|
1105
|
+
* ```js rolldown.config.js
|
|
1106
|
+
* export default defineConfig({ define: { 'process.env.NODE_ENV': "'production'" } })
|
|
1107
|
+
* ```
|
|
1108
|
+
*
|
|
1109
|
+
* Result:
|
|
1110
|
+
*
|
|
1111
|
+
* ```js
|
|
1112
|
+
* // Input
|
|
1113
|
+
* if (process.env.NODE_ENV === 'production') {
|
|
1114
|
+
* console.log('Production mode')
|
|
1115
|
+
* }
|
|
1116
|
+
*
|
|
1117
|
+
* // After bundling
|
|
1118
|
+
* if ('production' === 'production') {
|
|
1119
|
+
* console.log('Production mode')
|
|
1120
|
+
* }
|
|
1121
|
+
*
|
|
1122
|
+
* ```
|
|
1123
|
+
*/
|
|
1124
|
+
define?: Record<string, string>;
|
|
1125
|
+
/**
|
|
1126
|
+
* Inject import statements on demand.
|
|
1127
|
+
*
|
|
1128
|
+
* ## Supported patterns
|
|
1129
|
+
* ```js
|
|
1130
|
+
* {
|
|
1131
|
+
* // import { Promise } from 'es6-promise'
|
|
1132
|
+
* Promise: ['es6-promise', 'Promise'],
|
|
1133
|
+
*
|
|
1134
|
+
* // import { Promise as P } from 'es6-promise'
|
|
1135
|
+
* P: ['es6-promise', 'Promise'],
|
|
1136
|
+
*
|
|
1137
|
+
* // import $ from 'jquery'
|
|
1138
|
+
* $: 'jquery',
|
|
1139
|
+
*
|
|
1140
|
+
* // import * as fs from 'node:fs'
|
|
1141
|
+
* fs: ['node:fs', '*'],
|
|
1142
|
+
*
|
|
1143
|
+
* // Inject shims for property access pattern
|
|
1144
|
+
* 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
|
|
1145
|
+
* }
|
|
1146
|
+
* ```
|
|
1147
|
+
*/
|
|
1148
|
+
inject?: Record<string, string | [string, string]>;
|
|
1149
|
+
profilerNames?: boolean;
|
|
1150
|
+
/**
|
|
1151
|
+
* - `false` disables the JSX parser, resulting in a syntax error if JSX syntax is used.
|
|
1152
|
+
* - `"preserve"` disables the JSX transformer, preserving the original JSX syntax in the output.
|
|
1153
|
+
* - `"react"` enables the `classic` JSX transformer.
|
|
1154
|
+
* - `"react-jsx"` enables the `automatic` JSX transformer.
|
|
1155
|
+
*
|
|
1156
|
+
* @default runtime = "automatic"
|
|
1157
|
+
*/
|
|
1158
|
+
jsx?: false | "react" | "react-jsx" | "preserve" | RollupJsxOptions;
|
|
1159
|
+
/**
|
|
1160
|
+
* Configure how the code is transformed. This process happens after the `transform` hook.
|
|
1161
|
+
*
|
|
1162
|
+
* To transpile [legacy decorators](https://github.com/tc39/proposal-decorators/tree/4ac0f4cd31bd0f2e8170cb4c5136e51671e46c8d), you could use
|
|
1163
|
+
*
|
|
1164
|
+
* ```js
|
|
1165
|
+
* export default defineConfig({
|
|
1166
|
+
* transform: {
|
|
1167
|
+
* decorator: {
|
|
1168
|
+
* legacy: true,
|
|
1169
|
+
* },
|
|
1170
|
+
* },
|
|
1171
|
+
* })
|
|
1172
|
+
* ```
|
|
1173
|
+
*
|
|
1174
|
+
* For latest decorators proposal, rolldown is able to bundle them but doesn't support transpiling them yet.
|
|
1175
|
+
*/
|
|
1176
|
+
transform?: OxcTransformOption;
|
|
1177
|
+
watch?: WatcherOptions | false;
|
|
1178
|
+
dropLabels?: string[];
|
|
1179
|
+
keepNames?: boolean;
|
|
1180
|
+
checks?: ChecksOptions;
|
|
1181
|
+
makeAbsoluteExternalsRelative?: MakeAbsoluteExternalsRelative;
|
|
1182
|
+
debug?: {
|
|
1183
|
+
sessionId?: string;
|
|
1184
|
+
};
|
|
1185
|
+
preserveEntrySignatures?: false | "strict" | "allow-extension" | "exports-only";
|
|
1186
|
+
}
|
|
1187
|
+
//#endregion
|
|
1188
|
+
//#region src/types/rolldown-options.d.ts
|
|
1189
|
+
interface RolldownOptions extends InputOptions {
|
|
1190
|
+
output?: OutputOptions | OutputOptions[];
|
|
1191
|
+
}
|
|
1192
|
+
//#endregion
|
|
1193
|
+
//#region src/types/config-export.d.ts
|
|
1194
|
+
/**
|
|
1195
|
+
* Type for `default export` of `rolldown.config.js` file.
|
|
1196
|
+
*/
|
|
1197
|
+
type ConfigExport = RolldownOptions | RolldownOptions[];
|
|
1198
|
+
//#endregion
|
|
1199
|
+
//#region src/utils/define-config.d.ts
|
|
1200
|
+
declare function defineConfig(config: RolldownOptions): RolldownOptions;
|
|
1201
|
+
declare function defineConfig(config: RolldownOptions[]): RolldownOptions[];
|
|
1202
|
+
declare function defineConfig(config: ConfigExport): ConfigExport;
|
|
1203
|
+
//#endregion
|
|
1204
|
+
export { AddonFunction, AsyncPluginHooks, BuildOptions, BuiltinPlugin, ChunkFileNamesFunction, ConfigExport, CustomPluginOptions, DefineParallelPluginResult, EmittedAsset, EmittedFile, ExistingRawSourceMap, ExternalOption, FunctionPluginHooks, GeneralHookFilter, GetModuleInfo, GlobalsFunction, HookFilter, HookFilterExtension, ImportKind, InputOption, InputOptions, InternalModuleFormat, LoadResult, LogLevel, LogLevelOption, LogOrStringHandler, LoggingFunction, MaybePromise, MinifyOptions, MinimalPluginContext, ModuleFormat, ModuleInfo, ModuleOptions, ModuleType, ModuleTypeFilter, ModuleTypes, NormalizedInputOptions, NormalizedOutputOptions, ObjectHook, OutputAsset, OutputBundle, OutputChunk, OutputOptions, ParallelPluginHooks, PartialNull, PartialResolvedId, Plugin, PluginContext, PluginContextMeta, PreRenderedAsset, RenderedChunk, RenderedModule, ResolveIdExtraOptions, ResolveIdResult, ResolvedId, RolldownBuild, RolldownOptions, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatcher, RolldownWatcherEvent, RollupError, RollupLog, RollupLogWithString, SourceDescription, SourceMap, SourceMapInput, SourcemapIgnoreListOption, TransformPluginContext, TransformResult, TreeshakingOptions, VERSION, WarningHandlerWithDefault, WatchOptions, WatcherOptions, assetPlugin, build, buildImportAnalysisPlugin, defineConfig, defineParallelPlugin, dynamicImportVarsPlugin, importGlobPlugin, isolatedDeclarationPlugin, jsonPlugin, loadFallbackPlugin, manifestPlugin, moduleFederationPlugin, modulePreloadPolyfillPlugin, reporterPlugin, rolldown, viteResolvePlugin, wasmFallbackPlugin, wasmHelperPlugin, watch, webWorkerPostPlugin, withFilter };
|