@rolldown/browser 1.0.0-beta.43 → 1.0.0-beta.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-setup.d.mts +1 -0
- package/dist/cli-setup.mjs +16 -0
- package/dist/cli.mjs +1049 -76
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +4 -4
- package/dist/experimental-index.browser.mjs +34 -453
- package/dist/experimental-index.d.mts +21 -6
- package/dist/experimental-index.mjs +39 -16
- package/dist/filter-index.d.mts +2 -2
- package/dist/filter-index.mjs +1 -1
- package/dist/index.browser.mjs +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -3
- package/dist/parallel-plugin-worker.mjs +3 -3
- package/dist/parallel-plugin.d.mts +2 -2
- package/dist/parse-ast-index.d.mts +3 -3
- package/dist/parse-ast-index.mjs +1 -1
- package/dist/rolldown-binding.wasi-browser.js +1 -2
- package/dist/rolldown-binding.wasi.cjs +1 -2
- package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
- package/dist/shared/{binding-BkaKdpud.d.mts → binding-DRegrFdE.d.mts} +98 -22
- package/dist/shared/{dist-CU0dSkK2.mjs → composable-filters-D_PY7Qa7.mjs} +2 -2
- package/dist/shared/{define-config-D5LB7YAC.d.mts → define-config-C6-goOPh.d.mts} +217 -99
- package/dist/shared/{load-config-DBsf9ada.mjs → load-config-Z2MWPLZO.mjs} +4 -4
- package/dist/shared/{parse-ast-index-Gktxd-oi.mjs → parse-ast-index-Ck5SwMSC.mjs} +37 -6
- package/dist/shared/{prompt-B4e-jZUR.mjs → prompt-BDwA3jSr.mjs} +1 -1
- package/dist/shared/{src-Dqrw8WuH.mjs → src-B4ZmdjD5.mjs} +637 -669
- package/dist/{src-DXN0YLUN.js → src-CLWy1Uip.js} +871 -873
- package/package.json +1 -1
- package/dist/shared/logger-B83ocDok.mjs +0 -985
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as ParserOptions, I as PreRenderedChunk, M as MinifyOptions$1, O as BindingWatcherEvent, _ as BindingRenderedChunk, b as BindingTransformHookExtraArgs, c as BindingHookResolveIdExtraArgs, f as BindingMagicString, i as BindingBundlerImpl, j as JsxOptions, r as BindingBuiltinPluginName, z as TransformOptions$1 } from "./binding-DRegrFdE.mjs";
|
|
2
2
|
import { Program } from "@oxc-project/types";
|
|
3
3
|
import { TopLevelFilterExpression } from "@rolldown/pluginutils";
|
|
4
4
|
|
|
@@ -159,10 +159,20 @@ interface GeneratedCodeOptions {
|
|
|
159
159
|
* ```
|
|
160
160
|
*/
|
|
161
161
|
preset?: GeneratedCodePreset;
|
|
162
|
+
/**
|
|
163
|
+
* Whether to add readable names to internal variables for profiling purposes.
|
|
164
|
+
*
|
|
165
|
+
* When enabled, generated code will use descriptive variable names that correspond
|
|
166
|
+
* to the original module names, making it easier to profile and debug the bundled code.
|
|
167
|
+
*
|
|
168
|
+
* @default true when minification is disabled, false when minification is enabled
|
|
169
|
+
*/
|
|
170
|
+
profilerNames?: boolean;
|
|
162
171
|
}
|
|
163
172
|
type ModuleFormat = "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | "umd";
|
|
164
173
|
type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
|
|
165
174
|
type ChunkFileNamesFunction = (chunkInfo: PreRenderedChunk) => string;
|
|
175
|
+
type SanitizeFileNameFunction = (name: string) => string;
|
|
166
176
|
interface PreRenderedAsset {
|
|
167
177
|
type: "asset";
|
|
168
178
|
name?: string;
|
|
@@ -172,7 +182,13 @@ interface PreRenderedAsset {
|
|
|
172
182
|
source: string | Uint8Array;
|
|
173
183
|
}
|
|
174
184
|
type AssetFileNamesFunction = (chunkInfo: PreRenderedAsset) => string;
|
|
185
|
+
type PathsFunction$1 = (id: string) => string;
|
|
186
|
+
type ManualChunksFunction = (moduleId: string, meta: {
|
|
187
|
+
getModuleInfo: (moduleId: string) => ModuleInfo | null;
|
|
188
|
+
}) => string | NullValue;
|
|
175
189
|
type GlobalsFunction = (name: string) => string;
|
|
190
|
+
type AdvancedChunksNameFunction = (moduleId: string, ctx: ChunkingContext) => string | NullValue;
|
|
191
|
+
type AdvancedChunksTestFunction = (id: string) => boolean | undefined | void;
|
|
176
192
|
type MinifyOptions = Omit<MinifyOptions$1, "module" | "sourcemap">;
|
|
177
193
|
interface ChunkingContext {
|
|
178
194
|
getModuleInfo(moduleId: string): ModuleInfo | null;
|
|
@@ -239,7 +255,7 @@ interface OutputOptions {
|
|
|
239
255
|
chunkFileNames?: string | ChunkFileNamesFunction;
|
|
240
256
|
cssEntryFileNames?: string | ChunkFileNamesFunction;
|
|
241
257
|
cssChunkFileNames?: string | ChunkFileNamesFunction;
|
|
242
|
-
sanitizeFileName?: boolean |
|
|
258
|
+
sanitizeFileName?: boolean | SanitizeFileNameFunction;
|
|
243
259
|
/**
|
|
244
260
|
* Control code minification.
|
|
245
261
|
*
|
|
@@ -283,7 +299,7 @@ interface OutputOptions {
|
|
|
283
299
|
* }
|
|
284
300
|
* ```
|
|
285
301
|
*/
|
|
286
|
-
paths?: Record<string, string> |
|
|
302
|
+
paths?: Record<string, string> | PathsFunction$1;
|
|
287
303
|
generatedCode?: Partial<GeneratedCodeOptions>;
|
|
288
304
|
externalLiveBindings?: boolean;
|
|
289
305
|
inlineDynamicImports?: boolean;
|
|
@@ -331,11 +347,9 @@ interface OutputOptions {
|
|
|
331
347
|
*
|
|
332
348
|
* @deprecated Please use `advancedChunks` instead.
|
|
333
349
|
*/
|
|
334
|
-
manualChunks?:
|
|
335
|
-
getModuleInfo: (moduleId: string) => ModuleInfo | null;
|
|
336
|
-
}) => string | NullValue;
|
|
350
|
+
manualChunks?: ManualChunksFunction;
|
|
337
351
|
/**
|
|
338
|
-
* Allows you to do manual chunking. For deeper understanding, please refer to the in-depth [documentation](https://rolldown.rs/
|
|
352
|
+
* Allows you to do manual chunking. For deeper understanding, please refer to the in-depth [documentation](https://rolldown.rs/in-depth/advanced-chunks).
|
|
339
353
|
*/
|
|
340
354
|
advancedChunks?: {
|
|
341
355
|
/**
|
|
@@ -437,7 +451,7 @@ interface OutputOptions {
|
|
|
437
451
|
* Constraints like `minSize`, `maxSize`, etc. are applied separately for different names returned by the function.
|
|
438
452
|
* :::
|
|
439
453
|
*/
|
|
440
|
-
name: string |
|
|
454
|
+
name: string | AdvancedChunksNameFunction;
|
|
441
455
|
/**
|
|
442
456
|
* - Type: `string | RegExp | ((id: string) => boolean | undefined | void);`
|
|
443
457
|
*
|
|
@@ -454,7 +468,7 @@ interface OutputOptions {
|
|
|
454
468
|
* - ❌ Not recommended: `/node_modules/react/`
|
|
455
469
|
* :::
|
|
456
470
|
*/
|
|
457
|
-
test?: StringOrRegExp |
|
|
471
|
+
test?: StringOrRegExp | AdvancedChunksTestFunction;
|
|
458
472
|
/**
|
|
459
473
|
* - Type: `number`
|
|
460
474
|
* - Default: `0`
|
|
@@ -541,11 +555,26 @@ interface OutputOptions {
|
|
|
541
555
|
topLevelVar?: boolean;
|
|
542
556
|
/**
|
|
543
557
|
* - Type: `boolean`
|
|
544
|
-
* - Default: `false`
|
|
558
|
+
* - Default: `true` for format `es` or if `output.minify` is `true` or object, `false` otherwise
|
|
545
559
|
*
|
|
546
560
|
* Whether to minify internal exports.
|
|
547
561
|
*/
|
|
548
562
|
minifyInternalExports?: boolean;
|
|
563
|
+
/**
|
|
564
|
+
* - Type: `boolean`
|
|
565
|
+
* - Default: `false`
|
|
566
|
+
*
|
|
567
|
+
* Clean output directory before emitting output.
|
|
568
|
+
*/
|
|
569
|
+
cleanDir?: boolean;
|
|
570
|
+
/** Keep function and class names after bundling.
|
|
571
|
+
*
|
|
572
|
+
* When enabled, the bundler will preserve the original names of functions and classes
|
|
573
|
+
* in the output, which is useful for debugging and error stack traces.
|
|
574
|
+
*
|
|
575
|
+
* @default false
|
|
576
|
+
*/
|
|
577
|
+
keepNames?: boolean;
|
|
549
578
|
}
|
|
550
579
|
//#endregion
|
|
551
580
|
//#region src/api/build.d.ts
|
|
@@ -852,7 +881,7 @@ interface PluginContext extends MinimalPluginContext {
|
|
|
852
881
|
id: string;
|
|
853
882
|
resolveDependencies?: boolean;
|
|
854
883
|
} & Partial<PartialNull<ModuleOptions>>): Promise<ModuleInfo>;
|
|
855
|
-
parse(input: string, options?: ParserOptions |
|
|
884
|
+
parse(input: string, options?: ParserOptions | null): Program;
|
|
856
885
|
resolve(source: string, importer?: string, options?: PluginContextResolveOptions): Promise<ResolvedId | null>;
|
|
857
886
|
}
|
|
858
887
|
//#endregion
|
|
@@ -1039,15 +1068,15 @@ type SequentialPluginHooks = DefinedHookNames["augmentChunkHash" | "generateBund
|
|
|
1039
1068
|
type AddonHooks = DefinedHookNames["banner" | "footer" | "intro" | "outro"];
|
|
1040
1069
|
type OutputPluginHooks = DefinedHookNames["augmentChunkHash" | "generateBundle" | "outputOptions" | "renderChunk" | "renderError" | "renderStart" | "writeBundle"];
|
|
1041
1070
|
type ParallelPluginHooks = Exclude<keyof FunctionPluginHooks | AddonHooks, FirstPluginHooks | SequentialPluginHooks>;
|
|
1042
|
-
type HookFilterExtension<K extends keyof FunctionPluginHooks> = K extends "transform" ? {
|
|
1071
|
+
type HookFilterExtension<K$1 extends keyof FunctionPluginHooks> = K$1 extends "transform" ? {
|
|
1043
1072
|
filter?: TUnionWithTopLevelFilterExpressionArray<HookFilter>;
|
|
1044
|
-
} : K extends "load" ? {
|
|
1073
|
+
} : K$1 extends "load" ? {
|
|
1045
1074
|
filter?: TUnionWithTopLevelFilterExpressionArray<Pick<HookFilter, "id">>;
|
|
1046
|
-
} : K extends "resolveId" ? {
|
|
1075
|
+
} : K$1 extends "resolveId" ? {
|
|
1047
1076
|
filter?: TUnionWithTopLevelFilterExpressionArray<{
|
|
1048
1077
|
id?: GeneralHookFilter<RegExp>;
|
|
1049
1078
|
}>;
|
|
1050
|
-
} : K extends "renderChunk" ? {
|
|
1079
|
+
} : K$1 extends "renderChunk" ? {
|
|
1051
1080
|
filter?: TUnionWithTopLevelFilterExpressionArray<Pick<HookFilter, "code">>;
|
|
1052
1081
|
} : {};
|
|
1053
1082
|
type PluginHooks = { [K in keyof FunctionPluginHooks]: ObjectHook<K extends AsyncPluginHooks ? MakeAsync<FunctionPluginHooks[K]> : FunctionPluginHooks[K], HookFilterExtension<K> & (K extends ParallelPluginHooks ? {
|
|
@@ -1144,10 +1173,116 @@ interface ChecksOptions {
|
|
|
1144
1173
|
preferBuiltinFeature?: boolean;
|
|
1145
1174
|
}
|
|
1146
1175
|
//#endregion
|
|
1176
|
+
//#region src/options/transform-options.d.ts
|
|
1177
|
+
interface TransformOptions extends Omit<TransformOptions$1, "sourceType" | "lang" | "cwd" | "sourcemap" | "define" | "inject" | "jsx"> {
|
|
1178
|
+
/**
|
|
1179
|
+
* Replace global variables or [property accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors) with the provided values.
|
|
1180
|
+
*
|
|
1181
|
+
* # Examples
|
|
1182
|
+
*
|
|
1183
|
+
* - Replace the global variable `IS_PROD` with `true`
|
|
1184
|
+
*
|
|
1185
|
+
* ```js rolldown.config.js
|
|
1186
|
+
* export default defineConfig({ transform: { define: { IS_PROD: 'true' } } })
|
|
1187
|
+
* ```
|
|
1188
|
+
*
|
|
1189
|
+
* Result:
|
|
1190
|
+
*
|
|
1191
|
+
* ```js
|
|
1192
|
+
* // Input
|
|
1193
|
+
* if (IS_PROD) {
|
|
1194
|
+
* console.log('Production mode')
|
|
1195
|
+
* }
|
|
1196
|
+
*
|
|
1197
|
+
* // After bundling
|
|
1198
|
+
* if (true) {
|
|
1199
|
+
* console.log('Production mode')
|
|
1200
|
+
* }
|
|
1201
|
+
* ```
|
|
1202
|
+
*
|
|
1203
|
+
* - Replace the property accessor `process.env.NODE_ENV` with `'production'`
|
|
1204
|
+
*
|
|
1205
|
+
* ```js rolldown.config.js
|
|
1206
|
+
* export default defineConfig({ transform: { define: { 'process.env.NODE_ENV': "'production'" } } })
|
|
1207
|
+
* ```
|
|
1208
|
+
*
|
|
1209
|
+
* Result:
|
|
1210
|
+
*
|
|
1211
|
+
* ```js
|
|
1212
|
+
* // Input
|
|
1213
|
+
* if (process.env.NODE_ENV === 'production') {
|
|
1214
|
+
* console.log('Production mode')
|
|
1215
|
+
* }
|
|
1216
|
+
*
|
|
1217
|
+
* // After bundling
|
|
1218
|
+
* if ('production' === 'production') {
|
|
1219
|
+
* console.log('Production mode')
|
|
1220
|
+
* }
|
|
1221
|
+
*
|
|
1222
|
+
* ```
|
|
1223
|
+
*/
|
|
1224
|
+
define?: Record<string, string>;
|
|
1225
|
+
/**
|
|
1226
|
+
* Inject import statements on demand.
|
|
1227
|
+
*
|
|
1228
|
+
* The API is aligned with `@rollup/plugin-inject`.
|
|
1229
|
+
*
|
|
1230
|
+
* ## Supported patterns
|
|
1231
|
+
* ```js
|
|
1232
|
+
* {
|
|
1233
|
+
* // import { Promise } from 'es6-promise'
|
|
1234
|
+
* Promise: ['es6-promise', 'Promise'],
|
|
1235
|
+
*
|
|
1236
|
+
* // import { Promise as P } from 'es6-promise'
|
|
1237
|
+
* P: ['es6-promise', 'Promise'],
|
|
1238
|
+
*
|
|
1239
|
+
* // import $ from 'jquery'
|
|
1240
|
+
* $: 'jquery',
|
|
1241
|
+
*
|
|
1242
|
+
* // import * as fs from 'node:fs'
|
|
1243
|
+
* fs: ['node:fs', '*'],
|
|
1244
|
+
*
|
|
1245
|
+
* // Inject shims for property access pattern
|
|
1246
|
+
* 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
|
|
1247
|
+
* }
|
|
1248
|
+
* ```
|
|
1249
|
+
*/
|
|
1250
|
+
inject?: Record<string, string | [string, string]>;
|
|
1251
|
+
/**
|
|
1252
|
+
* Remove labeled statements with these label names.
|
|
1253
|
+
*
|
|
1254
|
+
* Labeled statements are JavaScript statements prefixed with a label identifier.
|
|
1255
|
+
* This option allows you to strip specific labeled statements from the output,
|
|
1256
|
+
* which is useful for removing debug-only code in production builds.
|
|
1257
|
+
*
|
|
1258
|
+
* ## Example
|
|
1259
|
+
*
|
|
1260
|
+
* ```js rolldown.config.js
|
|
1261
|
+
* export default defineConfig({ transform: { dropLabels: ['DEBUG', 'DEV'] } })
|
|
1262
|
+
* ```
|
|
1263
|
+
*
|
|
1264
|
+
* Result:
|
|
1265
|
+
*
|
|
1266
|
+
* ```js
|
|
1267
|
+
* // Input
|
|
1268
|
+
* DEBUG: console.log('Debug info');
|
|
1269
|
+
* DEV: {
|
|
1270
|
+
* console.log('Development mode');
|
|
1271
|
+
* }
|
|
1272
|
+
* console.log('Production code');
|
|
1273
|
+
*
|
|
1274
|
+
* // After bundling
|
|
1275
|
+
* console.log('Production code');
|
|
1276
|
+
* ```
|
|
1277
|
+
*/
|
|
1278
|
+
dropLabels?: string[];
|
|
1279
|
+
jsx?: false | "react" | "react-jsx" | "preserve" | JsxOptions;
|
|
1280
|
+
}
|
|
1281
|
+
//#endregion
|
|
1147
1282
|
//#region src/options/input-options.d.ts
|
|
1148
1283
|
type InputOption = string | string[] | Record<string, string>;
|
|
1149
|
-
type
|
|
1150
|
-
type ExternalOption = StringOrRegExp | StringOrRegExp[] |
|
|
1284
|
+
type ExternalOptionFunction = (id: string, parentId: string | undefined, isResolved: boolean) => NullValue<boolean>;
|
|
1285
|
+
type ExternalOption = StringOrRegExp | StringOrRegExp[] | ExternalOptionFunction;
|
|
1151
1286
|
type ModuleTypes = Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | "css" | "asset">;
|
|
1152
1287
|
interface WatcherOptions {
|
|
1153
1288
|
skipWrite?: boolean;
|
|
@@ -1211,16 +1346,15 @@ type OptimizationOptions = {
|
|
|
1211
1346
|
mode?: "all" | "smart";
|
|
1212
1347
|
pass?: number;
|
|
1213
1348
|
};
|
|
1349
|
+
/**
|
|
1350
|
+
* Use PIFE pattern for module wrappers
|
|
1351
|
+
*/
|
|
1352
|
+
pifeForModuleWrappers?: boolean;
|
|
1214
1353
|
};
|
|
1215
1354
|
type AttachDebugOptions = "none" | "simple" | "full";
|
|
1216
1355
|
type ChunkModulesOrder = "exec-order" | "module-id";
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
factory?: string;
|
|
1220
|
-
fragment?: string;
|
|
1221
|
-
importSource?: string;
|
|
1222
|
-
jsxImportSource?: string;
|
|
1223
|
-
}
|
|
1356
|
+
type OnLogFunction = (level: LogLevel, log: RollupLog, defaultHandler: LogOrStringHandler) => void;
|
|
1357
|
+
type OnwarnFunction = (warning: RollupLog, defaultHandler: (warning: RollupLogWithString | (() => RollupLogWithString)) => void) => void;
|
|
1224
1358
|
interface InputOptions {
|
|
1225
1359
|
input?: InputOption;
|
|
1226
1360
|
plugins?: RolldownPluginOption;
|
|
@@ -1270,8 +1404,8 @@ interface InputOptions {
|
|
|
1270
1404
|
shimMissingExports?: boolean;
|
|
1271
1405
|
treeshake?: boolean | TreeshakingOptions;
|
|
1272
1406
|
logLevel?: LogLevelOption;
|
|
1273
|
-
onLog?:
|
|
1274
|
-
onwarn?:
|
|
1407
|
+
onLog?: OnLogFunction;
|
|
1408
|
+
onwarn?: OnwarnFunction;
|
|
1275
1409
|
moduleTypes?: ModuleTypes;
|
|
1276
1410
|
experimental?: {
|
|
1277
1411
|
/**
|
|
@@ -1379,97 +1513,67 @@ interface InputOptions {
|
|
|
1379
1513
|
* - Type: `boolean`
|
|
1380
1514
|
* - Default: `false`
|
|
1381
1515
|
*
|
|
1382
|
-
*
|
|
1383
|
-
* for
|
|
1516
|
+
* [MagicString](https://github.com/rich-harris/magic-string) is a JavaScript library commonly used by bundlers
|
|
1517
|
+
* for string manipulation and source map generation. When enabled, rolldown will use a native Rust
|
|
1518
|
+
* implementation of MagicString instead of the JavaScript version, providing significantly better performance
|
|
1519
|
+
* during source map generation and code transformation.
|
|
1520
|
+
*
|
|
1521
|
+
* ## Benefits
|
|
1522
|
+
*
|
|
1523
|
+
* - **Improved Performance**: The native Rust implementation is typically faster than the JavaScript version,
|
|
1524
|
+
* especially for large codebases with extensive source maps.
|
|
1525
|
+
* - **Background Processing**: Source map generation is performed asynchronously in a background thread,
|
|
1526
|
+
* allowing the main bundling process to continue without blocking. This parallel processing can significantly
|
|
1527
|
+
* reduce overall build times when working with JavaScript transform hooks.
|
|
1528
|
+
* - **Better Integration**: Seamless integration with rolldown's native Rust architecture.
|
|
1529
|
+
*
|
|
1530
|
+
* ## Example
|
|
1531
|
+
*
|
|
1532
|
+
* ```js
|
|
1533
|
+
* export default {
|
|
1534
|
+
* experimental: {
|
|
1535
|
+
* nativeMagicString: true
|
|
1536
|
+
* },
|
|
1537
|
+
* output: {
|
|
1538
|
+
* sourcemap: true
|
|
1539
|
+
* }
|
|
1540
|
+
* }
|
|
1541
|
+
* ```
|
|
1542
|
+
*
|
|
1543
|
+
* > [!NOTE]
|
|
1544
|
+
* > This is an experimental feature. While it aims to provide identical behavior to the JavaScript
|
|
1545
|
+
* > implementation, there may be edge cases. Please report any discrepancies you encounter.
|
|
1546
|
+
* > For a complete working example, see [examples/native-magic-string](https://github.com/rolldown/rolldown/tree/main/examples/native-magic-string)
|
|
1384
1547
|
*/
|
|
1385
1548
|
nativeMagicString?: boolean;
|
|
1386
1549
|
};
|
|
1387
1550
|
/**
|
|
1388
1551
|
* Replace global variables or [property accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors) with the provided values.
|
|
1389
1552
|
*
|
|
1390
|
-
*
|
|
1391
|
-
*
|
|
1392
|
-
* - Replace the global variable `IS_PROD` with `true`
|
|
1393
|
-
*
|
|
1394
|
-
* ```js rolldown.config.js
|
|
1395
|
-
* export default defineConfig({ define: { IS_PROD: 'true' // or JSON.stringify(true) } })
|
|
1396
|
-
* ```
|
|
1397
|
-
*
|
|
1398
|
-
* Result:
|
|
1553
|
+
* @deprecated Use `transform.define` instead. This top-level option will be removed in a future release.
|
|
1399
1554
|
*
|
|
1400
|
-
*
|
|
1401
|
-
* // Input
|
|
1402
|
-
* if (IS_PROD) {
|
|
1403
|
-
* console.log('Production mode')
|
|
1404
|
-
* }
|
|
1405
|
-
*
|
|
1406
|
-
* // After bundling
|
|
1407
|
-
* if (true) {
|
|
1408
|
-
* console.log('Production mode')
|
|
1409
|
-
* }
|
|
1410
|
-
* ```
|
|
1411
|
-
*
|
|
1412
|
-
* - Replace the property accessor `process.env.NODE_ENV` with `'production'`
|
|
1413
|
-
*
|
|
1414
|
-
* ```js rolldown.config.js
|
|
1415
|
-
* export default defineConfig({ define: { 'process.env.NODE_ENV': "'production'" } })
|
|
1416
|
-
* ```
|
|
1417
|
-
*
|
|
1418
|
-
* Result:
|
|
1419
|
-
*
|
|
1420
|
-
* ```js
|
|
1421
|
-
* // Input
|
|
1422
|
-
* if (process.env.NODE_ENV === 'production') {
|
|
1423
|
-
* console.log('Production mode')
|
|
1424
|
-
* }
|
|
1425
|
-
*
|
|
1426
|
-
* // After bundling
|
|
1427
|
-
* if ('production' === 'production') {
|
|
1428
|
-
* console.log('Production mode')
|
|
1429
|
-
* }
|
|
1430
|
-
*
|
|
1431
|
-
* ```
|
|
1555
|
+
* See `transform.define` for detailed documentation and examples.
|
|
1432
1556
|
*/
|
|
1433
1557
|
define?: Record<string, string>;
|
|
1434
1558
|
/**
|
|
1435
1559
|
* Inject import statements on demand.
|
|
1436
1560
|
*
|
|
1437
|
-
*
|
|
1438
|
-
* ```js
|
|
1439
|
-
* {
|
|
1440
|
-
* // import { Promise } from 'es6-promise'
|
|
1441
|
-
* Promise: ['es6-promise', 'Promise'],
|
|
1442
|
-
*
|
|
1443
|
-
* // import { Promise as P } from 'es6-promise'
|
|
1444
|
-
* P: ['es6-promise', 'Promise'],
|
|
1445
|
-
*
|
|
1446
|
-
* // import $ from 'jquery'
|
|
1447
|
-
* $: 'jquery',
|
|
1448
|
-
*
|
|
1449
|
-
* // import * as fs from 'node:fs'
|
|
1450
|
-
* fs: ['node:fs', '*'],
|
|
1561
|
+
* @deprecated Use `transform.inject` instead. This top-level option will be removed in a future release.
|
|
1451
1562
|
*
|
|
1452
|
-
*
|
|
1453
|
-
* 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
|
|
1454
|
-
* }
|
|
1455
|
-
* ```
|
|
1563
|
+
* See `transform.inject` for detailed documentation and examples.
|
|
1456
1564
|
*/
|
|
1457
1565
|
inject?: Record<string, string | [string, string]>;
|
|
1458
|
-
profilerNames?: boolean;
|
|
1459
1566
|
/**
|
|
1460
|
-
*
|
|
1567
|
+
* Whether to add readable names to internal variables for profiling purposes.
|
|
1461
1568
|
*
|
|
1462
|
-
*
|
|
1463
|
-
*
|
|
1569
|
+
* When enabled, generated code will use descriptive variable names that correspond
|
|
1570
|
+
* to the original module names, making it easier to profile and debug the bundled code.
|
|
1464
1571
|
*
|
|
1465
|
-
*
|
|
1466
|
-
* - `"preserve"` disables the JSX transformer, preserving the original JSX syntax in the output.
|
|
1467
|
-
* - `"react"` enables the `classic` JSX transformer.
|
|
1468
|
-
* - `"react-jsx"` enables the `automatic` JSX transformer.
|
|
1572
|
+
* @default true when minification is disabled, false when minification is enabled
|
|
1469
1573
|
*
|
|
1470
|
-
* @
|
|
1574
|
+
* @deprecated Use `output.generatedCode.profilerNames` instead. This top-level option will be removed in a future release.
|
|
1471
1575
|
*/
|
|
1472
|
-
|
|
1576
|
+
profilerNames?: boolean;
|
|
1473
1577
|
/**
|
|
1474
1578
|
* Configure how the code is transformed. This process happens after the `transform` hook.
|
|
1475
1579
|
*
|
|
@@ -1487,9 +1591,23 @@ interface InputOptions {
|
|
|
1487
1591
|
*
|
|
1488
1592
|
* For latest decorators proposal, rolldown is able to bundle them but doesn't support transpiling them yet.
|
|
1489
1593
|
*/
|
|
1490
|
-
transform?:
|
|
1594
|
+
transform?: TransformOptions;
|
|
1491
1595
|
watch?: WatcherOptions | false;
|
|
1596
|
+
/**
|
|
1597
|
+
* Remove labeled statements with these label names.
|
|
1598
|
+
*
|
|
1599
|
+
* @deprecated Use `transform.dropLabels` instead. This top-level option will be removed in a future release.
|
|
1600
|
+
*
|
|
1601
|
+
* See `transform.dropLabels` for detailed documentation and examples.
|
|
1602
|
+
*/
|
|
1492
1603
|
dropLabels?: string[];
|
|
1604
|
+
/**
|
|
1605
|
+
* Keep function and class names after bundling.
|
|
1606
|
+
*
|
|
1607
|
+
* @deprecated Use `output.keepNames` instead. This top-level option will be removed in a future release.
|
|
1608
|
+
*
|
|
1609
|
+
* See `output.keepNames` for detailed documentation.
|
|
1610
|
+
*/
|
|
1493
1611
|
keepNames?: boolean;
|
|
1494
1612
|
checks?: ChecksOptions;
|
|
1495
1613
|
makeAbsoluteExternalsRelative?: MakeAbsoluteExternalsRelative;
|
|
@@ -1529,4 +1647,4 @@ declare function defineConfig(config: RolldownOptions[]): RolldownOptions[];
|
|
|
1529
1647
|
declare function defineConfig(config: RolldownOptionsFunction): RolldownOptionsFunction;
|
|
1530
1648
|
declare function defineConfig(config: ConfigExport): ConfigExport;
|
|
1531
1649
|
//#endregion
|
|
1532
|
-
export {
|
|
1650
|
+
export { InternalModuleFormat as $, BuiltinPlugin as A, SourceMap as At, GetModuleInfo as B, ResolveIdResult as C, PartialNull as Ct, SourceDescription as D, RenderedChunk as Dt, RolldownPluginOption as E, OutputChunk as Et, OutputBundle as F, LogOrStringHandler as Ft, PluginContextMeta as G, DefineParallelPluginResult as H, TreeshakingOptions as I, RollupError as It, ModuleTypeFilter as J, GeneralHookFilter as K, TransformPluginContext as L, RollupLog as Lt, ExistingRawSourceMap as M, SourcemapIgnoreListOption as Mt, SourceMapInput as N, LogLevel as Nt, TransformResult as O, RenderedModule as Ot, RolldownOptionsFunction as P, LogLevelOption as Pt, RolldownFsModule as Q, EmittedAsset as R, RollupLogWithString as Rt, ResolveIdExtraOptions as S, MaybePromise as St, RolldownPlugin as T, OutputAsset as Tt, defineParallelPlugin as U, PluginContext as V, MinimalPluginContext as W, RolldownDirectoryEntry as X, BufferEncoding as Y, RolldownFileStats as Z, ModuleType as _, GlobalsFunction as _t, InputOption as a, RolldownWatcher as at, PartialResolvedId as b, OutputOptions as bt, OptimizationOptions as c, rolldown as ct, CustomPluginOptions as d, build as dt, NormalizedOutputOptions as et, FunctionPluginHooks as f, AddonFunction as ft, ModuleOptions as g, GeneratedCodePreset as gt, LoadResult as h, GeneratedCodeOptions as ht, ExternalOption as i, watch as it, VERSION as j, ModuleInfo as jt, withFilter as k, RolldownOutput as kt, WatcherOptions as l, RolldownBuild as lt, ImportKind as m, ChunkingContext as mt, ConfigExport as n, LoggingFunction as nt, InputOptions as o, RolldownWatcherEvent as ot, HookFilterExtension as p, ChunkFileNamesFunction as pt, HookFilter as q, RolldownOptions as r, WarningHandlerWithDefault as rt, ModuleTypes as s, WatchOptions as st, defineConfig as t, NormalizedInputOptions as tt, AsyncPluginHooks as u, BuildOptions as ut, ObjectHook as v, MinifyOptions as vt, ResolvedId as w, StringOrRegExp as wt, Plugin as x, PreRenderedAsset as xt, ParallelPluginHooks as y, ModuleFormat as yt, EmittedFile as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { rolldown } from "./src-
|
|
1
|
+
import { o as rolldown } from "./src-B4ZmdjD5.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { readdir } from "node:fs/promises";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
@@ -14,13 +14,13 @@ async function bundleTsConfig(configFile, isEsm) {
|
|
|
14
14
|
input: configFile,
|
|
15
15
|
platform: "node",
|
|
16
16
|
resolve: { mainFields: ["main"] },
|
|
17
|
-
define: {
|
|
17
|
+
transform: { define: {
|
|
18
18
|
__dirname: dirnameVarName,
|
|
19
19
|
__filename: filenameVarName,
|
|
20
20
|
"import.meta.url": importMetaUrlVarName,
|
|
21
21
|
"import.meta.dirname": dirnameVarName,
|
|
22
22
|
"import.meta.filename": filenameVarName
|
|
23
|
-
},
|
|
23
|
+
} },
|
|
24
24
|
treeshake: false,
|
|
25
25
|
external: [/^[\w@][^:]/],
|
|
26
26
|
plugins: [{
|
|
@@ -111,4 +111,4 @@ async function loadConfig(configPath) {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
//#endregion
|
|
114
|
-
export { loadConfig };
|
|
114
|
+
export { loadConfig as t };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parseAsync, parseSync } from "../rolldown-binding.wasi.cjs";
|
|
2
|
+
import { styleText } from "node:util";
|
|
2
3
|
|
|
3
4
|
//#region src/utils/code-frame.ts
|
|
4
5
|
function spaces(index) {
|
|
@@ -38,6 +39,12 @@ function getCodeFrame(source, line, column) {
|
|
|
38
39
|
}).join("\n");
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/utils/style-text.ts
|
|
44
|
+
function styleText$1(...args) {
|
|
45
|
+
return styleText(...args);
|
|
46
|
+
}
|
|
47
|
+
|
|
41
48
|
//#endregion
|
|
42
49
|
//#region src/log/locate-character/index.js
|
|
43
50
|
/** @typedef {import('./types').Location} Location */
|
|
@@ -101,7 +108,7 @@ function locate(source, search, options) {
|
|
|
101
108
|
|
|
102
109
|
//#endregion
|
|
103
110
|
//#region src/log/logs.ts
|
|
104
|
-
const INVALID_LOG_POSITION = "INVALID_LOG_POSITION", PLUGIN_ERROR = "PLUGIN_ERROR", INPUT_HOOK_IN_OUTPUT_PLUGIN = "INPUT_HOOK_IN_OUTPUT_PLUGIN", CYCLE_LOADING = "CYCLE_LOADING", MULTIPLY_NOTIFY_OPTION = "MULTIPLY_NOTIFY_OPTION", PARSE_ERROR = "PARSE_ERROR",
|
|
111
|
+
const INVALID_LOG_POSITION = "INVALID_LOG_POSITION", PLUGIN_ERROR = "PLUGIN_ERROR", INPUT_HOOK_IN_OUTPUT_PLUGIN = "INPUT_HOOK_IN_OUTPUT_PLUGIN", CYCLE_LOADING = "CYCLE_LOADING", MULTIPLY_NOTIFY_OPTION = "MULTIPLY_NOTIFY_OPTION", PARSE_ERROR = "PARSE_ERROR", NO_FS_IN_BROWSER = "NO_FS_IN_BROWSER", DEPRECATED_DEFINE = "DEPRECATED_DEFINE", DEPRECATED_INJECT = "DEPRECATED_INJECT", DEPRECATED_PROFILER_NAMES = "DEPRECATED_PROFILER_NAMES", DEPRECATED_KEEP_NAMES = "DEPRECATED_KEEP_NAMES", DEPRECATED_DROP_LABELS = "DEPRECATED_DROP_LABELS";
|
|
105
112
|
function logParseError(message) {
|
|
106
113
|
return {
|
|
107
114
|
code: PARSE_ERROR,
|
|
@@ -132,10 +139,34 @@ function logMultiplyNotifyOption() {
|
|
|
132
139
|
message: `Found multiply notify option at watch options, using first one to start notify watcher.`
|
|
133
140
|
};
|
|
134
141
|
}
|
|
135
|
-
function
|
|
142
|
+
function logDeprecatedDefine() {
|
|
143
|
+
return {
|
|
144
|
+
code: DEPRECATED_DEFINE,
|
|
145
|
+
message: `${styleText$1(["yellow", "bold"], "⚠ Deprecation Warning:")} The top-level "define" option is deprecated. Use "transform.define" instead.`
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function logDeprecatedInject() {
|
|
149
|
+
return {
|
|
150
|
+
code: DEPRECATED_INJECT,
|
|
151
|
+
message: `${styleText$1(["yellow", "bold"], "⚠ Deprecation Warning:")} The top-level "inject" option is deprecated. Use "transform.inject" instead.`
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
function logDeprecatedProfilerNames() {
|
|
155
|
+
return {
|
|
156
|
+
code: DEPRECATED_PROFILER_NAMES,
|
|
157
|
+
message: "The top-level \"profilerNames\" option is deprecated. Use \"output.generatedCode.profilerNames\" instead."
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function logDeprecatedKeepNames() {
|
|
161
|
+
return {
|
|
162
|
+
code: DEPRECATED_KEEP_NAMES,
|
|
163
|
+
message: "The top-level \"keepNames\" option is deprecated. Use \"output.keepNames\" instead."
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function logDeprecatedDropLabels() {
|
|
136
167
|
return {
|
|
137
|
-
code:
|
|
138
|
-
message: "
|
|
168
|
+
code: DEPRECATED_DROP_LABELS,
|
|
169
|
+
message: `${styleText$1(["yellow", "bold"], "⚠ Deprecation Warning:")} The top-level "dropLabels" option is deprecated. Use "transform.dropLabels" instead.`
|
|
139
170
|
};
|
|
140
171
|
}
|
|
141
172
|
function logPluginError(error$1, plugin, { hook, id } = {}) {
|
|
@@ -186,7 +217,7 @@ function augmentCodeLocation(properties, pos, source, id) {
|
|
|
186
217
|
}
|
|
187
218
|
|
|
188
219
|
//#endregion
|
|
189
|
-
//#region ../../node_modules/.pnpm/oxc-parser@0.
|
|
220
|
+
//#region ../../node_modules/.pnpm/oxc-parser@0.95.0/node_modules/oxc-parser/src-js/wrap.js
|
|
190
221
|
function wrap$1(result) {
|
|
191
222
|
let program, module, comments, errors;
|
|
192
223
|
return {
|
|
@@ -263,4 +294,4 @@ async function parseAstAsync(sourceText, options, filename) {
|
|
|
263
294
|
}
|
|
264
295
|
|
|
265
296
|
//#endregion
|
|
266
|
-
export {
|
|
297
|
+
export { logCycleLoading as a, logDeprecatedInject as c, logInputHookInOutputPlugin as d, logInvalidLogPosition as f, styleText$1 as h, error as i, logDeprecatedKeepNames as l, logPluginError as m, parseAstAsync as n, logDeprecatedDefine as o, logMultiplyNotifyOption as p, augmentCodeLocation as r, logDeprecatedDropLabels as s, parseAst as t, logDeprecatedProfilerNames as u };
|