@rolldown/browser 1.0.0-beta.15 → 1.0.0-beta.17
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.cjs +8 -8
- package/dist/cli.mjs +1042 -1083
- package/dist/config.cjs +3 -3
- package/dist/config.d.cts +2 -2
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +4 -5
- package/dist/experimental-index.browser.mjs +3 -3
- package/dist/experimental-index.cjs +3 -3
- package/dist/experimental-index.d.cts +2 -2
- package/dist/experimental-index.d.mts +2 -2
- package/dist/experimental-index.mjs +5 -17
- package/dist/experimental-runtime-types.d.ts +52 -0
- package/dist/filter-index.d.cts +2 -2
- package/dist/filter-index.d.mts +2 -2
- package/dist/filter-index.mjs +1 -2
- package/dist/index.browser.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -4
- package/dist/parallel-plugin-worker.cjs +2 -2
- package/dist/parallel-plugin-worker.mjs +27 -33
- package/dist/parallel-plugin.d.cts +2 -2
- package/dist/parallel-plugin.d.mts +2 -2
- package/dist/parse-ast-index.cjs +1 -1
- package/dist/parse-ast-index.d.cts +1 -1
- package/dist/parse-ast-index.d.mts +1 -1
- package/dist/parse-ast-index.mjs +1 -2
- package/dist/rolldown-binding.wasi-browser.js +4 -2
- package/dist/rolldown-binding.wasi.cjs +3 -1
- package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
- package/dist/shared/{binding-CZdobbZA.d.cts → binding-CWvDTpOw.d.mts} +23 -15
- package/dist/shared/{binding-Dze8QVpf.d.mts → binding-um3VI33z.d.cts} +23 -15
- package/dist/shared/{define-config-CnVvtpOm.d.mts → define-config-DETTMcOl.d.mts} +73 -12
- package/dist/shared/{define-config-BE-fkZNW.d.cts → define-config-POPyhxOq.d.cts} +73 -12
- package/dist/shared/dist-BoWaIc-K.mjs +147 -0
- package/dist/shared/{load-config-CmZwBnZf.mjs → load-config-C0FU-xTD.mjs} +14 -19
- package/dist/shared/{load-config-DlY_Bz-0.cjs → load-config-Cp5Lu-qW.cjs} +1 -1
- package/dist/shared/{parse-ast-index-IepkD-LB.mjs → parse-ast-index-B5AmHtd5.mjs} +10 -28
- package/dist/shared/{parse-ast-index-5MuKtufe.cjs → parse-ast-index-X4pECV1E.cjs} +1 -1
- package/dist/shared/prompt-C5jz26Zn.mjs +852 -0
- package/dist/shared/{prompt-8EeOGx1_.cjs → prompt-QNI93ne7.cjs} +2 -2
- package/dist/shared/{src-Do34b1Pc.mjs → src-CsIMaM6C.mjs} +1157 -1367
- package/dist/shared/{src-CYvvndv2.cjs → src-D8KQ1KMN.cjs} +43 -28
- package/dist/{src-B1yRSHcw.js → src-Bv_xHi2_.js} +43 -28
- package/package.json +3 -2
- package/dist/shared/chunk-DSsiIF1Z.mjs +0 -30
- package/dist/shared/dist-DeDsdiza.mjs +0 -153
- package/dist/shared/prompt-jPdbaKAj.mjs +0 -854
|
@@ -952,12 +952,23 @@ interface TypeScriptOptions {
|
|
|
952
952
|
declare class BindingBundleEndEventData {
|
|
953
953
|
output: string;
|
|
954
954
|
duration: number;
|
|
955
|
-
get result():
|
|
955
|
+
get result(): BindingBundlerImpl;
|
|
956
956
|
}
|
|
957
957
|
declare class BindingBundleErrorEventData {
|
|
958
|
-
get result():
|
|
958
|
+
get result(): BindingBundlerImpl;
|
|
959
959
|
get error(): Array<Error | BindingError>;
|
|
960
960
|
}
|
|
961
|
+
declare class BindingBundlerImpl {
|
|
962
|
+
constructor(option: BindingBundlerOptions);
|
|
963
|
+
write(): Promise<BindingOutputs>;
|
|
964
|
+
generate(): Promise<BindingOutputs>;
|
|
965
|
+
scan(): Promise<BindingOutputs>;
|
|
966
|
+
close(): Promise<void>;
|
|
967
|
+
get closed(): boolean;
|
|
968
|
+
getWatchFiles(): Promise<Array<string>>;
|
|
969
|
+
generateHmrPatch(changedFiles: Array<string>): Promise<BindingHmrOutput>;
|
|
970
|
+
hmrInvalidate(file: string, firstInvalidatedBy?: string | undefined | null): Promise<BindingHmrOutput>;
|
|
971
|
+
}
|
|
961
972
|
declare class BindingError {
|
|
962
973
|
kind: string;
|
|
963
974
|
message: string;
|
|
@@ -1006,6 +1017,9 @@ declare class BindingNormalizedOptions {
|
|
|
1006
1017
|
get minify(): false | BindingMinifyOptions;
|
|
1007
1018
|
get polyfillRequire(): boolean;
|
|
1008
1019
|
get legalComments(): 'none' | 'inline';
|
|
1020
|
+
get preserveModules(): boolean;
|
|
1021
|
+
get preserveModulesRoot(): string | undefined;
|
|
1022
|
+
get virtualDirname(): string;
|
|
1009
1023
|
}
|
|
1010
1024
|
declare class BindingOutputAsset {
|
|
1011
1025
|
get fileName(): string;
|
|
@@ -1080,17 +1094,6 @@ declare class BindingWatcherEvent {
|
|
|
1080
1094
|
bundleEventKind(): string;
|
|
1081
1095
|
bundleErrorData(): BindingBundleErrorEventData;
|
|
1082
1096
|
}
|
|
1083
|
-
declare class Bundler {
|
|
1084
|
-
constructor(option: BindingBundlerOptions);
|
|
1085
|
-
write(): Promise<BindingOutputs>;
|
|
1086
|
-
generate(): Promise<BindingOutputs>;
|
|
1087
|
-
scan(): Promise<BindingOutputs>;
|
|
1088
|
-
close(): Promise<void>;
|
|
1089
|
-
get closed(): boolean;
|
|
1090
|
-
getWatchFiles(): Promise<Array<string>>;
|
|
1091
|
-
generateHmrPatch(changedFiles: Array<string>): Promise<BindingHmrOutput>;
|
|
1092
|
-
hmrInvalidate(file: string, firstInvalidatedBy?: string | undefined | null): Promise<BindingHmrOutput>;
|
|
1093
|
-
}
|
|
1094
1097
|
declare class ParallelJsPluginRegistry {
|
|
1095
1098
|
id: number;
|
|
1096
1099
|
workerCount: number;
|
|
@@ -1117,6 +1120,11 @@ interface BindingAssetPluginConfig {
|
|
|
1117
1120
|
interface BindingAssetSource {
|
|
1118
1121
|
inner: string | Uint8Array;
|
|
1119
1122
|
}
|
|
1123
|
+
declare enum BindingAttachDebugInfo {
|
|
1124
|
+
None = 0,
|
|
1125
|
+
Simple = 1,
|
|
1126
|
+
Full = 2,
|
|
1127
|
+
}
|
|
1120
1128
|
interface BindingBuildImportAnalysisPluginConfig {
|
|
1121
1129
|
preloadCode: string;
|
|
1122
1130
|
insertPreload: boolean;
|
|
@@ -1184,7 +1192,7 @@ interface BindingExperimentalOptions {
|
|
|
1184
1192
|
viteMode?: boolean;
|
|
1185
1193
|
resolveNewUrlToAsset?: boolean;
|
|
1186
1194
|
hmr?: BindingExperimentalHmrOptions;
|
|
1187
|
-
attachDebugInfo?:
|
|
1195
|
+
attachDebugInfo?: BindingAttachDebugInfo;
|
|
1188
1196
|
}
|
|
1189
1197
|
interface BindingFilterToken {
|
|
1190
1198
|
kind: FilterTokenKind;
|
|
@@ -1645,4 +1653,4 @@ interface PreRenderedChunk {
|
|
|
1645
1653
|
exports: Array<string>;
|
|
1646
1654
|
}
|
|
1647
1655
|
//#endregion
|
|
1648
|
-
export { BindingAssetPluginConfig, BindingBuildImportAnalysisPluginConfig, BindingBuiltinPluginName,
|
|
1656
|
+
export { BindingAssetPluginConfig, BindingBuildImportAnalysisPluginConfig, BindingBuiltinPluginName, BindingBundlerImpl, BindingDynamicImportVarsPluginConfig, BindingHmrOutputPatch, BindingHookResolveIdExtraArgs, BindingImportGlobPluginConfig, BindingIsolatedDeclarationPluginConfig, BindingJsonPluginConfig, BindingManifestPluginConfig, BindingMfManifest, BindingMinifyOptions, BindingModuleFederationPluginOption, BindingModulePreloadPolyfillPluginConfig, BindingRemote, BindingRenderedChunk, BindingReplacePluginConfig, BindingReporterPluginConfig, BindingTransformHookExtraArgs, BindingTransformPluginConfig, BindingViteResolvePluginConfig, BindingWatcherEvent, IsolatedDeclarationsOptions, IsolatedDeclarationsResult, NapiResolveOptions, ParseResult, ParserOptions, PreRenderedChunk, ResolveResult, ResolverFactory, TransformOptions, TransformResult, isolatedDeclaration, moduleRunnerTransform, transform };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BindingAssetPluginConfig, BindingBuildImportAnalysisPluginConfig, BindingBuiltinPluginName,
|
|
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-CWvDTpOw.mjs";
|
|
2
2
|
import { Program } from "@oxc-project/types";
|
|
3
3
|
import { TopLevelFilterExpression } from "@rolldown/pluginutils";
|
|
4
4
|
|
|
@@ -170,7 +170,7 @@ interface OutputOptions {
|
|
|
170
170
|
externalLiveBindings?: boolean;
|
|
171
171
|
inlineDynamicImports?: boolean;
|
|
172
172
|
/**
|
|
173
|
-
* Allows you to do
|
|
173
|
+
* Allows you to do manual chunking. For deeper understanding, please refer to the in-depth [documentation](https://rolldown.rs/guide/in-depth/advanced-chunks).
|
|
174
174
|
*/
|
|
175
175
|
advancedChunks?: {
|
|
176
176
|
/**
|
|
@@ -211,6 +211,24 @@ interface OutputOptions {
|
|
|
211
211
|
* - Type: `string`
|
|
212
212
|
*
|
|
213
213
|
* Name of the group. It will be also used as the name of the chunk and replaced the `[name]` placeholder in the `chunkFileNames` option.
|
|
214
|
+
*
|
|
215
|
+
* For example,
|
|
216
|
+
*
|
|
217
|
+
* ```js
|
|
218
|
+
* import { defineConfig } from 'rolldown';
|
|
219
|
+
*
|
|
220
|
+
* export default defineConfig({
|
|
221
|
+
* advancedChunks: {
|
|
222
|
+
* groups: [
|
|
223
|
+
* {
|
|
224
|
+
* name: 'libs',
|
|
225
|
+
* test: /node_modules/,
|
|
226
|
+
* },
|
|
227
|
+
* ],
|
|
228
|
+
* },
|
|
229
|
+
* });
|
|
230
|
+
* ```
|
|
231
|
+
* will create a chunk named `libs-[hash].js` in the end.
|
|
214
232
|
*/
|
|
215
233
|
name: string;
|
|
216
234
|
/**
|
|
@@ -218,25 +236,50 @@ interface OutputOptions {
|
|
|
218
236
|
*
|
|
219
237
|
* Controls which modules are captured in this group.
|
|
220
238
|
*
|
|
221
|
-
* If `test` is a string, the module whose id contains the string will be captured.
|
|
222
|
-
* If `test` is a regular expression, the module whose id matches the regular expression will be captured.
|
|
223
|
-
* If `test` is a function, modules for which `test(id)` returns `true` will be captured.
|
|
224
|
-
*
|
|
239
|
+
* - If `test` is a string, the module whose id contains the string will be captured.
|
|
240
|
+
* - If `test` is a regular expression, the module whose id matches the regular expression will be captured.
|
|
241
|
+
* - If `test` is a function, modules for which `test(id)` returns `true` will be captured.
|
|
242
|
+
* - If `test` is empty, any module will be considered as matched.
|
|
225
243
|
*/
|
|
226
244
|
test?: StringOrRegExp | ((id: string) => boolean | undefined | void);
|
|
227
245
|
/**
|
|
228
246
|
* - Type: `number`
|
|
247
|
+
* - Default: `0`
|
|
229
248
|
*
|
|
230
249
|
* 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.
|
|
231
250
|
*
|
|
232
251
|
* If two groups have the same priority, the group whose index is smaller will be chosen.
|
|
252
|
+
*
|
|
253
|
+
* For example,
|
|
254
|
+
*
|
|
255
|
+
* ```js
|
|
256
|
+
* import { defineConfig } from 'rolldown';
|
|
257
|
+
*
|
|
258
|
+
* export default defineConfig({
|
|
259
|
+
* advancedChunks: {
|
|
260
|
+
* groups: [
|
|
261
|
+
* {
|
|
262
|
+
* name: 'react',
|
|
263
|
+
* test: /node_modules\/react/,
|
|
264
|
+
* priority: 1,
|
|
265
|
+
* },
|
|
266
|
+
* {
|
|
267
|
+
* name: 'other-libs',
|
|
268
|
+
* test: /node_modules/,
|
|
269
|
+
* priority: 2,
|
|
270
|
+
* },
|
|
271
|
+
* ],
|
|
272
|
+
* });
|
|
273
|
+
* ```
|
|
274
|
+
*
|
|
275
|
+
* 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.
|
|
233
276
|
*/
|
|
234
277
|
priority?: number;
|
|
235
278
|
/**
|
|
236
279
|
* - Type: `number`
|
|
237
280
|
* - Default: `0`
|
|
238
281
|
*
|
|
239
|
-
* Minimum size of the desired chunk. If accumulated size of captured modules is smaller than this value, this group will
|
|
282
|
+
* Minimum size 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.
|
|
240
283
|
*/
|
|
241
284
|
minSize?: number;
|
|
242
285
|
/**
|
|
@@ -250,7 +293,7 @@ interface OutputOptions {
|
|
|
250
293
|
* - Type: `number`
|
|
251
294
|
* - Default: `Infinity`
|
|
252
295
|
*
|
|
253
|
-
* If
|
|
296
|
+
* If the accumulated size 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.
|
|
254
297
|
*/
|
|
255
298
|
maxSize?: number;
|
|
256
299
|
/**
|
|
@@ -309,8 +352,8 @@ declare class RolldownBuild {
|
|
|
309
352
|
write(outputOptions?: OutputOptions): Promise<RolldownOutput>;
|
|
310
353
|
close(): Promise<void>;
|
|
311
354
|
[Symbol.asyncDispose](): Promise<void>;
|
|
312
|
-
generateHmrPatch(changedFiles: string[]): Promise<BindingHmrOutputPatch
|
|
313
|
-
hmrInvalidate(file: string, firstInvalidatedBy?: string): Promise<
|
|
355
|
+
generateHmrPatch(changedFiles: string[]): Promise<BindingHmrOutputPatch>;
|
|
356
|
+
hmrInvalidate(file: string, firstInvalidatedBy?: string): Promise<BindingHmrOutputPatch>;
|
|
314
357
|
// TODO(underfin)
|
|
315
358
|
// The `watchFiles` method returns a promise, but Rollup does not.
|
|
316
359
|
// Converting it to a synchronous API might cause a deadlock if the user calls `write` and `watchFiles` simultaneously.
|
|
@@ -330,7 +373,7 @@ interface WatchOptions extends InputOptions {
|
|
|
330
373
|
type WatcherEvent = "close" | "event" | "restart" | "change";
|
|
331
374
|
type ChangeEvent$1 = "create" | "update" | "delete";
|
|
332
375
|
// TODO: find a way use `RolldownBuild` instead of `Bundler`.
|
|
333
|
-
type RolldownWatchBuild =
|
|
376
|
+
type RolldownWatchBuild = BindingBundlerImpl;
|
|
334
377
|
type RolldownWatcherEvent = {
|
|
335
378
|
code: "START";
|
|
336
379
|
} | {
|
|
@@ -878,6 +921,7 @@ type HmrOptions = boolean | {
|
|
|
878
921
|
port?: number;
|
|
879
922
|
implement?: string;
|
|
880
923
|
};
|
|
924
|
+
type AttachDebugOptions = "none" | "simple" | "full";
|
|
881
925
|
interface RollupJsxOptions {
|
|
882
926
|
mode?: "classic" | "automatic" | "preserve";
|
|
883
927
|
factory?: string;
|
|
@@ -936,7 +980,7 @@ interface InputOptions {
|
|
|
936
980
|
viteMode?: boolean;
|
|
937
981
|
resolveNewUrlToAsset?: boolean;
|
|
938
982
|
hmr?: HmrOptions;
|
|
939
|
-
attachDebugInfo?:
|
|
983
|
+
attachDebugInfo?: AttachDebugOptions;
|
|
940
984
|
};
|
|
941
985
|
/**
|
|
942
986
|
* Replace global variables or [property accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors) with the provided values.
|
|
@@ -1019,6 +1063,23 @@ interface InputOptions {
|
|
|
1019
1063
|
* @default runtime = "automatic"
|
|
1020
1064
|
*/
|
|
1021
1065
|
jsx?: false | "react" | "react-jsx" | "preserve" | RollupJsxOptions;
|
|
1066
|
+
/**
|
|
1067
|
+
* Configure how the code is transformed. This process happens after the `transform` hook.
|
|
1068
|
+
*
|
|
1069
|
+
* To transpile [legacy decorators](https://github.com/tc39/proposal-decorators/tree/4ac0f4cd31bd0f2e8170cb4c5136e51671e46c8d), you could use
|
|
1070
|
+
*
|
|
1071
|
+
* ```js
|
|
1072
|
+
* export default defineConfig({
|
|
1073
|
+
* transform: {
|
|
1074
|
+
* decorator: {
|
|
1075
|
+
* legacy: true,
|
|
1076
|
+
* },
|
|
1077
|
+
* },
|
|
1078
|
+
* })
|
|
1079
|
+
* ```
|
|
1080
|
+
*
|
|
1081
|
+
* For latest decorators proposal, rolldown is able to bundle them but doesn't support transpiling them yet.
|
|
1082
|
+
*/
|
|
1022
1083
|
transform?: OxcTransformOption;
|
|
1023
1084
|
watch?: WatcherOptions | false;
|
|
1024
1085
|
dropLabels?: string[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BindingAssetPluginConfig, BindingBuildImportAnalysisPluginConfig, BindingBuiltinPluginName,
|
|
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-um3VI33z.cjs";
|
|
2
2
|
import { Program } from "@oxc-project/types";
|
|
3
3
|
import { TopLevelFilterExpression } from "@rolldown/pluginutils";
|
|
4
4
|
|
|
@@ -170,7 +170,7 @@ interface OutputOptions {
|
|
|
170
170
|
externalLiveBindings?: boolean;
|
|
171
171
|
inlineDynamicImports?: boolean;
|
|
172
172
|
/**
|
|
173
|
-
* Allows you to do
|
|
173
|
+
* Allows you to do manual chunking. For deeper understanding, please refer to the in-depth [documentation](https://rolldown.rs/guide/in-depth/advanced-chunks).
|
|
174
174
|
*/
|
|
175
175
|
advancedChunks?: {
|
|
176
176
|
/**
|
|
@@ -211,6 +211,24 @@ interface OutputOptions {
|
|
|
211
211
|
* - Type: `string`
|
|
212
212
|
*
|
|
213
213
|
* Name of the group. It will be also used as the name of the chunk and replaced the `[name]` placeholder in the `chunkFileNames` option.
|
|
214
|
+
*
|
|
215
|
+
* For example,
|
|
216
|
+
*
|
|
217
|
+
* ```js
|
|
218
|
+
* import { defineConfig } from 'rolldown';
|
|
219
|
+
*
|
|
220
|
+
* export default defineConfig({
|
|
221
|
+
* advancedChunks: {
|
|
222
|
+
* groups: [
|
|
223
|
+
* {
|
|
224
|
+
* name: 'libs',
|
|
225
|
+
* test: /node_modules/,
|
|
226
|
+
* },
|
|
227
|
+
* ],
|
|
228
|
+
* },
|
|
229
|
+
* });
|
|
230
|
+
* ```
|
|
231
|
+
* will create a chunk named `libs-[hash].js` in the end.
|
|
214
232
|
*/
|
|
215
233
|
name: string;
|
|
216
234
|
/**
|
|
@@ -218,25 +236,50 @@ interface OutputOptions {
|
|
|
218
236
|
*
|
|
219
237
|
* Controls which modules are captured in this group.
|
|
220
238
|
*
|
|
221
|
-
* If `test` is a string, the module whose id contains the string will be captured.
|
|
222
|
-
* If `test` is a regular expression, the module whose id matches the regular expression will be captured.
|
|
223
|
-
* If `test` is a function, modules for which `test(id)` returns `true` will be captured.
|
|
224
|
-
*
|
|
239
|
+
* - If `test` is a string, the module whose id contains the string will be captured.
|
|
240
|
+
* - If `test` is a regular expression, the module whose id matches the regular expression will be captured.
|
|
241
|
+
* - If `test` is a function, modules for which `test(id)` returns `true` will be captured.
|
|
242
|
+
* - If `test` is empty, any module will be considered as matched.
|
|
225
243
|
*/
|
|
226
244
|
test?: StringOrRegExp | ((id: string) => boolean | undefined | void);
|
|
227
245
|
/**
|
|
228
246
|
* - Type: `number`
|
|
247
|
+
* - Default: `0`
|
|
229
248
|
*
|
|
230
249
|
* 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.
|
|
231
250
|
*
|
|
232
251
|
* If two groups have the same priority, the group whose index is smaller will be chosen.
|
|
252
|
+
*
|
|
253
|
+
* For example,
|
|
254
|
+
*
|
|
255
|
+
* ```js
|
|
256
|
+
* import { defineConfig } from 'rolldown';
|
|
257
|
+
*
|
|
258
|
+
* export default defineConfig({
|
|
259
|
+
* advancedChunks: {
|
|
260
|
+
* groups: [
|
|
261
|
+
* {
|
|
262
|
+
* name: 'react',
|
|
263
|
+
* test: /node_modules\/react/,
|
|
264
|
+
* priority: 1,
|
|
265
|
+
* },
|
|
266
|
+
* {
|
|
267
|
+
* name: 'other-libs',
|
|
268
|
+
* test: /node_modules/,
|
|
269
|
+
* priority: 2,
|
|
270
|
+
* },
|
|
271
|
+
* ],
|
|
272
|
+
* });
|
|
273
|
+
* ```
|
|
274
|
+
*
|
|
275
|
+
* 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.
|
|
233
276
|
*/
|
|
234
277
|
priority?: number;
|
|
235
278
|
/**
|
|
236
279
|
* - Type: `number`
|
|
237
280
|
* - Default: `0`
|
|
238
281
|
*
|
|
239
|
-
* Minimum size of the desired chunk. If accumulated size of captured modules is smaller than this value, this group will
|
|
282
|
+
* Minimum size 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.
|
|
240
283
|
*/
|
|
241
284
|
minSize?: number;
|
|
242
285
|
/**
|
|
@@ -250,7 +293,7 @@ interface OutputOptions {
|
|
|
250
293
|
* - Type: `number`
|
|
251
294
|
* - Default: `Infinity`
|
|
252
295
|
*
|
|
253
|
-
* If
|
|
296
|
+
* If the accumulated size 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.
|
|
254
297
|
*/
|
|
255
298
|
maxSize?: number;
|
|
256
299
|
/**
|
|
@@ -309,8 +352,8 @@ declare class RolldownBuild {
|
|
|
309
352
|
write(outputOptions?: OutputOptions): Promise<RolldownOutput>;
|
|
310
353
|
close(): Promise<void>;
|
|
311
354
|
[Symbol.asyncDispose](): Promise<void>;
|
|
312
|
-
generateHmrPatch(changedFiles: string[]): Promise<BindingHmrOutputPatch
|
|
313
|
-
hmrInvalidate(file: string, firstInvalidatedBy?: string): Promise<
|
|
355
|
+
generateHmrPatch(changedFiles: string[]): Promise<BindingHmrOutputPatch>;
|
|
356
|
+
hmrInvalidate(file: string, firstInvalidatedBy?: string): Promise<BindingHmrOutputPatch>;
|
|
314
357
|
// TODO(underfin)
|
|
315
358
|
// The `watchFiles` method returns a promise, but Rollup does not.
|
|
316
359
|
// Converting it to a synchronous API might cause a deadlock if the user calls `write` and `watchFiles` simultaneously.
|
|
@@ -330,7 +373,7 @@ interface WatchOptions extends InputOptions {
|
|
|
330
373
|
type WatcherEvent = "close" | "event" | "restart" | "change";
|
|
331
374
|
type ChangeEvent$1 = "create" | "update" | "delete";
|
|
332
375
|
// TODO: find a way use `RolldownBuild` instead of `Bundler`.
|
|
333
|
-
type RolldownWatchBuild =
|
|
376
|
+
type RolldownWatchBuild = BindingBundlerImpl;
|
|
334
377
|
type RolldownWatcherEvent = {
|
|
335
378
|
code: "START";
|
|
336
379
|
} | {
|
|
@@ -878,6 +921,7 @@ type HmrOptions = boolean | {
|
|
|
878
921
|
port?: number;
|
|
879
922
|
implement?: string;
|
|
880
923
|
};
|
|
924
|
+
type AttachDebugOptions = "none" | "simple" | "full";
|
|
881
925
|
interface RollupJsxOptions {
|
|
882
926
|
mode?: "classic" | "automatic" | "preserve";
|
|
883
927
|
factory?: string;
|
|
@@ -936,7 +980,7 @@ interface InputOptions {
|
|
|
936
980
|
viteMode?: boolean;
|
|
937
981
|
resolveNewUrlToAsset?: boolean;
|
|
938
982
|
hmr?: HmrOptions;
|
|
939
|
-
attachDebugInfo?:
|
|
983
|
+
attachDebugInfo?: AttachDebugOptions;
|
|
940
984
|
};
|
|
941
985
|
/**
|
|
942
986
|
* Replace global variables or [property accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors) with the provided values.
|
|
@@ -1019,6 +1063,23 @@ interface InputOptions {
|
|
|
1019
1063
|
* @default runtime = "automatic"
|
|
1020
1064
|
*/
|
|
1021
1065
|
jsx?: false | "react" | "react-jsx" | "preserve" | RollupJsxOptions;
|
|
1066
|
+
/**
|
|
1067
|
+
* Configure how the code is transformed. This process happens after the `transform` hook.
|
|
1068
|
+
*
|
|
1069
|
+
* To transpile [legacy decorators](https://github.com/tc39/proposal-decorators/tree/4ac0f4cd31bd0f2e8170cb4c5136e51671e46c8d), you could use
|
|
1070
|
+
*
|
|
1071
|
+
* ```js
|
|
1072
|
+
* export default defineConfig({
|
|
1073
|
+
* transform: {
|
|
1074
|
+
* decorator: {
|
|
1075
|
+
* legacy: true,
|
|
1076
|
+
* },
|
|
1077
|
+
* },
|
|
1078
|
+
* })
|
|
1079
|
+
* ```
|
|
1080
|
+
*
|
|
1081
|
+
* For latest decorators proposal, rolldown is able to bundle them but doesn't support transpiling them yet.
|
|
1082
|
+
*/
|
|
1022
1083
|
transform?: OxcTransformOption;
|
|
1023
1084
|
watch?: WatcherOptions | false;
|
|
1024
1085
|
dropLabels?: string[];
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
//#region src/utils/misc.ts
|
|
2
|
+
function arraify(value) {
|
|
3
|
+
return Array.isArray(value) ? value : [value];
|
|
4
|
+
}
|
|
5
|
+
function isNullish(value) {
|
|
6
|
+
return value === null || value === void 0;
|
|
7
|
+
}
|
|
8
|
+
function isPromiseLike(value) {
|
|
9
|
+
return value && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
|
|
10
|
+
}
|
|
11
|
+
function unimplemented(info) {
|
|
12
|
+
if (info) throw new Error(`unimplemented: ${info}`);
|
|
13
|
+
throw new Error("unimplemented");
|
|
14
|
+
}
|
|
15
|
+
function unreachable(info) {
|
|
16
|
+
if (info) throw new Error(`unreachable: ${info}`);
|
|
17
|
+
throw new Error("unreachable");
|
|
18
|
+
}
|
|
19
|
+
function unsupported(info) {
|
|
20
|
+
throw new Error(`UNSUPPORTED: ${info}`);
|
|
21
|
+
}
|
|
22
|
+
function noop(..._args) {}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region ../pluginutils/dist/index.js
|
|
26
|
+
var And = class {
|
|
27
|
+
kind;
|
|
28
|
+
args;
|
|
29
|
+
constructor(...args) {
|
|
30
|
+
if (args.length === 0) throw new Error("`And` expects at least one operand");
|
|
31
|
+
this.args = args;
|
|
32
|
+
this.kind = "and";
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var Or = class {
|
|
36
|
+
kind;
|
|
37
|
+
args;
|
|
38
|
+
constructor(...args) {
|
|
39
|
+
if (args.length === 0) throw new Error("`Or` expects at least one operand");
|
|
40
|
+
this.args = args;
|
|
41
|
+
this.kind = "or";
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var Not = class {
|
|
45
|
+
kind;
|
|
46
|
+
expr;
|
|
47
|
+
constructor(expr) {
|
|
48
|
+
this.expr = expr;
|
|
49
|
+
this.kind = "not";
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var Id = class {
|
|
53
|
+
kind;
|
|
54
|
+
pattern;
|
|
55
|
+
params;
|
|
56
|
+
constructor(pattern, params) {
|
|
57
|
+
this.pattern = pattern;
|
|
58
|
+
this.kind = "id";
|
|
59
|
+
this.params = params ?? { cleanUrl: false };
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var ModuleType = class {
|
|
63
|
+
kind;
|
|
64
|
+
pattern;
|
|
65
|
+
constructor(pattern) {
|
|
66
|
+
this.pattern = pattern;
|
|
67
|
+
this.kind = "moduleType";
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
var Code = class {
|
|
71
|
+
kind;
|
|
72
|
+
pattern;
|
|
73
|
+
constructor(expr) {
|
|
74
|
+
this.pattern = expr;
|
|
75
|
+
this.kind = "code";
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var Query = class {
|
|
79
|
+
kind;
|
|
80
|
+
key;
|
|
81
|
+
pattern;
|
|
82
|
+
constructor(key, pattern) {
|
|
83
|
+
this.pattern = pattern;
|
|
84
|
+
this.key = key;
|
|
85
|
+
this.kind = "query";
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var Include = class {
|
|
89
|
+
kind;
|
|
90
|
+
expr;
|
|
91
|
+
constructor(expr) {
|
|
92
|
+
this.expr = expr;
|
|
93
|
+
this.kind = "include";
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var Exclude = class {
|
|
97
|
+
kind;
|
|
98
|
+
expr;
|
|
99
|
+
constructor(expr) {
|
|
100
|
+
this.expr = expr;
|
|
101
|
+
this.kind = "exclude";
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
function and(...args) {
|
|
105
|
+
return new And(...args);
|
|
106
|
+
}
|
|
107
|
+
function or(...args) {
|
|
108
|
+
return new Or(...args);
|
|
109
|
+
}
|
|
110
|
+
function not(expr) {
|
|
111
|
+
return new Not(expr);
|
|
112
|
+
}
|
|
113
|
+
function id(pattern, params) {
|
|
114
|
+
return new Id(pattern, params);
|
|
115
|
+
}
|
|
116
|
+
function moduleType(pattern) {
|
|
117
|
+
return new ModuleType(pattern);
|
|
118
|
+
}
|
|
119
|
+
function code(pattern) {
|
|
120
|
+
return new Code(pattern);
|
|
121
|
+
}
|
|
122
|
+
function query(key, pattern) {
|
|
123
|
+
return new Query(key, pattern);
|
|
124
|
+
}
|
|
125
|
+
function include(expr) {
|
|
126
|
+
return new Include(expr);
|
|
127
|
+
}
|
|
128
|
+
function exclude(expr) {
|
|
129
|
+
return new Exclude(expr);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* convert a queryObject to FilterExpression like
|
|
133
|
+
* ```js
|
|
134
|
+
* and(query(k1, v1), query(k2, v2))
|
|
135
|
+
* ```
|
|
136
|
+
* @param queryFilterObject The query filter object needs to be matched.
|
|
137
|
+
* @returns a `And` FilterExpression
|
|
138
|
+
*/
|
|
139
|
+
function queries(queryFilter) {
|
|
140
|
+
let arr = Object.entries(queryFilter).map(([key, value]) => {
|
|
141
|
+
return new Query(key, value);
|
|
142
|
+
});
|
|
143
|
+
return and(...arr);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
//#endregion
|
|
147
|
+
export { and, arraify, code, exclude, id, include, isNullish, isPromiseLike, moduleType, noop, not, or, queries, query, unimplemented, unreachable, unsupported };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { init_rolldown, rolldown } from "./src-Do34b1Pc.mjs";
|
|
1
|
+
import { rolldown } from "./src-CsIMaM6C.mjs";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import { pathToFileURL } from "node:url";
|
|
5
4
|
import { cwd } from "node:process";
|
|
@@ -48,6 +47,18 @@ async function bundleTsConfig(configFile, isEsm) {
|
|
|
48
47
|
const fileName = result.output.find((chunk) => chunk.type === "chunk" && chunk.isEntry).fileName;
|
|
49
48
|
return path.join(outputDir, fileName);
|
|
50
49
|
}
|
|
50
|
+
const SUPPORTED_JS_CONFIG_FORMATS = [
|
|
51
|
+
".js",
|
|
52
|
+
".mjs",
|
|
53
|
+
".cjs"
|
|
54
|
+
];
|
|
55
|
+
const SUPPORTED_TS_CONFIG_FORMATS = [
|
|
56
|
+
".ts",
|
|
57
|
+
".mts",
|
|
58
|
+
".cts"
|
|
59
|
+
];
|
|
60
|
+
const SUPPORTED_CONFIG_FORMATS = [...SUPPORTED_JS_CONFIG_FORMATS, ...SUPPORTED_TS_CONFIG_FORMATS];
|
|
61
|
+
const DEFAULT_CONFIG_BASE = "rolldown.config";
|
|
51
62
|
async function findConfigFileNameInCwd() {
|
|
52
63
|
const filesInWorkingDirectory = new Set(await readdir(cwd()));
|
|
53
64
|
for (const extension of SUPPORTED_CONFIG_FORMATS) {
|
|
@@ -103,22 +114,6 @@ async function loadConfig(configPath) {
|
|
|
103
114
|
throw new Error("Error happened while loading config.", { cause: err });
|
|
104
115
|
}
|
|
105
116
|
}
|
|
106
|
-
var SUPPORTED_JS_CONFIG_FORMATS, SUPPORTED_TS_CONFIG_FORMATS, SUPPORTED_CONFIG_FORMATS, DEFAULT_CONFIG_BASE;
|
|
107
|
-
var init_load_config = __esm({ "src/utils/load-config.ts"() {
|
|
108
|
-
init_rolldown();
|
|
109
|
-
SUPPORTED_JS_CONFIG_FORMATS = [
|
|
110
|
-
".js",
|
|
111
|
-
".mjs",
|
|
112
|
-
".cjs"
|
|
113
|
-
];
|
|
114
|
-
SUPPORTED_TS_CONFIG_FORMATS = [
|
|
115
|
-
".ts",
|
|
116
|
-
".mts",
|
|
117
|
-
".cts"
|
|
118
|
-
];
|
|
119
|
-
SUPPORTED_CONFIG_FORMATS = [...SUPPORTED_JS_CONFIG_FORMATS, ...SUPPORTED_TS_CONFIG_FORMATS];
|
|
120
|
-
DEFAULT_CONFIG_BASE = "rolldown.config";
|
|
121
|
-
} });
|
|
122
117
|
|
|
123
118
|
//#endregion
|
|
124
|
-
export {
|
|
119
|
+
export { loadConfig };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-DDkG_k5U.cjs');
|
|
2
|
-
const require_src = require('./src-
|
|
2
|
+
const require_src = require('./src-D8KQ1KMN.cjs');
|
|
3
3
|
const node_path = require_chunk.__toESM(require("node:path"));
|
|
4
4
|
const node_url = require_chunk.__toESM(require("node:url"));
|
|
5
5
|
const node_process = require_chunk.__toESM(require("node:process"));
|