@rolldown/browser 1.0.0-beta.40 → 1.0.0-beta.42

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 (29) hide show
  1. package/dist/cli.mjs +17 -9
  2. package/dist/config.d.mts +2 -2
  3. package/dist/config.mjs +4 -4
  4. package/dist/experimental-index.browser.mjs +22 -25
  5. package/dist/experimental-index.d.mts +17 -9
  6. package/dist/experimental-index.mjs +25 -28
  7. package/dist/experimental-runtime-types.d.ts +6 -0
  8. package/dist/filter-index.d.mts +2 -2
  9. package/dist/filter-index.mjs +1 -1
  10. package/dist/index.browser.mjs +1 -1
  11. package/dist/index.d.mts +3 -3
  12. package/dist/index.mjs +3 -3
  13. package/dist/parallel-plugin-worker.mjs +5 -6
  14. package/dist/parallel-plugin.d.mts +2 -2
  15. package/dist/parse-ast-index.d.mts +1 -1
  16. package/dist/parse-ast-index.mjs +1 -1
  17. package/dist/rolldown-binding.wasi-browser.js +2 -1
  18. package/dist/rolldown-binding.wasi.cjs +2 -1
  19. package/dist/rolldown-binding.wasm32-wasi.wasm +0 -0
  20. package/dist/shared/{binding-BVXbXhPv.d.mts → binding-CtbNz6TD.d.mts} +29 -22
  21. package/dist/shared/{define-config-D9LkukIg.d.mts → define-config-xBdWOg15.d.mts} +27 -6
  22. package/dist/shared/{dist-CHTC3-kR.mjs → dist-CU0dSkK2.mjs} +2 -3
  23. package/dist/shared/{load-config-CU4Yss-9.mjs → load-config-B4-CoeU7.mjs} +4 -7
  24. package/dist/shared/{logger-CiCY7ucm.mjs → logger-B83ocDok.mjs} +6 -9
  25. package/dist/shared/{parse-ast-index-DuyJNdzo.mjs → parse-ast-index-Gktxd-oi.mjs} +1 -1
  26. package/dist/shared/{prompt-D2FxOcB5.mjs → prompt-B4e-jZUR.mjs} +28 -30
  27. package/dist/shared/{src-BfUPNTHw.mjs → src-DbG0hppv.mjs} +115 -125
  28. package/dist/{src-ChN10Pih.js → src-D_rsgcbb.js} +150 -163
  29. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { BindingBuiltinPluginName, BindingBundlerImpl, BindingHmrUpdate, BindingHookResolveIdExtraArgs, BindingRenderedChunk, BindingTransformHookExtraArgs, BindingWatcherEvent, MinifyOptions as MinifyOptions$1, ParserOptions, PreRenderedChunk, TransformOptions } from "./binding-BVXbXhPv.mjs";
1
+ import { BindingBuiltinPluginName, BindingBundlerImpl, BindingHookResolveIdExtraArgs, BindingRenderedChunk, BindingTransformHookExtraArgs, BindingWatcherEvent, MinifyOptions as MinifyOptions$1, ParserOptions, PreRenderedChunk, TransformOptions } from "./binding-CtbNz6TD.mjs";
2
2
  import { Program } from "@oxc-project/types";
3
3
  import { TopLevelFilterExpression } from "@rolldown/pluginutils";
4
4
 
@@ -137,6 +137,29 @@ type MaybeArray<T> = T | T[];
137
137
  type StringOrRegExp = string | RegExp;
138
138
  //#endregion
139
139
  //#region src/options/output-options.d.ts
140
+ type GeneratedCodePreset = "es5" | "es2015";
141
+ interface GeneratedCodeOptions {
142
+ /**
143
+ * Whether to use Symbol.toStringTag for namespace objects.
144
+ * @default false
145
+ */
146
+ symbols?: boolean;
147
+ /**
148
+ * Allows choosing one of the presets listed above while overriding some options.
149
+ *
150
+ * ```js
151
+ * export default {
152
+ * output: {
153
+ * generatedCode: {
154
+ * preset: 'es2015',
155
+ * symbols: false
156
+ * }
157
+ * }
158
+ * };
159
+ * ```
160
+ */
161
+ preset?: GeneratedCodePreset;
162
+ }
140
163
  type ModuleFormat = "es" | "cjs" | "esm" | "module" | "commonjs" | "iife" | "umd";
141
164
  type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
142
165
  type ChunkFileNamesFunction = (chunkInfo: PreRenderedChunk) => string;
@@ -195,7 +218,7 @@ interface OutputOptions {
195
218
  * // ✅ Preferred: Use string pattern for better performance
196
219
  * sourcemapIgnoreList: "vendor"
197
220
  *
198
- * // ⚠️ Use sparingly: Function calls have high overhead
221
+ * // ! Use sparingly: Function calls have high overhead
199
222
  * sourcemapIgnoreList: (source, sourcemapPath) => {
200
223
  * return source.includes('node_modules') || source.includes('.min.');
201
224
  * }
@@ -230,6 +253,7 @@ interface OutputOptions {
230
253
  minify?: boolean | "dce-only" | MinifyOptions;
231
254
  name?: string;
232
255
  globals?: Record<string, string> | GlobalsFunction;
256
+ generatedCode?: Partial<GeneratedCodeOptions>;
233
257
  externalLiveBindings?: boolean;
234
258
  inlineDynamicImports?: boolean;
235
259
  /**
@@ -520,8 +544,6 @@ declare class RolldownBuild {
520
544
  write(outputOptions?: OutputOptions): Promise<RolldownOutput>;
521
545
  close(): Promise<void>;
522
546
  [Symbol.asyncDispose](): Promise<void>;
523
- generateHmrPatch(changedFiles: string[]): Promise<BindingHmrUpdate[]>;
524
- hmrInvalidate(file: string, firstInvalidatedBy?: string): Promise<BindingHmrUpdate>;
525
547
  get watchFiles(): Promise<string[]>;
526
548
  }
527
549
  //#endregion
@@ -1108,7 +1130,6 @@ type HmrOptions = boolean | {
1108
1130
  host?: string;
1109
1131
  port?: number;
1110
1132
  implement?: string;
1111
- new?: boolean;
1112
1133
  };
1113
1134
  type OptimizationOptions = {
1114
1135
  /**
@@ -1451,4 +1472,4 @@ declare function defineConfig(config: RolldownOptions[]): RolldownOptions[];
1451
1472
  declare function defineConfig(config: RolldownOptionsFunction): RolldownOptionsFunction;
1452
1473
  declare function defineConfig(config: ConfigExport): ConfigExport;
1453
1474
  //#endregion
1454
- export { type AddonFunction, type AsyncPluginHooks, type BufferEncoding, type BuildOptions, BuiltinPlugin, type ChunkFileNamesFunction, type ChunkingContext, type ConfigExport, type CustomPluginOptions, type DefineParallelPluginResult, type EmittedAsset, type EmittedFile, type ExistingRawSourceMap, type ExternalOption, type FunctionPluginHooks, type GeneralHookFilter, type GetModuleInfo, type GlobalsFunction, type HookFilter, type HookFilterExtension, type ImportKind, type InputOption, type InputOptions, type InternalModuleFormat, type LoadResult, type LogLevel, type LogLevelOption, type LogOrStringHandler, type LoggingFunction, MaybePromise, type MinifyOptions, type MinimalPluginContext, type ModuleFormat, type ModuleInfo, type ModuleOptions, type ModuleType, type ModuleTypeFilter, type ModuleTypes, type NormalizedInputOptions, type NormalizedOutputOptions, type ObjectHook, type OptimizationOptions, type OutputAsset, type OutputBundle, type OutputChunk, type OutputOptions, type ParallelPluginHooks, type PartialNull, type PartialResolvedId, type Plugin, type PluginContext, type PluginContextMeta, type PreRenderedAsset, type RenderedChunk, type RenderedModule, type ResolveIdExtraOptions, type ResolveIdResult, type ResolvedId, type RolldownBuild, type RolldownDirectoryEntry, type RolldownFileStats, type RolldownFsModule, type RolldownOptions, type RolldownOptionsFunction, type RolldownOutput, type RolldownPlugin, type RolldownPluginOption, type RolldownWatcher, type RolldownWatcherEvent, type RollupError, type RollupLog, type RollupLogWithString, type SourceDescription, type SourceMap, type SourceMapInput, type SourcemapIgnoreListOption, StringOrRegExp, type TransformPluginContext, type TransformResult, type TreeshakingOptions, VERSION, type WarningHandlerWithDefault, type WatchOptions, type WatcherOptions, build, defineConfig, defineParallelPlugin, rolldown, watch, withFilter };
1475
+ export { type AddonFunction, type AsyncPluginHooks, type BufferEncoding, type BuildOptions, BuiltinPlugin, type ChunkFileNamesFunction, type ChunkingContext, type ConfigExport, type CustomPluginOptions, type DefineParallelPluginResult, type EmittedAsset, type EmittedFile, type ExistingRawSourceMap, type ExternalOption, type FunctionPluginHooks, type GeneralHookFilter, type GeneratedCodeOptions, type GeneratedCodePreset, type GetModuleInfo, type GlobalsFunction, type HookFilter, type HookFilterExtension, type ImportKind, type InputOption, type InputOptions, type InternalModuleFormat, type LoadResult, type LogLevel, type LogLevelOption, type LogOrStringHandler, type LoggingFunction, MaybePromise, type MinifyOptions, type MinimalPluginContext, type ModuleFormat, type ModuleInfo, type ModuleOptions, type ModuleType, type ModuleTypeFilter, type ModuleTypes, type NormalizedInputOptions, type NormalizedOutputOptions, type ObjectHook, type OptimizationOptions, type OutputAsset, type OutputBundle, type OutputChunk, type OutputOptions, type ParallelPluginHooks, type PartialNull, type PartialResolvedId, type Plugin, type PluginContext, type PluginContextMeta, type PreRenderedAsset, type RenderedChunk, type RenderedModule, type ResolveIdExtraOptions, type ResolveIdResult, type ResolvedId, type RolldownBuild, type RolldownDirectoryEntry, type RolldownFileStats, type RolldownFsModule, type RolldownOptions, type RolldownOptionsFunction, type RolldownOutput, type RolldownPlugin, type RolldownPluginOption, type RolldownWatcher, type RolldownWatcherEvent, type RollupError, type RollupLog, type RollupLogWithString, type SourceDescription, type SourceMap, type SourceMapInput, type SourcemapIgnoreListOption, StringOrRegExp, type TransformPluginContext, type TransformResult, type TreeshakingOptions, VERSION, type WarningHandlerWithDefault, type WatchOptions, type WatcherOptions, build, defineConfig, defineParallelPlugin, rolldown, watch, withFilter };
@@ -134,10 +134,9 @@ function exclude(expr) {
134
134
  * @returns a `And` FilterExpression
135
135
  */
136
136
  function queries(queryFilter) {
137
- let arr = Object.entries(queryFilter).map(([key, value]) => {
137
+ return and(...Object.entries(queryFilter).map(([key, value]) => {
138
138
  return new Query(key, value);
139
- });
140
- return and(...arr);
139
+ }));
141
140
  }
142
141
 
143
142
  //#endregion
@@ -1,4 +1,4 @@
1
- import { rolldown } from "./src-BfUPNTHw.mjs";
1
+ import { rolldown } from "./src-DbG0hppv.mjs";
2
2
  import path from "node:path";
3
3
  import { readdir } from "node:fs/promises";
4
4
  import { pathToFileURL } from "node:url";
@@ -66,8 +66,7 @@ async function findConfigFileNameInCwd() {
66
66
  throw new Error("No `rolldown.config` configuration file found.");
67
67
  }
68
68
  async function loadTsConfig(configFile) {
69
- const isEsm = isFilePathESM(configFile);
70
- const file = await bundleTsConfig(configFile, isEsm);
69
+ const file = await bundleTsConfig(configFile, isFilePathESM(configFile));
71
70
  try {
72
71
  return (await import(pathToFileURL(file).href)).default;
73
72
  } finally {
@@ -104,10 +103,8 @@ async function loadConfig(configPath) {
104
103
  const ext = path.extname(configPath = configPath || await findConfigFileNameInCwd());
105
104
  try {
106
105
  if (SUPPORTED_JS_CONFIG_FORMATS.includes(ext) || process.env.NODE_OPTIONS?.includes("--import=tsx") && SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return (await import(pathToFileURL(configPath).href)).default;
107
- else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) {
108
- const rawConfigPath = path.resolve(configPath);
109
- return await loadTsConfig(rawConfigPath);
110
- } else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
106
+ else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return await loadTsConfig(path.resolve(configPath));
107
+ else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
111
108
  } catch (err) {
112
109
  throw new Error("Error happened while loading config.", { cause: err });
113
110
  }
@@ -416,11 +416,10 @@ ${indent}`);
416
416
  return causedPrefix + message + "\n" + stack + causedError;
417
417
  }
418
418
  formatArgs(args, opts) {
419
- const _args = args.map((arg) => {
419
+ return formatWithOptions(opts, ...args.map((arg) => {
420
420
  if (arg && typeof arg.stack === "string") return this.formatError(arg, opts);
421
421
  return arg;
422
- });
423
- return formatWithOptions(opts, ..._args);
422
+ }));
424
423
  }
425
424
  formatDate(date, opts) {
426
425
  return opts.date ? date.toLocaleTimeString() : "";
@@ -442,11 +441,10 @@ ${indent}`);
442
441
  ]);
443
442
  }
444
443
  log(logObj, ctx) {
445
- const line = this.formatLogObj(logObj, {
444
+ return writeStream(this.formatLogObj(logObj, {
446
445
  columns: ctx.options.stdout.columns || 0,
447
446
  ...ctx.options.formatOptions
448
- });
449
- return writeStream(line + "\n", logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout);
447
+ }) + "\n", logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout);
450
448
  }
451
449
  };
452
450
 
@@ -646,8 +644,7 @@ const r = Object.create(null), i = (e) => globalThis.process?.env || import.meta
646
644
  return i()[s$1] ?? r[s$1];
647
645
  },
648
646
  has(e, s$1) {
649
- const E = i();
650
- return s$1 in E || s$1 in r;
647
+ return s$1 in i() || s$1 in r;
651
648
  },
652
649
  set(e, s$1, E) {
653
650
  const B = i(true);
@@ -944,7 +941,7 @@ function createConsola(options = {}) {
944
941
  defaults: { level },
945
942
  stdout: process.stdout,
946
943
  stderr: process.stderr,
947
- prompt: (...args) => import("./prompt-D2FxOcB5.mjs").then((m) => m.prompt(...args)),
944
+ prompt: (...args) => import("./prompt-B4e-jZUR.mjs").then((m) => m.prompt(...args)),
948
945
  reporters: options.reporters || [options.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()],
949
946
  ...options
950
947
  });
@@ -186,7 +186,7 @@ function augmentCodeLocation(properties, pos, source, id) {
186
186
  }
187
187
 
188
188
  //#endregion
189
- //#region ../../node_modules/.pnpm/oxc-parser@0.92.0/node_modules/oxc-parser/src-js/wrap.js
189
+ //#region ../../node_modules/.pnpm/oxc-parser@0.94.0/node_modules/oxc-parser/src-js/wrap.js
190
190
  function wrap$1(result) {
191
191
  let program, module, comments, errors;
192
192
  return {
@@ -39,28 +39,26 @@ function requireSrc() {
39
39
  save: `${ESC}7`,
40
40
  restore: `${ESC}8`
41
41
  };
42
- const scroll = {
43
- up: (count = 1) => `${CSI}S`.repeat(count),
44
- down: (count = 1) => `${CSI}T`.repeat(count)
45
- };
46
- const erase = {
47
- screen: `${CSI}2J`,
48
- up: (count = 1) => `${CSI}1J`.repeat(count),
49
- down: (count = 1) => `${CSI}J`.repeat(count),
50
- line: `${CSI}2K`,
51
- lineEnd: `${CSI}K`,
52
- lineStart: `${CSI}1K`,
53
- lines(count) {
54
- let clear = "";
55
- for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
56
- if (count) clear += cursor.left;
57
- return clear;
58
- }
59
- };
60
42
  src = {
61
43
  cursor,
62
- scroll,
63
- erase,
44
+ scroll: {
45
+ up: (count = 1) => `${CSI}S`.repeat(count),
46
+ down: (count = 1) => `${CSI}T`.repeat(count)
47
+ },
48
+ erase: {
49
+ screen: `${CSI}2J`,
50
+ up: (count = 1) => `${CSI}1J`.repeat(count),
51
+ down: (count = 1) => `${CSI}J`.repeat(count),
52
+ line: `${CSI}2K`,
53
+ lineEnd: `${CSI}K`,
54
+ lineStart: `${CSI}1K`,
55
+ lines(count) {
56
+ let clear = "";
57
+ for (let i = 0; i < count; i++) clear += this.line + (i < count - 1 ? cursor.up() : "");
58
+ if (count) clear += cursor.left;
59
+ return clear;
60
+ }
61
+ },
64
62
  beep
65
63
  };
66
64
  return src;
@@ -401,16 +399,16 @@ function G(t, u$1, F$1) {
401
399
  `).map((e$1) => oD(e$1, u$1, F$1)).join(`
402
400
  `);
403
401
  }
404
- const aD = [
405
- "up",
406
- "down",
407
- "left",
408
- "right",
409
- "space",
410
- "enter",
411
- "cancel"
412
- ], c = {
413
- actions: new Set(aD),
402
+ const c = {
403
+ actions: new Set([
404
+ "up",
405
+ "down",
406
+ "left",
407
+ "right",
408
+ "space",
409
+ "enter",
410
+ "cancel"
411
+ ]),
414
412
  aliases: new Map([
415
413
  ["k", "up"],
416
414
  ["j", "down"],