rolldown 1.0.0-beta.16 → 1.0.0-beta.18

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.
Files changed (42) hide show
  1. package/dist/cli.cjs +6 -6
  2. package/dist/cli.mjs +1042 -1081
  3. package/dist/config.cjs +3 -3
  4. package/dist/config.d.cts +2 -2
  5. package/dist/config.d.mts +2 -2
  6. package/dist/config.mjs +4 -6
  7. package/dist/experimental-index.cjs +7 -31
  8. package/dist/experimental-index.d.cts +2 -2
  9. package/dist/experimental-index.d.mts +2 -2
  10. package/dist/experimental-index.mjs +4 -22
  11. package/dist/filter-index.d.cts +2 -2
  12. package/dist/filter-index.d.mts +2 -2
  13. package/dist/filter-index.mjs +1 -2
  14. package/dist/index.cjs +2 -2
  15. package/dist/index.d.cts +2 -2
  16. package/dist/index.d.mts +2 -2
  17. package/dist/index.mjs +3 -4
  18. package/dist/parallel-plugin-worker.cjs +3 -4
  19. package/dist/parallel-plugin-worker.mjs +27 -34
  20. package/dist/parallel-plugin.d.cts +2 -2
  21. package/dist/parallel-plugin.d.mts +2 -2
  22. package/dist/parse-ast-index.cjs +1 -1
  23. package/dist/parse-ast-index.d.cts +1 -1
  24. package/dist/parse-ast-index.d.mts +1 -1
  25. package/dist/parse-ast-index.mjs +1 -2
  26. package/dist/shared/{binding--Y47JZSL.d.cts → binding-D__94uwg.d.cts} +13 -462
  27. package/dist/shared/{binding-C_9au5Eg.d.mts → binding-DwMf_OTa.d.mts} +13 -462
  28. package/dist/shared/{define-config-DMWHsgSt.d.mts → define-config-CXjwrGWr.d.cts} +70 -10
  29. package/dist/shared/{define-config-CAyC9-af.d.cts → define-config-pMM2R7Js.d.mts} +70 -10
  30. package/dist/shared/{load-config-BniS-jT_.cjs → load-config-BeHXwv7L.cjs} +1 -1
  31. package/dist/shared/{load-config-BT5Ts430.mjs → load-config-D2fi4c8T.mjs} +14 -19
  32. package/dist/shared/{misc-DGAe2XOW.mjs → misc-BN0nse6C.mjs} +1 -4
  33. package/dist/shared/parse-ast-index-BbUPYP6B.cjs +738 -0
  34. package/dist/shared/parse-ast-index-QIuIuIzO.mjs +616 -0
  35. package/dist/shared/prompt-C5jz26Zn.mjs +852 -0
  36. package/dist/shared/{src-1lPDqeuR.cjs → src-BHe-J6xJ.cjs} +44 -48
  37. package/dist/shared/{src-Cv4_zurW.mjs → src-Bob3e8Hh.mjs} +1136 -1394
  38. package/package.json +21 -21
  39. package/dist/shared/chunk--iN_1bjD.mjs +0 -33
  40. package/dist/shared/parse-ast-index-BHkdbivO.mjs +0 -659
  41. package/dist/shared/parse-ast-index-hgMnddyI.cjs +0 -701
  42. package/dist/shared/prompt-CodO769G.mjs +0 -854
@@ -1,6 +1,6 @@
1
- import { BindingAssetPluginConfig, BindingBuildImportAnalysisPluginConfig, BindingBuiltinPluginName, BindingDynamicImportVarsPluginConfig, BindingHmrOutputPatch, BindingHookResolveIdExtraArgs, BindingImportGlobPluginConfig, BindingIsolatedDeclarationPluginConfig, BindingJsonPluginConfig, BindingManifestPluginConfig, BindingMfManifest, BindingMinifyOptions, BindingModuleFederationPluginOption, BindingModulePreloadPolyfillPluginConfig, BindingRemote, BindingRenderedChunk, BindingReporterPluginConfig, BindingTransformHookExtraArgs, BindingViteResolvePluginConfig, BindingWatcherEvent, Bundler, ParserOptions, PreRenderedChunk, TransformOptions } from "./binding-C_9au5Eg.mjs";
2
- import { TopLevelFilterExpression } from "@rolldown/pluginutils";
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-D__94uwg.cjs";
3
2
  import { Program } from "@oxc-project/types";
3
+ import { TopLevelFilterExpression } from "@rolldown/pluginutils";
4
4
 
5
5
  //#region src/log/logging.d.ts
6
6
  type LogLevel = "info" | "debug" | "warn";
@@ -170,7 +170,7 @@ interface OutputOptions {
170
170
  externalLiveBindings?: boolean;
171
171
  inlineDynamicImports?: boolean;
172
172
  /**
173
- * Allows you to do advanced chunking. Use it to reduce the number of common chunks or split out a chunk that hardly changes to obtain better caching.
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
- * if `test` is empty, any module will be considered as matched.
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 be ignored.
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 final size of this group is larger than this value, this group will be spit into multiple groups that each has size closed to this value.
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
  /**
@@ -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 = Bundler;
376
+ type RolldownWatchBuild = BindingBundlerImpl;
334
377
  type RolldownWatcherEvent = {
335
378
  code: "START";
336
379
  } | {
@@ -1020,6 +1063,23 @@ interface InputOptions {
1020
1063
  * @default runtime = "automatic"
1021
1064
  */
1022
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
+ */
1023
1083
  transform?: OxcTransformOption;
1024
1084
  watch?: WatcherOptions | false;
1025
1085
  dropLabels?: string[];
@@ -1,6 +1,6 @@
1
- import { BindingAssetPluginConfig, BindingBuildImportAnalysisPluginConfig, BindingBuiltinPluginName, BindingDynamicImportVarsPluginConfig, BindingHmrOutputPatch, BindingHookResolveIdExtraArgs, BindingImportGlobPluginConfig, BindingIsolatedDeclarationPluginConfig, BindingJsonPluginConfig, BindingManifestPluginConfig, BindingMfManifest, BindingMinifyOptions, BindingModuleFederationPluginOption, BindingModulePreloadPolyfillPluginConfig, BindingRemote, BindingRenderedChunk, BindingReporterPluginConfig, BindingTransformHookExtraArgs, BindingViteResolvePluginConfig, BindingWatcherEvent, Bundler, ParserOptions, PreRenderedChunk, TransformOptions } from "./binding--Y47JZSL.cjs";
2
- import { Program } from "@oxc-project/types";
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-DwMf_OTa.mjs";
3
2
  import { TopLevelFilterExpression } from "@rolldown/pluginutils";
3
+ import { Program } from "@oxc-project/types";
4
4
 
5
5
  //#region src/log/logging.d.ts
6
6
  type LogLevel = "info" | "debug" | "warn";
@@ -170,7 +170,7 @@ interface OutputOptions {
170
170
  externalLiveBindings?: boolean;
171
171
  inlineDynamicImports?: boolean;
172
172
  /**
173
- * Allows you to do advanced chunking. Use it to reduce the number of common chunks or split out a chunk that hardly changes to obtain better caching.
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
- * if `test` is empty, any module will be considered as matched.
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 be ignored.
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 final size of this group is larger than this value, this group will be spit into multiple groups that each has size closed to this value.
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
  /**
@@ -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 = Bundler;
376
+ type RolldownWatchBuild = BindingBundlerImpl;
334
377
  type RolldownWatcherEvent = {
335
378
  code: "START";
336
379
  } | {
@@ -1020,6 +1063,23 @@ interface InputOptions {
1020
1063
  * @default runtime = "automatic"
1021
1064
  */
1022
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
+ */
1023
1083
  transform?: OxcTransformOption;
1024
1084
  watch?: WatcherOptions | false;
1025
1085
  dropLabels?: string[];
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require('./chunk-DDkG_k5U.cjs');
2
- const require_src = require('./src-1lPDqeuR.cjs');
2
+ const require_src = require('./src-BHe-J6xJ.cjs');
3
3
  const node_fs = require_chunk.__toESM(require("node:fs"));
4
4
  const node_path = require_chunk.__toESM(require("node:path"));
5
5
  const node_url = require_chunk.__toESM(require("node:url"));
@@ -1,5 +1,4 @@
1
- import { __esm } from "./chunk--iN_1bjD.mjs";
2
- import { init_rolldown, rolldown } from "./src-Cv4_zurW.mjs";
1
+ import { rolldown } from "./src-Bob3e8Hh.mjs";
3
2
  import fs from "node:fs";
4
3
  import path from "node:path";
5
4
  import { pathToFileURL } from "node:url";
@@ -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 { init_load_config, loadConfig };
119
+ export { loadConfig };
@@ -1,5 +1,3 @@
1
- import { __esm } from "./chunk--iN_1bjD.mjs";
2
-
3
1
  //#region src/utils/misc.ts
4
2
  function arraify(value) {
5
3
  return Array.isArray(value) ? value : [value];
@@ -22,7 +20,6 @@ function unsupported(info) {
22
20
  throw new Error(`UNSUPPORTED: ${info}`);
23
21
  }
24
22
  function noop(..._args) {}
25
- var init_misc = __esm({ "src/utils/misc.ts"() {} });
26
23
 
27
24
  //#endregion
28
- export { arraify, init_misc, isNullish, isPromiseLike, noop, unimplemented, unreachable, unsupported };
25
+ export { arraify, isNullish, isPromiseLike, noop, unimplemented, unreachable, unsupported };