@rolldown/browser 1.0.0-beta.42 → 1.0.0-beta.44
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 +1046 -67
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +4 -4
- package/dist/experimental-index.browser.mjs +51 -453
- package/dist/experimental-index.d.mts +26 -5
- package/dist/experimental-index.mjs +56 -16
- package/dist/filter-index.d.mts +2 -2
- package/dist/filter-index.mjs +1 -1
- package/dist/index.browser.mjs +2 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +4 -4
- package/dist/parallel-plugin-worker.mjs +3 -3
- package/dist/parallel-plugin.d.mts +2 -2
- package/dist/parse-ast-index.d.mts +1 -1
- package/dist/parse-ast-index.mjs +1 -1
- package/dist/rolldown-binding.wasi-browser.js +2 -3
- package/dist/rolldown-binding.wasi.cjs +2 -3
- package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
- package/dist/shared/{binding-CtbNz6TD.d.mts → binding-0m41EAn-.d.mts} +108 -17
- package/dist/shared/{define-config-xBdWOg15.d.mts → define-config-BbwLmCDX.d.mts} +250 -87
- package/dist/shared/{dist-CU0dSkK2.mjs → dist-DNFKY37q.mjs} +1 -1
- package/dist/shared/{load-config-B4-CoeU7.mjs → load-config-B3FsKQ_6.mjs} +2 -2
- 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-DbG0hppv.mjs → src-BnIhK3nA.mjs} +234 -328
- package/dist/{src-D_rsgcbb.js → src-CIeG_TGR.js} +506 -570
- 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-0m41EAn-.mjs";
|
|
2
2
|
import { Program } from "@oxc-project/types";
|
|
3
3
|
import { TopLevelFilterExpression } from "@rolldown/pluginutils";
|
|
4
4
|
|
|
@@ -159,6 +159,15 @@ 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>;
|
|
@@ -253,6 +262,37 @@ interface OutputOptions {
|
|
|
253
262
|
minify?: boolean | "dce-only" | MinifyOptions;
|
|
254
263
|
name?: string;
|
|
255
264
|
globals?: Record<string, string> | GlobalsFunction;
|
|
265
|
+
/**
|
|
266
|
+
* Maps external module IDs to paths.
|
|
267
|
+
*
|
|
268
|
+
* Allows customizing the path used when importing external dependencies.
|
|
269
|
+
* This is particularly useful for loading dependencies from CDNs or custom locations.
|
|
270
|
+
*
|
|
271
|
+
* - Object form: Maps module IDs to their replacement paths
|
|
272
|
+
* - Function form: Takes a module ID and returns its replacement path
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```js
|
|
276
|
+
* {
|
|
277
|
+
* paths: {
|
|
278
|
+
* 'd3': 'https://cdn.jsdelivr.net/npm/d3@7'
|
|
279
|
+
* }
|
|
280
|
+
* }
|
|
281
|
+
* ```
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```js
|
|
285
|
+
* {
|
|
286
|
+
* paths: (id) => {
|
|
287
|
+
* if (id.startsWith('lodash')) {
|
|
288
|
+
* return `https://cdn.jsdelivr.net/npm/${id}`
|
|
289
|
+
* }
|
|
290
|
+
* return id
|
|
291
|
+
* }
|
|
292
|
+
* }
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
paths?: Record<string, string> | ((id: string) => string);
|
|
256
296
|
generatedCode?: Partial<GeneratedCodeOptions>;
|
|
257
297
|
externalLiveBindings?: boolean;
|
|
258
298
|
inlineDynamicImports?: boolean;
|
|
@@ -314,7 +354,7 @@ interface OutputOptions {
|
|
|
314
354
|
* By default, each group will also include captured modules' dependencies. This reduces the chance of generating circular chunks.
|
|
315
355
|
*
|
|
316
356
|
* If you want to disable this behavior, it's recommended to both set
|
|
317
|
-
* - `preserveEntrySignatures: false`
|
|
357
|
+
* - `preserveEntrySignatures: false | 'allow-extension'`
|
|
318
358
|
* - `strictExecutionOrder: true`
|
|
319
359
|
*
|
|
320
360
|
* to avoid generating invalid chunks.
|
|
@@ -510,11 +550,26 @@ interface OutputOptions {
|
|
|
510
550
|
topLevelVar?: boolean;
|
|
511
551
|
/**
|
|
512
552
|
* - Type: `boolean`
|
|
513
|
-
* - Default: `false`
|
|
553
|
+
* - Default: `true` for format `es` or if `output.minify` is `true` or object, `false` otherwise
|
|
514
554
|
*
|
|
515
555
|
* Whether to minify internal exports.
|
|
516
556
|
*/
|
|
517
557
|
minifyInternalExports?: boolean;
|
|
558
|
+
/**
|
|
559
|
+
* - Type: `boolean`
|
|
560
|
+
* - Default: `false`
|
|
561
|
+
*
|
|
562
|
+
* Clean output directory before emitting output.
|
|
563
|
+
*/
|
|
564
|
+
cleanDir?: boolean;
|
|
565
|
+
/** Keep function and class names after bundling.
|
|
566
|
+
*
|
|
567
|
+
* When enabled, the bundler will preserve the original names of functions and classes
|
|
568
|
+
* in the output, which is useful for debugging and error stack traces.
|
|
569
|
+
*
|
|
570
|
+
* @default false
|
|
571
|
+
*/
|
|
572
|
+
keepNames?: boolean;
|
|
518
573
|
}
|
|
519
574
|
//#endregion
|
|
520
575
|
//#region src/api/build.d.ts
|
|
@@ -612,6 +667,7 @@ interface NormalizedInputOptions {
|
|
|
612
667
|
}
|
|
613
668
|
//#endregion
|
|
614
669
|
//#region src/options/normalized-output-options.d.ts
|
|
670
|
+
type PathsFunction = (id: string) => string;
|
|
615
671
|
type InternalModuleFormat = "es" | "cjs" | "iife" | "umd";
|
|
616
672
|
interface NormalizedOutputOptions {
|
|
617
673
|
name: string | undefined;
|
|
@@ -635,6 +691,7 @@ interface NormalizedOutputOptions {
|
|
|
635
691
|
esModule: boolean | "if-default-prop";
|
|
636
692
|
extend: boolean;
|
|
637
693
|
globals: Record<string, string> | GlobalsFunction;
|
|
694
|
+
paths: Record<string, string> | PathsFunction | undefined;
|
|
638
695
|
hashCharacters: "base64" | "base36" | "hex";
|
|
639
696
|
sourcemapDebugIds: boolean;
|
|
640
697
|
sourcemapIgnoreList: boolean | SourcemapIgnoreListOption | StringOrRegExp | undefined;
|
|
@@ -952,7 +1009,9 @@ interface ResolveIdExtraOptions {
|
|
|
952
1009
|
}
|
|
953
1010
|
type ResolveIdResult = string | NullValue | false | PartialResolvedId;
|
|
954
1011
|
type LoadResult = NullValue | string | SourceDescription;
|
|
955
|
-
type TransformResult = NullValue | string |
|
|
1012
|
+
type TransformResult = NullValue | string | Omit<SourceDescription, "code"> & {
|
|
1013
|
+
code?: string | BindingMagicString;
|
|
1014
|
+
};
|
|
956
1015
|
type RenderedChunkMeta = {
|
|
957
1016
|
chunks: Record<string, RenderedChunk>;
|
|
958
1017
|
};
|
|
@@ -970,6 +1029,7 @@ interface FunctionPluginHooks {
|
|
|
970
1029
|
[DEFINED_HOOK_NAMES.load]: (this: PluginContext, id: string) => MaybePromise<LoadResult>;
|
|
971
1030
|
[DEFINED_HOOK_NAMES.transform]: (this: TransformPluginContext, code: string, id: string, meta: BindingTransformHookExtraArgs & {
|
|
972
1031
|
moduleType: ModuleType;
|
|
1032
|
+
magicString?: BindingMagicString;
|
|
973
1033
|
}) => TransformResult;
|
|
974
1034
|
[DEFINED_HOOK_NAMES.moduleParsed]: (this: PluginContext, moduleInfo: ModuleInfo) => void;
|
|
975
1035
|
[DEFINED_HOOK_NAMES.buildEnd]: (this: PluginContext, err?: Error) => void;
|
|
@@ -1003,15 +1063,15 @@ type SequentialPluginHooks = DefinedHookNames["augmentChunkHash" | "generateBund
|
|
|
1003
1063
|
type AddonHooks = DefinedHookNames["banner" | "footer" | "intro" | "outro"];
|
|
1004
1064
|
type OutputPluginHooks = DefinedHookNames["augmentChunkHash" | "generateBundle" | "outputOptions" | "renderChunk" | "renderError" | "renderStart" | "writeBundle"];
|
|
1005
1065
|
type ParallelPluginHooks = Exclude<keyof FunctionPluginHooks | AddonHooks, FirstPluginHooks | SequentialPluginHooks>;
|
|
1006
|
-
type HookFilterExtension<K extends keyof FunctionPluginHooks> = K extends "transform" ? {
|
|
1066
|
+
type HookFilterExtension<K$1 extends keyof FunctionPluginHooks> = K$1 extends "transform" ? {
|
|
1007
1067
|
filter?: TUnionWithTopLevelFilterExpressionArray<HookFilter>;
|
|
1008
|
-
} : K extends "load" ? {
|
|
1068
|
+
} : K$1 extends "load" ? {
|
|
1009
1069
|
filter?: TUnionWithTopLevelFilterExpressionArray<Pick<HookFilter, "id">>;
|
|
1010
|
-
} : K extends "resolveId" ? {
|
|
1070
|
+
} : K$1 extends "resolveId" ? {
|
|
1011
1071
|
filter?: TUnionWithTopLevelFilterExpressionArray<{
|
|
1012
1072
|
id?: GeneralHookFilter<RegExp>;
|
|
1013
1073
|
}>;
|
|
1014
|
-
} : K extends "renderChunk" ? {
|
|
1074
|
+
} : K$1 extends "renderChunk" ? {
|
|
1015
1075
|
filter?: TUnionWithTopLevelFilterExpressionArray<Pick<HookFilter, "code">>;
|
|
1016
1076
|
} : {};
|
|
1017
1077
|
type PluginHooks = { [K in keyof FunctionPluginHooks]: ObjectHook<K extends AsyncPluginHooks ? MakeAsync<FunctionPluginHooks[K]> : FunctionPluginHooks[K], HookFilterExtension<K> & (K extends ParallelPluginHooks ? {
|
|
@@ -1108,9 +1168,114 @@ interface ChecksOptions {
|
|
|
1108
1168
|
preferBuiltinFeature?: boolean;
|
|
1109
1169
|
}
|
|
1110
1170
|
//#endregion
|
|
1171
|
+
//#region src/options/transform-options.d.ts
|
|
1172
|
+
interface TransformOptions extends Omit<TransformOptions$1, "sourceType" | "lang" | "cwd" | "sourcemap" | "define" | "inject" | "jsx"> {
|
|
1173
|
+
/**
|
|
1174
|
+
* Replace global variables or [property accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors) with the provided values.
|
|
1175
|
+
*
|
|
1176
|
+
* # Examples
|
|
1177
|
+
*
|
|
1178
|
+
* - Replace the global variable `IS_PROD` with `true`
|
|
1179
|
+
*
|
|
1180
|
+
* ```js rolldown.config.js
|
|
1181
|
+
* export default defineConfig({ transform: { define: { IS_PROD: 'true' } } })
|
|
1182
|
+
* ```
|
|
1183
|
+
*
|
|
1184
|
+
* Result:
|
|
1185
|
+
*
|
|
1186
|
+
* ```js
|
|
1187
|
+
* // Input
|
|
1188
|
+
* if (IS_PROD) {
|
|
1189
|
+
* console.log('Production mode')
|
|
1190
|
+
* }
|
|
1191
|
+
*
|
|
1192
|
+
* // After bundling
|
|
1193
|
+
* if (true) {
|
|
1194
|
+
* console.log('Production mode')
|
|
1195
|
+
* }
|
|
1196
|
+
* ```
|
|
1197
|
+
*
|
|
1198
|
+
* - Replace the property accessor `process.env.NODE_ENV` with `'production'`
|
|
1199
|
+
*
|
|
1200
|
+
* ```js rolldown.config.js
|
|
1201
|
+
* export default defineConfig({ transform: { define: { 'process.env.NODE_ENV': "'production'" } } })
|
|
1202
|
+
* ```
|
|
1203
|
+
*
|
|
1204
|
+
* Result:
|
|
1205
|
+
*
|
|
1206
|
+
* ```js
|
|
1207
|
+
* // Input
|
|
1208
|
+
* if (process.env.NODE_ENV === 'production') {
|
|
1209
|
+
* console.log('Production mode')
|
|
1210
|
+
* }
|
|
1211
|
+
*
|
|
1212
|
+
* // After bundling
|
|
1213
|
+
* if ('production' === 'production') {
|
|
1214
|
+
* console.log('Production mode')
|
|
1215
|
+
* }
|
|
1216
|
+
*
|
|
1217
|
+
* ```
|
|
1218
|
+
*/
|
|
1219
|
+
define?: Record<string, string>;
|
|
1220
|
+
/**
|
|
1221
|
+
* Inject import statements on demand.
|
|
1222
|
+
*
|
|
1223
|
+
* The API is aligned with `@rollup/plugin-inject`.
|
|
1224
|
+
*
|
|
1225
|
+
* ## Supported patterns
|
|
1226
|
+
* ```js
|
|
1227
|
+
* {
|
|
1228
|
+
* // import { Promise } from 'es6-promise'
|
|
1229
|
+
* Promise: ['es6-promise', 'Promise'],
|
|
1230
|
+
*
|
|
1231
|
+
* // import { Promise as P } from 'es6-promise'
|
|
1232
|
+
* P: ['es6-promise', 'Promise'],
|
|
1233
|
+
*
|
|
1234
|
+
* // import $ from 'jquery'
|
|
1235
|
+
* $: 'jquery',
|
|
1236
|
+
*
|
|
1237
|
+
* // import * as fs from 'node:fs'
|
|
1238
|
+
* fs: ['node:fs', '*'],
|
|
1239
|
+
*
|
|
1240
|
+
* // Inject shims for property access pattern
|
|
1241
|
+
* 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
|
|
1242
|
+
* }
|
|
1243
|
+
* ```
|
|
1244
|
+
*/
|
|
1245
|
+
inject?: Record<string, string | [string, string]>;
|
|
1246
|
+
/**
|
|
1247
|
+
* Remove labeled statements with these label names.
|
|
1248
|
+
*
|
|
1249
|
+
* Labeled statements are JavaScript statements prefixed with a label identifier.
|
|
1250
|
+
* This option allows you to strip specific labeled statements from the output,
|
|
1251
|
+
* which is useful for removing debug-only code in production builds.
|
|
1252
|
+
*
|
|
1253
|
+
* ## Example
|
|
1254
|
+
*
|
|
1255
|
+
* ```js rolldown.config.js
|
|
1256
|
+
* export default defineConfig({ transform: { dropLabels: ['DEBUG', 'DEV'] } })
|
|
1257
|
+
* ```
|
|
1258
|
+
*
|
|
1259
|
+
* Result:
|
|
1260
|
+
*
|
|
1261
|
+
* ```js
|
|
1262
|
+
* // Input
|
|
1263
|
+
* DEBUG: console.log('Debug info');
|
|
1264
|
+
* DEV: {
|
|
1265
|
+
* console.log('Development mode');
|
|
1266
|
+
* }
|
|
1267
|
+
* console.log('Production code');
|
|
1268
|
+
*
|
|
1269
|
+
* // After bundling
|
|
1270
|
+
* console.log('Production code');
|
|
1271
|
+
* ```
|
|
1272
|
+
*/
|
|
1273
|
+
dropLabels?: string[];
|
|
1274
|
+
jsx?: false | "react" | "react-jsx" | "preserve" | JsxOptions;
|
|
1275
|
+
}
|
|
1276
|
+
//#endregion
|
|
1111
1277
|
//#region src/options/input-options.d.ts
|
|
1112
1278
|
type InputOption = string | string[] | Record<string, string>;
|
|
1113
|
-
type OxcTransformOption = Omit<TransformOptions, "sourceType" | "lang" | "cwd" | "sourcemap" | "define" | "inject">;
|
|
1114
1279
|
type ExternalOption = StringOrRegExp | StringOrRegExp[] | ((id: string, parentId: string | undefined, isResolved: boolean) => NullValue<boolean>);
|
|
1115
1280
|
type ModuleTypes = Record<string, "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | "css" | "asset">;
|
|
1116
1281
|
interface WatcherOptions {
|
|
@@ -1178,13 +1343,6 @@ type OptimizationOptions = {
|
|
|
1178
1343
|
};
|
|
1179
1344
|
type AttachDebugOptions = "none" | "simple" | "full";
|
|
1180
1345
|
type ChunkModulesOrder = "exec-order" | "module-id";
|
|
1181
|
-
interface RollupJsxOptions {
|
|
1182
|
-
mode?: "classic" | "automatic" | "preserve";
|
|
1183
|
-
factory?: string;
|
|
1184
|
-
fragment?: string;
|
|
1185
|
-
importSource?: string;
|
|
1186
|
-
jsxImportSource?: string;
|
|
1187
|
-
}
|
|
1188
1346
|
interface InputOptions {
|
|
1189
1347
|
input?: InputOption;
|
|
1190
1348
|
plugins?: RolldownPluginOption;
|
|
@@ -1238,6 +1396,17 @@ interface InputOptions {
|
|
|
1238
1396
|
onwarn?: (warning: RollupLog, defaultHandler: (warning: RollupLogWithString | (() => RollupLogWithString)) => void) => void;
|
|
1239
1397
|
moduleTypes?: ModuleTypes;
|
|
1240
1398
|
experimental?: {
|
|
1399
|
+
/**
|
|
1400
|
+
* Lets modules be executed in the order they are declared.
|
|
1401
|
+
*
|
|
1402
|
+
* - Type: `boolean`
|
|
1403
|
+
* - Default: `false`
|
|
1404
|
+
*
|
|
1405
|
+
* This is done by injecting runtime helpers to ensure that modules are executed in the order they are imported. External modules won't be affected.
|
|
1406
|
+
*
|
|
1407
|
+
* > [!WARNING]
|
|
1408
|
+
* > Enabling this option may negatively increase bundle size. It is recommended to use this option only when absolutely necessary.
|
|
1409
|
+
*/
|
|
1241
1410
|
strictExecutionOrder?: boolean;
|
|
1242
1411
|
disableLiveBindings?: boolean;
|
|
1243
1412
|
viteMode?: boolean;
|
|
@@ -1326,93 +1495,73 @@ interface InputOptions {
|
|
|
1326
1495
|
*/
|
|
1327
1496
|
incrementalBuild?: boolean;
|
|
1328
1497
|
transformHiresSourcemap?: boolean | "boundary";
|
|
1498
|
+
/**
|
|
1499
|
+
* Use native Rust implementation of MagicString for source map generation.
|
|
1500
|
+
*
|
|
1501
|
+
* - Type: `boolean`
|
|
1502
|
+
* - Default: `false`
|
|
1503
|
+
*
|
|
1504
|
+
* [MagicString](https://github.com/rich-harris/magic-string) is a JavaScript library commonly used by bundlers
|
|
1505
|
+
* for string manipulation and source map generation. When enabled, rolldown will use a native Rust
|
|
1506
|
+
* implementation of MagicString instead of the JavaScript version, providing significantly better performance
|
|
1507
|
+
* during source map generation and code transformation.
|
|
1508
|
+
*
|
|
1509
|
+
* ## Benefits
|
|
1510
|
+
*
|
|
1511
|
+
* - **Improved Performance**: The native Rust implementation is typically faster than the JavaScript version,
|
|
1512
|
+
* especially for large codebases with extensive source maps.
|
|
1513
|
+
* - **Background Processing**: Source map generation is performed asynchronously in a background thread,
|
|
1514
|
+
* allowing the main bundling process to continue without blocking. This parallel processing can significantly
|
|
1515
|
+
* reduce overall build times when working with JavaScript transform hooks.
|
|
1516
|
+
* - **Better Integration**: Seamless integration with rolldown's native Rust architecture.
|
|
1517
|
+
*
|
|
1518
|
+
* ## Example
|
|
1519
|
+
*
|
|
1520
|
+
* ```js
|
|
1521
|
+
* export default {
|
|
1522
|
+
* experimental: {
|
|
1523
|
+
* nativeMagicString: true
|
|
1524
|
+
* },
|
|
1525
|
+
* output: {
|
|
1526
|
+
* sourcemap: true
|
|
1527
|
+
* }
|
|
1528
|
+
* }
|
|
1529
|
+
* ```
|
|
1530
|
+
*
|
|
1531
|
+
* > [!NOTE]
|
|
1532
|
+
* > This is an experimental feature. While it aims to provide identical behavior to the JavaScript
|
|
1533
|
+
* > implementation, there may be edge cases. Please report any discrepancies you encounter.
|
|
1534
|
+
* > For a complete working example, see [examples/native-magic-string](https://github.com/rolldown/rolldown/tree/main/examples/native-magic-string)
|
|
1535
|
+
*/
|
|
1536
|
+
nativeMagicString?: boolean;
|
|
1329
1537
|
};
|
|
1330
1538
|
/**
|
|
1331
1539
|
* Replace global variables or [property accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors) with the provided values.
|
|
1332
1540
|
*
|
|
1333
|
-
*
|
|
1334
|
-
*
|
|
1335
|
-
* - Replace the global variable `IS_PROD` with `true`
|
|
1336
|
-
*
|
|
1337
|
-
* ```js rolldown.config.js
|
|
1338
|
-
* export default defineConfig({ define: { IS_PROD: 'true' // or JSON.stringify(true) } })
|
|
1339
|
-
* ```
|
|
1340
|
-
*
|
|
1341
|
-
* Result:
|
|
1342
|
-
*
|
|
1343
|
-
* ```js
|
|
1344
|
-
* // Input
|
|
1345
|
-
* if (IS_PROD) {
|
|
1346
|
-
* console.log('Production mode')
|
|
1347
|
-
* }
|
|
1348
|
-
*
|
|
1349
|
-
* // After bundling
|
|
1350
|
-
* if (true) {
|
|
1351
|
-
* console.log('Production mode')
|
|
1352
|
-
* }
|
|
1353
|
-
* ```
|
|
1354
|
-
*
|
|
1355
|
-
* - Replace the property accessor `process.env.NODE_ENV` with `'production'`
|
|
1356
|
-
*
|
|
1357
|
-
* ```js rolldown.config.js
|
|
1358
|
-
* export default defineConfig({ define: { 'process.env.NODE_ENV': "'production'" } })
|
|
1359
|
-
* ```
|
|
1360
|
-
*
|
|
1361
|
-
* Result:
|
|
1541
|
+
* @deprecated Use `transform.define` instead. This top-level option will be removed in a future release.
|
|
1362
1542
|
*
|
|
1363
|
-
*
|
|
1364
|
-
* // Input
|
|
1365
|
-
* if (process.env.NODE_ENV === 'production') {
|
|
1366
|
-
* console.log('Production mode')
|
|
1367
|
-
* }
|
|
1368
|
-
*
|
|
1369
|
-
* // After bundling
|
|
1370
|
-
* if ('production' === 'production') {
|
|
1371
|
-
* console.log('Production mode')
|
|
1372
|
-
* }
|
|
1373
|
-
*
|
|
1374
|
-
* ```
|
|
1543
|
+
* See `transform.define` for detailed documentation and examples.
|
|
1375
1544
|
*/
|
|
1376
1545
|
define?: Record<string, string>;
|
|
1377
1546
|
/**
|
|
1378
1547
|
* Inject import statements on demand.
|
|
1379
1548
|
*
|
|
1380
|
-
*
|
|
1381
|
-
* ```js
|
|
1382
|
-
* {
|
|
1383
|
-
* // import { Promise } from 'es6-promise'
|
|
1384
|
-
* Promise: ['es6-promise', 'Promise'],
|
|
1385
|
-
*
|
|
1386
|
-
* // import { Promise as P } from 'es6-promise'
|
|
1387
|
-
* P: ['es6-promise', 'Promise'],
|
|
1388
|
-
*
|
|
1389
|
-
* // import $ from 'jquery'
|
|
1390
|
-
* $: 'jquery',
|
|
1549
|
+
* @deprecated Use `transform.inject` instead. This top-level option will be removed in a future release.
|
|
1391
1550
|
*
|
|
1392
|
-
*
|
|
1393
|
-
* fs: ['node:fs', '*'],
|
|
1394
|
-
*
|
|
1395
|
-
* // Inject shims for property access pattern
|
|
1396
|
-
* 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
|
|
1397
|
-
* }
|
|
1398
|
-
* ```
|
|
1551
|
+
* See `transform.inject` for detailed documentation and examples.
|
|
1399
1552
|
*/
|
|
1400
1553
|
inject?: Record<string, string | [string, string]>;
|
|
1401
|
-
profilerNames?: boolean;
|
|
1402
1554
|
/**
|
|
1403
|
-
*
|
|
1555
|
+
* Whether to add readable names to internal variables for profiling purposes.
|
|
1404
1556
|
*
|
|
1405
|
-
*
|
|
1406
|
-
*
|
|
1557
|
+
* When enabled, generated code will use descriptive variable names that correspond
|
|
1558
|
+
* to the original module names, making it easier to profile and debug the bundled code.
|
|
1407
1559
|
*
|
|
1408
|
-
*
|
|
1409
|
-
* - `"preserve"` disables the JSX transformer, preserving the original JSX syntax in the output.
|
|
1410
|
-
* - `"react"` enables the `classic` JSX transformer.
|
|
1411
|
-
* - `"react-jsx"` enables the `automatic` JSX transformer.
|
|
1560
|
+
* @default true when minification is disabled, false when minification is enabled
|
|
1412
1561
|
*
|
|
1413
|
-
* @
|
|
1562
|
+
* @deprecated Use `output.generatedCode.profilerNames` instead. This top-level option will be removed in a future release.
|
|
1414
1563
|
*/
|
|
1415
|
-
|
|
1564
|
+
profilerNames?: boolean;
|
|
1416
1565
|
/**
|
|
1417
1566
|
* Configure how the code is transformed. This process happens after the `transform` hook.
|
|
1418
1567
|
*
|
|
@@ -1430,9 +1579,23 @@ interface InputOptions {
|
|
|
1430
1579
|
*
|
|
1431
1580
|
* For latest decorators proposal, rolldown is able to bundle them but doesn't support transpiling them yet.
|
|
1432
1581
|
*/
|
|
1433
|
-
transform?:
|
|
1582
|
+
transform?: TransformOptions;
|
|
1434
1583
|
watch?: WatcherOptions | false;
|
|
1584
|
+
/**
|
|
1585
|
+
* Remove labeled statements with these label names.
|
|
1586
|
+
*
|
|
1587
|
+
* @deprecated Use `transform.dropLabels` instead. This top-level option will be removed in a future release.
|
|
1588
|
+
*
|
|
1589
|
+
* See `transform.dropLabels` for detailed documentation and examples.
|
|
1590
|
+
*/
|
|
1435
1591
|
dropLabels?: string[];
|
|
1592
|
+
/**
|
|
1593
|
+
* Keep function and class names after bundling.
|
|
1594
|
+
*
|
|
1595
|
+
* @deprecated Use `output.keepNames` instead. This top-level option will be removed in a future release.
|
|
1596
|
+
*
|
|
1597
|
+
* See `output.keepNames` for detailed documentation.
|
|
1598
|
+
*/
|
|
1436
1599
|
keepNames?: boolean;
|
|
1437
1600
|
checks?: ChecksOptions;
|
|
1438
1601
|
makeAbsoluteExternalsRelative?: MakeAbsoluteExternalsRelative;
|
|
@@ -1472,4 +1635,4 @@ declare function defineConfig(config: RolldownOptions[]): RolldownOptions[];
|
|
|
1472
1635
|
declare function defineConfig(config: RolldownOptionsFunction): RolldownOptionsFunction;
|
|
1473
1636
|
declare function defineConfig(config: ConfigExport): ConfigExport;
|
|
1474
1637
|
//#endregion
|
|
1475
|
-
export {
|
|
1638
|
+
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 };
|
|
@@ -140,4 +140,4 @@ function queries(queryFilter) {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
//#endregion
|
|
143
|
-
export {
|
|
143
|
+
export { include as a, or as c, arraify as d, isPromiseLike as f, unsupported as g, unreachable as h, id as i, queries as l, unimplemented as m, code as n, moduleType as o, noop as p, exclude as r, not as s, and as t, query as u };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { rolldown } from "./src-
|
|
1
|
+
import { o as rolldown } from "./src-BnIhK3nA.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { readdir } from "node:fs/promises";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
@@ -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 };
|