rolldown 1.0.0-beta.31-commit.832324a → 1.0.0-beta.33

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 (39) hide show
  1. package/dist/cli.cjs +5 -5
  2. package/dist/cli.d.cts +1 -1
  3. package/dist/cli.d.mts +1 -1
  4. package/dist/cli.mjs +7 -6
  5. package/dist/config.cjs +3 -3
  6. package/dist/config.d.cts +2 -2
  7. package/dist/config.d.mts +2 -2
  8. package/dist/config.mjs +3 -3
  9. package/dist/experimental-index.cjs +2 -2
  10. package/dist/experimental-index.d.cts +2 -2
  11. package/dist/experimental-index.d.mts +2 -2
  12. package/dist/experimental-index.mjs +2 -2
  13. package/dist/filter-index.d.cts +2 -2
  14. package/dist/filter-index.d.mts +2 -2
  15. package/dist/index.cjs +2 -2
  16. package/dist/index.d.cts +2 -2
  17. package/dist/index.d.mts +2 -2
  18. package/dist/index.mjs +2 -2
  19. package/dist/parallel-plugin-worker.cjs +2 -2
  20. package/dist/parallel-plugin-worker.d.cts +1 -1
  21. package/dist/parallel-plugin-worker.d.mts +1 -1
  22. package/dist/parallel-plugin-worker.mjs +4 -3
  23. package/dist/parallel-plugin.d.cts +2 -2
  24. package/dist/parallel-plugin.d.mts +2 -2
  25. package/dist/parse-ast-index.cjs +1 -1
  26. package/dist/parse-ast-index.d.cts +1 -1
  27. package/dist/parse-ast-index.d.mts +1 -1
  28. package/dist/parse-ast-index.mjs +1 -1
  29. package/dist/shared/{binding-BIqlUgrm.d.cts → binding-CFhvYkVn.d.mts} +4 -3
  30. package/dist/shared/{binding-COE5UL-B.d.mts → binding-DQk9TN_A.d.cts} +4 -3
  31. package/dist/shared/{define-config-DFC0Nu7H.d.cts → define-config-B3QOs3Kt.d.cts} +7 -1
  32. package/dist/shared/{define-config-DfOVOsx6.d.mts → define-config-DtlZ1GSS.d.mts} +7 -1
  33. package/dist/shared/{load-config-C2ByPkRr.cjs → load-config-B-y3XROZ.cjs} +1 -1
  34. package/dist/shared/{load-config-BsvtI-HD.mjs → load-config-C00QU0Nl.mjs} +1 -1
  35. package/dist/shared/{parse-ast-index-B5ThufKy.mjs → parse-ast-index-BsbuAWqn.mjs} +24 -24
  36. package/dist/shared/{parse-ast-index-DSyjeX7n.cjs → parse-ast-index-DBzcfyxO.cjs} +24 -24
  37. package/dist/shared/{src-CJyr8NNX.mjs → src-D1dc6nJr.mjs} +82 -77
  38. package/dist/shared/{src-aI0ysjSj.cjs → src-DZTBSVJk.cjs} +82 -77
  39. package/package.json +22 -22
@@ -1,4 +1,4 @@
1
- import { BindingAttachDebugInfo, BindingBundler, BindingCallableBuiltinPlugin, BindingChunkModuleOrderBy, BindingJsx, BindingLogLevel, BindingPluginOrder, BindingWatcher, ParallelJsPluginRegistry, augmentCodeLocation, error, logCycleLoading, logDuplicateJsxConfig, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst, shutdownAsyncRuntime, startAsyncRuntime } from "./parse-ast-index-B5ThufKy.mjs";
1
+ import { BindingAttachDebugInfo, BindingBundler, BindingCallableBuiltinPlugin, BindingChunkModuleOrderBy, BindingJsx, BindingLogLevel, BindingPluginOrder, BindingWatcher, ParallelJsPluginRegistry, augmentCodeLocation, error, logCycleLoading, logDuplicateJsxConfig, logInputHookInOutputPlugin, logInvalidLogPosition, logMultiplyNotifyOption, logPluginError, parseAst, shutdownAsyncRuntime, startAsyncRuntime } from "./parse-ast-index-BsbuAWqn.mjs";
2
2
  import { arraify, noop, unimplemented, unreachable, unsupported } from "./misc-CQeo-AFx.mjs";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
@@ -9,7 +9,7 @@ import os from "node:os";
9
9
  import { Worker } from "node:worker_threads";
10
10
 
11
11
  //#region package.json
12
- var version = "1.0.0-beta.31-commit.832324a";
12
+ var version = "1.0.0-beta.33";
13
13
  var description$1 = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
14
14
 
15
15
  //#endregion
@@ -31,9 +31,9 @@ function makeBuiltinPluginCallable(plugin) {
31
31
  for (const key in callablePlugin) wrappedPlugin[key] = async function(...args$1) {
32
32
  try {
33
33
  return await callablePlugin[key](...args$1);
34
- } catch (e) {
35
- if (e instanceof Error && !e.stack?.includes("at ")) Error.captureStackTrace(e, wrappedPlugin[key]);
36
- return error(logPluginError(e, plugin.name, {
34
+ } catch (e$1) {
35
+ if (e$1 instanceof Error && !e$1.stack?.includes("at ")) Error.captureStackTrace(e$1, wrappedPlugin[key]);
36
+ return error(logPluginError(e$1, plugin.name, {
37
37
  hook: key,
38
38
  id: key === "transform" ? args$1[2] : void 0
39
39
  }));
@@ -352,8 +352,8 @@ var MinimalPluginContextImpl = class {
352
352
  watchMode
353
353
  };
354
354
  }
355
- error(e) {
356
- return error(logPluginError(normalizeLog(e), this.pluginName, { hook: this.hookName }));
355
+ error(e$1) {
356
+ return error(logPluginError(normalizeLog(e$1), this.pluginName, { hook: this.hookName }));
357
357
  }
358
358
  };
359
359
 
@@ -2210,7 +2210,7 @@ function validateOption(key, options) {
2210
2210
  const issuePaths = issue.path.map((path$1) => path$1.key);
2211
2211
  let issueMsg = issue.message;
2212
2212
  if (issue.type === "union") {
2213
- const subIssue = issue.issues?.find((i$1) => !(i$1.type !== issue.received && i$1.input === issue.input));
2213
+ const subIssue = issue.issues?.find((i) => !(i.type !== issue.received && i.input === issue.input));
2214
2214
  if (subIssue) {
2215
2215
  if (subIssue.path) issuePaths.push(subIssue.path.map((path$1) => path$1.key));
2216
2216
  issueMsg = subIssue.message;
@@ -2253,19 +2253,19 @@ function bindingifySourcemap$1(map) {
2253
2253
  //#endregion
2254
2254
  //#region src/utils/error.ts
2255
2255
  function normalizeErrors(rawErrors) {
2256
- const errors = rawErrors.map((e) => e instanceof Error ? e : Object.assign(/* @__PURE__ */ new Error(), {
2257
- kind: e.kind,
2258
- message: e.message,
2256
+ const errors = rawErrors.map((e$1) => e$1 instanceof Error ? e$1 : Object.assign(/* @__PURE__ */ new Error(), {
2257
+ kind: e$1.kind,
2258
+ message: e$1.message,
2259
2259
  stack: void 0
2260
2260
  }));
2261
2261
  let summary = `Build failed with ${errors.length} error${errors.length < 2 ? "" : "s"}:\n`;
2262
- for (let i$1 = 0; i$1 < errors.length; i$1++) {
2262
+ for (let i = 0; i < errors.length; i++) {
2263
2263
  summary += "\n";
2264
- if (i$1 >= 5) {
2264
+ if (i >= 5) {
2265
2265
  summary += "...";
2266
2266
  break;
2267
2267
  }
2268
- summary += getErrorMessage(errors[i$1]);
2268
+ summary += getErrorMessage(errors[i]);
2269
2269
  }
2270
2270
  const wrapper = new Error(summary);
2271
2271
  Object.defineProperty(wrapper, "errors", {
@@ -2280,20 +2280,20 @@ function normalizeErrors(rawErrors) {
2280
2280
  });
2281
2281
  return wrapper;
2282
2282
  }
2283
- function getErrorMessage(e) {
2284
- if (Object.hasOwn(e, "kind")) return e.message;
2283
+ function getErrorMessage(e$1) {
2284
+ if (Object.hasOwn(e$1, "kind")) return e$1.message;
2285
2285
  let s = "";
2286
- if (e.plugin) s += `[plugin ${e.plugin}]`;
2287
- const id = e.id ?? e.loc?.file;
2286
+ if (e$1.plugin) s += `[plugin ${e$1.plugin}]`;
2287
+ const id = e$1.id ?? e$1.loc?.file;
2288
2288
  if (id) {
2289
2289
  s += " " + id;
2290
- if (e.loc) s += `:${e.loc.line}:${e.loc.column}`;
2290
+ if (e$1.loc) s += `:${e$1.loc.line}:${e$1.loc.column}`;
2291
2291
  }
2292
2292
  if (s) s += "\n";
2293
- const message = `${e.name ?? "Error"}: ${e.message}`;
2293
+ const message = `${e$1.name ?? "Error"}: ${e$1.message}`;
2294
2294
  s += message;
2295
- if (e.frame) s = joinNewLine(s, e.frame);
2296
- if (e.stack) s = joinNewLine(s, e.stack.replace(message, ""));
2295
+ if (e$1.frame) s = joinNewLine(s, e$1.frame);
2296
+ if (e$1.stack) s = joinNewLine(s, e$1.stack.replace(message, ""));
2297
2297
  return s;
2298
2298
  }
2299
2299
  function joinNewLine(s1, s2) {
@@ -2337,33 +2337,33 @@ function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
2337
2337
  }
2338
2338
 
2339
2339
  //#endregion
2340
- //#region ../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-D6FCK2GA.js
2341
- function u$1(o, n, a) {
2342
- let t = (r) => o(r, ...n);
2343
- return a === void 0 ? t : Object.assign(t, {
2344
- lazy: a,
2345
- lazyArgs: n
2340
+ //#region ../../node_modules/.pnpm/remeda@2.30.0/node_modules/remeda/dist/lazyDataLastImpl-BDhrIOwR.js
2341
+ function e(e$1, t$2, n$1) {
2342
+ let r = (n$2) => e$1(n$2, ...t$2);
2343
+ return n$1 === void 0 ? r : Object.assign(r, {
2344
+ lazy: n$1,
2345
+ lazyArgs: t$2
2346
2346
  });
2347
2347
  }
2348
2348
 
2349
2349
  //#endregion
2350
- //#region ../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-WIMGWYZL.js
2351
- function u(r, n, o) {
2352
- let a = r.length - n.length;
2353
- if (a === 0) return r(...n);
2354
- if (a === 1) return u$1(r, n, o);
2355
- throw new Error("Wrong number of arguments");
2350
+ //#region ../../node_modules/.pnpm/remeda@2.30.0/node_modules/remeda/dist/purry-DH9cw9sy.js
2351
+ function t(t$2, n$1, r) {
2352
+ let i = t$2.length - n$1.length;
2353
+ if (i === 0) return t$2(...n$1);
2354
+ if (i === 1) return e(t$2, n$1, r);
2355
+ throw Error(`Wrong number of arguments`);
2356
2356
  }
2357
2357
 
2358
2358
  //#endregion
2359
- //#region ../../node_modules/.pnpm/remeda@2.28.0/node_modules/remeda/dist/chunk-3IFJP4R5.js
2360
- function d(...r) {
2361
- return u(i, r);
2362
- }
2363
- var i = (r, t) => {
2364
- let a = [[], []];
2365
- for (let [o, e] of r.entries()) t(e, o, r) ? a[0].push(e) : a[1].push(e);
2366
- return a;
2359
+ //#region ../../node_modules/.pnpm/remeda@2.30.0/node_modules/remeda/dist/partition-BJYkp-a7.js
2360
+ function t$1(...t$2) {
2361
+ return t(n, t$2);
2362
+ }
2363
+ const n = (e$1, t$2) => {
2364
+ let n$1 = [[], []];
2365
+ for (let [r, i] of e$1.entries()) t$2(i, r, e$1) ? n$1[0].push(i) : n$1[1].push(i);
2366
+ return n$1;
2367
2367
  };
2368
2368
 
2369
2369
  //#endregion
@@ -2388,8 +2388,8 @@ function transformFilterMatcherToFilterExprs(filterOption) {
2388
2388
  let idExcludes = [];
2389
2389
  let codeIncludes = [];
2390
2390
  let codeExcludes = [];
2391
- if (id) [idIncludes, idExcludes] = d(generalHookFilterMatcherToFilterExprs(id, "id") ?? [], (m) => m.kind === "include");
2392
- if (code) [codeIncludes, codeExcludes] = d(generalHookFilterMatcherToFilterExprs(code, "code") ?? [], (m) => m.kind === "include");
2391
+ if (id) [idIncludes, idExcludes] = t$1(generalHookFilterMatcherToFilterExprs(id, "id") ?? [], (m) => m.kind === "include");
2392
+ if (code) [codeIncludes, codeExcludes] = t$1(generalHookFilterMatcherToFilterExprs(code, "code") ?? [], (m) => m.kind === "include");
2393
2393
  ret.push(...idExcludes);
2394
2394
  ret.push(...codeExcludes);
2395
2395
  let andExprList = [];
@@ -2417,7 +2417,7 @@ function bindingifyFilterExprImpl(expr, list) {
2417
2417
  switch (expr.kind) {
2418
2418
  case "and": {
2419
2419
  let args$1 = expr.args;
2420
- for (let i$1 = args$1.length - 1; i$1 >= 0; i$1--) bindingifyFilterExprImpl(args$1[i$1], list);
2420
+ for (let i = args$1.length - 1; i >= 0; i--) bindingifyFilterExprImpl(args$1[i], list);
2421
2421
  list.push({
2422
2422
  kind: "And",
2423
2423
  payload: args$1.length
@@ -2426,7 +2426,7 @@ function bindingifyFilterExprImpl(expr, list) {
2426
2426
  }
2427
2427
  case "or": {
2428
2428
  let args$1 = expr.args;
2429
- for (let i$1 = args$1.length - 1; i$1 >= 0; i$1--) bindingifyFilterExprImpl(args$1[i$1], list);
2429
+ for (let i = args$1.length - 1; i >= 0; i--) bindingifyFilterExprImpl(args$1[i], list);
2430
2430
  list.push({
2431
2431
  kind: "Or",
2432
2432
  payload: args$1.length
@@ -2576,10 +2576,10 @@ var PluginContextImpl = class extends MinimalPluginContextImpl {
2576
2576
  data.loadModulePromiseMap.set(id, promise$1);
2577
2577
  try {
2578
2578
  await context.load(id, options.moduleSideEffects ?? void 0);
2579
- } catch (e) {
2579
+ } catch (e$1) {
2580
2580
  data.loadModulePromiseMap.delete(id);
2581
2581
  data.loadModulePromiseResolveFnMap.delete(id);
2582
- throw e;
2582
+ throw e$1;
2583
2583
  }
2584
2584
  return promise$1;
2585
2585
  }
@@ -2666,12 +2666,12 @@ var TransformPluginContextImpl = class extends PluginContextImpl {
2666
2666
  this.warn = getLogHandler$1(this.warn);
2667
2667
  this.info = getLogHandler$1(this.info);
2668
2668
  }
2669
- error(e, pos) {
2670
- if (typeof e === "string") e = { message: e };
2671
- if (pos) augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
2672
- e.id = this.moduleId;
2673
- e.hook = "transform";
2674
- return error(logPluginError(normalizeLog(e), this.pluginName));
2669
+ error(e$1, pos) {
2670
+ if (typeof e$1 === "string") e$1 = { message: e$1 };
2671
+ if (pos) augmentCodeLocation(e$1, pos, this.moduleSource, this.moduleId);
2672
+ e$1.id = this.moduleId;
2673
+ e$1.hook = "transform";
2674
+ return error(logPluginError(normalizeLog(e$1), this.pluginName));
2675
2675
  }
2676
2676
  getCombinedSourcemap() {
2677
2677
  return JSON.parse(this.inner.getCombinedSourcemap());
@@ -2897,9 +2897,9 @@ function transformRenderedChunk(chunk) {
2897
2897
  }
2898
2898
  function transformChunkModules(modules) {
2899
2899
  const result = {};
2900
- for (let i$1 = 0; i$1 < modules.values.length; i$1++) {
2901
- let key = modules.keys[i$1];
2902
- const mod = modules.values[i$1];
2900
+ for (let i = 0; i < modules.values.length; i++) {
2901
+ let key = modules.keys[i];
2902
+ const mod = modules.values[i];
2903
2903
  result[key] = transformToRenderedModule(mod);
2904
2904
  }
2905
2905
  return result;
@@ -3408,8 +3408,8 @@ function wrapHandlers(plugin) {
3408
3408
  if (handler) plugin[hookName] = async (...args$1) => {
3409
3409
  try {
3410
3410
  return await handler(...args$1);
3411
- } catch (e) {
3412
- return error(logPluginError(e, plugin.name, {
3411
+ } catch (e$1) {
3412
+ return error(logPluginError(e$1, plugin.name, {
3413
3413
  hook: hookName,
3414
3414
  id: hookName === "transform" ? args$1[2] : void 0
3415
3415
  }));
@@ -3439,6 +3439,9 @@ var NormalizedInputOptionsImpl = class {
3439
3439
  get platform() {
3440
3440
  return this.inner.platform;
3441
3441
  }
3442
+ get context() {
3443
+ return this.inner.context;
3444
+ }
3442
3445
  };
3443
3446
 
3444
3447
  //#endregion
@@ -4070,7 +4073,7 @@ async function initializeParallelPlugins(plugins) {
4070
4073
  };
4071
4074
  }
4072
4075
  function initializeWorkers(registryId, count, pluginInfos) {
4073
- return Promise.all(Array.from({ length: count }, (_, i$1) => initializeWorker(registryId, pluginInfos, i$1)));
4076
+ return Promise.all(Array.from({ length: count }, (_, i) => initializeWorker(registryId, pluginInfos, i)));
4074
4077
  }
4075
4078
  async function initializeWorker(registryId, pluginInfos, threadNumber) {
4076
4079
  const urlString = import.meta.resolve("#parallel-plugin-worker");
@@ -4090,9 +4093,9 @@ async function initializeWorker(registryId, pluginInfos, threadNumber) {
4090
4093
  });
4091
4094
  });
4092
4095
  return worker;
4093
- } catch (e) {
4096
+ } catch (e$1) {
4094
4097
  worker?.terminate();
4095
- throw e;
4098
+ throw e$1;
4096
4099
  }
4097
4100
  }
4098
4101
  const availableParallelism = () => {
@@ -4108,12 +4111,12 @@ const availableParallelism = () => {
4108
4111
 
4109
4112
  //#endregion
4110
4113
  //#region src/utils/create-bundler-option.ts
4111
- async function createBundlerOptions(inputOptions, outputOptions, watchMode, isClose) {
4114
+ async function createBundlerOptions(inputOptions, outputOptions, watchMode) {
4112
4115
  const inputPlugins = await normalizePluginOption(inputOptions.plugins);
4113
4116
  const outputPlugins = await normalizePluginOption(outputOptions.plugins);
4114
4117
  const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
4115
4118
  const onLog = getLogger(getObjectPlugins(inputPlugins), getOnLog(inputOptions, logLevel), logLevel, watchMode);
4116
- if (!isClose) outputOptions = PluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions, onLog, logLevel, watchMode);
4119
+ outputOptions = PluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions, onLog, logLevel, watchMode);
4117
4120
  const normalizedOutputPlugins = await normalizePluginOption(outputOptions.plugins);
4118
4121
  let plugins = [
4119
4122
  ...BUILTIN_PLUGINS,
@@ -4134,17 +4137,17 @@ async function createBundlerOptions(inputOptions, outputOptions, watchMode, isCl
4134
4137
  onLog,
4135
4138
  stopWorkers: parallelPluginInitResult?.stopWorkers
4136
4139
  };
4137
- } catch (e) {
4140
+ } catch (e$1) {
4138
4141
  await parallelPluginInitResult?.stopWorkers();
4139
- throw e;
4142
+ throw e$1;
4140
4143
  }
4141
4144
  }
4142
4145
 
4143
4146
  //#endregion
4144
4147
  //#region src/utils/create-bundler.ts
4145
4148
  let asyncRuntimeShutdown = false;
4146
- async function createBundlerImpl(bundler, inputOptions, outputOptions, isClose) {
4147
- const option = await createBundlerOptions(inputOptions, outputOptions, false, isClose);
4149
+ async function createBundlerImpl(bundler, inputOptions, outputOptions) {
4150
+ const option = await createBundlerOptions(inputOptions, outputOptions, false);
4148
4151
  if (asyncRuntimeShutdown) startAsyncRuntime();
4149
4152
  try {
4150
4153
  return {
@@ -4155,9 +4158,9 @@ async function createBundlerImpl(bundler, inputOptions, outputOptions, isClose)
4155
4158
  asyncRuntimeShutdown = true;
4156
4159
  }
4157
4160
  };
4158
- } catch (e) {
4161
+ } catch (e$1) {
4159
4162
  await option.stopWorkers?.();
4160
- throw e;
4163
+ throw e$1;
4161
4164
  }
4162
4165
  }
4163
4166
 
@@ -4185,11 +4188,11 @@ var RolldownBuild = class {
4185
4188
  this.#bundler = new BindingBundler();
4186
4189
  }
4187
4190
  get closed() {
4188
- return this.#bundlerImpl?.impl.closed ?? false;
4191
+ return this.#bundlerImpl?.impl.closed ?? true;
4189
4192
  }
4190
- async #getBundlerWithStopWorker(outputOptions, isClose) {
4193
+ async #getBundlerWithStopWorker(outputOptions) {
4191
4194
  if (this.#bundlerImpl) await this.#bundlerImpl.stopWorkers?.();
4192
- return this.#bundlerImpl = await createBundlerImpl(this.#bundler, this.#inputOptions, outputOptions, isClose);
4195
+ return this.#bundlerImpl = await createBundlerImpl(this.#bundler, this.#inputOptions, outputOptions);
4193
4196
  }
4194
4197
  async generate(outputOptions = {}) {
4195
4198
  validateOption("output", outputOptions);
@@ -4204,10 +4207,12 @@ var RolldownBuild = class {
4204
4207
  return transformToRollupOutput(output);
4205
4208
  }
4206
4209
  async close() {
4207
- const { impl, stopWorkers, shutdown } = await this.#getBundlerWithStopWorker({}, true);
4208
- await stopWorkers?.();
4209
- await impl.close();
4210
- shutdown();
4210
+ if (this.#bundlerImpl) {
4211
+ await this.#bundlerImpl.stopWorkers?.();
4212
+ await this.#bundlerImpl.impl.close();
4213
+ this.#bundlerImpl.shutdown();
4214
+ this.#bundlerImpl = void 0;
4215
+ }
4211
4216
  }
4212
4217
  async [Symbol.asyncDispose]() {
4213
4218
  await this.close();