rolldown 0.15.0-snapshot-3cea4f5-20241211003613 → 0.15.1-commit.09cccaf

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 (40) hide show
  1. package/dist/cjs/cli.cjs +78 -26
  2. package/dist/cjs/experimental-index.cjs +1 -1
  3. package/dist/cjs/index.cjs +1 -1
  4. package/dist/cjs/parallel-plugin-worker.cjs +1 -1
  5. package/dist/esm/cli.mjs +80 -28
  6. package/dist/esm/experimental-index.mjs +1 -1
  7. package/dist/esm/index.mjs +1 -1
  8. package/dist/esm/parallel-plugin-worker.mjs +1 -1
  9. package/dist/shared/{src-DYANT4eY.cjs → src-BKghi7SX.cjs} +127 -108
  10. package/dist/shared/{src-0e08MJIp.mjs → src-BKlslLnW.mjs} +127 -108
  11. package/dist/tsconfig.dts.tsbuildinfo +1 -1
  12. package/dist/types/binding.d.ts +8 -2
  13. package/dist/types/cli/load-config.d.ts +3 -0
  14. package/dist/types/cli/{utils.d.ts → logger.d.ts} +0 -2
  15. package/dist/types/index.d.ts +3 -4
  16. package/dist/types/log/logHandler.d.ts +1 -1
  17. package/dist/types/log/logger.d.ts +1 -1
  18. package/dist/types/log/logs.d.ts +2 -1
  19. package/dist/types/options/input-options.d.ts +10 -2
  20. package/dist/types/options/normalized-input-options.d.ts +1 -1
  21. package/dist/types/options/normalized-output-options.d.ts +3 -2
  22. package/dist/types/options/output-options.d.ts +3 -3
  23. package/dist/types/plugin/bindingify-plugin.d.ts +1 -1
  24. package/dist/types/plugin/index.d.ts +6 -6
  25. package/dist/types/plugin/minimal-plugin-context.d.ts +4 -4
  26. package/dist/types/plugin/plugin-context.d.ts +15 -11
  27. package/dist/types/plugin/transform-plugin-context.d.ts +8 -5
  28. package/dist/types/types/misc.d.ts +40 -0
  29. package/dist/types/types/module-info.d.ts +1 -0
  30. package/dist/types/types/output-bundle.d.ts +2 -2
  31. package/dist/types/types/rolldown-output.d.ts +8 -11
  32. package/dist/types/utils/bindingify-input-options.d.ts +1 -1
  33. package/dist/types/utils/create-bundler-option.d.ts +1 -1
  34. package/dist/types/utils/misc.d.ts +1 -2
  35. package/dist/types/utils/normalize-plugin-option.d.ts +1 -1
  36. package/dist/types/utils/transform-rendered-chunk.d.ts +4 -4
  37. package/dist/types/utils/transform-rendered-module.d.ts +2 -2
  38. package/package.json +17 -17
  39. package/dist/types/rollup-types.d.ts +0 -1
  40. package/dist/types/rollup.d.ts +0 -1118
@@ -606,9 +606,7 @@ function unreachable(info) {
606
606
  throw new Error("unreachable");
607
607
  }
608
608
  function unsupported(info) {
609
- return () => {
610
- throw new Error(`UNSUPPORTED: ${info}`);
611
- };
609
+ throw new Error(`UNSUPPORTED: ${info}`);
612
610
  }
613
611
  function noop(..._args) {}
614
612
 
@@ -723,7 +721,13 @@ function locate(source, search, options) {
723
721
 
724
722
  //#endregion
725
723
  //#region src/log/logs.ts
726
- 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";
724
+ 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", MINIFY_WARNING = "MINIFY_WARNING";
725
+ function logMinifyWarning() {
726
+ return {
727
+ code: MINIFY_WARNING,
728
+ message: "The built-in minifier is still under development. Setting \"minify: true\" is not recommended for production use."
729
+ };
730
+ }
727
731
  function logInvalidLogPosition(pluginName) {
728
732
  return {
729
733
  code: INVALID_LOG_POSITION,
@@ -851,7 +855,8 @@ function getLogger(plugins, onLog, logLevel) {
851
855
  rolldownVersion: VERSION,
852
856
  watchMode: false
853
857
  },
854
- warn: getLogHandler$1(LOG_LEVEL_WARN)
858
+ warn: getLogHandler$1(LOG_LEVEL_WARN),
859
+ pluginName: plugin.name || "unknown"
855
860
  }, level, log) === false) return;
856
861
  }
857
862
  }
@@ -1074,7 +1079,8 @@ var PluginDriver = class {
1074
1079
  rolldownVersion: VERSION,
1075
1080
  watchMode: false
1076
1081
  },
1077
- warn: getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", logger, name, logLevel)
1082
+ warn: getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", logger, name, logLevel),
1083
+ pluginName: name
1078
1084
  }, inputOptions);
1079
1085
  if (result) inputOptions = result;
1080
1086
  }
@@ -1174,6 +1180,7 @@ function transformModuleInfo(info, option) {
1174
1180
  dynamicImporters: info.dynamicImporters,
1175
1181
  importedIds: info.importedIds,
1176
1182
  dynamicallyImportedIds: info.dynamicallyImportedIds,
1183
+ exports: info.exports,
1177
1184
  isEntry: info.isEntry,
1178
1185
  ...option
1179
1186
  };
@@ -1186,21 +1193,20 @@ var MinimalPluginContext = class {
1186
1193
  warn;
1187
1194
  debug;
1188
1195
  meta;
1189
- error;
1190
- constructor(onLog, logLevel, plugin) {
1191
- const pluginName = plugin.name || "unknown";
1196
+ constructor(onLog, logLevel, pluginName) {
1197
+ this.pluginName = pluginName;
1192
1198
  this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
1193
1199
  this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
1194
1200
  this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
1195
- this.error = (e) => {
1196
- return error(logPluginError(normalizeLog(e), pluginName));
1197
- };
1198
1201
  this.meta = {
1199
1202
  rollupVersion: "4.23.0",
1200
1203
  rolldownVersion: VERSION,
1201
1204
  watchMode: false
1202
1205
  };
1203
1206
  }
1207
+ error(e) {
1208
+ return error(logPluginError(normalizeLog(e), this.pluginName));
1209
+ }
1204
1210
  };
1205
1211
 
1206
1212
  //#endregion
@@ -1220,84 +1226,92 @@ function bindingifySideEffects(sideEffects) {
1220
1226
  //#endregion
1221
1227
  //#region src/plugin/plugin-context.ts
1222
1228
  var PluginContext = class extends MinimalPluginContext {
1223
- load;
1224
- resolve;
1225
- emitFile;
1226
- getFileName;
1227
- getModuleInfo;
1228
- getModuleIds;
1229
- addWatchFile;
1230
- /**
1231
- * @deprecated This rollup API won't be supported by rolldown. Using this API will cause runtime error.
1232
- */
1233
- parse;
1234
1229
  constructor(context, plugin, data, onLog, logLevel, currentLoadingModule) {
1235
- super(onLog, logLevel, plugin);
1236
- this.load = async ({ id,...options }) => {
1237
- if (id === currentLoadingModule) onLog(LOG_LEVEL_WARN, logCycleLoading(plugin.name, currentLoadingModule));
1238
- const moduleInfo = data.getModuleInfo(id, context);
1239
- if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
1240
- const rawOptions = {
1241
- meta: options.meta || {},
1242
- moduleSideEffects: options.moduleSideEffects || null
1243
- };
1244
- data.updateModuleOption(id, rawOptions);
1245
- async function createLoadModulePromise() {
1246
- const loadPromise = data.loadModulePromiseMap.get(id);
1247
- if (loadPromise) return loadPromise;
1248
- let resolveFn;
1249
- const promise = new Promise((resolve, _) => {
1250
- resolveFn = resolve;
1251
- });
1252
- data.loadModulePromiseMap.set(id, promise);
1253
- try {
1254
- await context.load(id, bindingifySideEffects(options.moduleSideEffects), resolveFn);
1255
- } finally {
1256
- data.loadModulePromiseMap.delete(id);
1257
- }
1258
- return promise;
1259
- }
1260
- await createLoadModulePromise();
1261
- return data.getModuleInfo(id, context);
1262
- };
1263
- this.resolve = async (source, importer, options) => {
1264
- let receipt = undefined;
1265
- if (options != null) receipt = data.saveResolveOptions(options);
1266
- const res = await context.resolve(source, importer, {
1267
- custom: receipt,
1268
- skipSelf: options?.skipSelf
1269
- });
1270
- if (receipt != null) data.removeSavedResolveOptions(receipt);
1271
- if (res == null) return null;
1272
- const info = data.getModuleOption(res.id) || {};
1273
- return {
1274
- ...res,
1275
- ...info
1276
- };
1230
+ super(onLog, logLevel, plugin.name);
1231
+ this.context = context;
1232
+ this.data = data;
1233
+ this.onLog = onLog;
1234
+ this.currentLoadingModule = currentLoadingModule;
1235
+ }
1236
+ async load(options) {
1237
+ const id = options.id;
1238
+ if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
1239
+ const moduleInfo = this.data.getModuleInfo(id, this.context);
1240
+ if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
1241
+ const rawOptions = {
1242
+ meta: options.meta || {},
1243
+ moduleSideEffects: options.moduleSideEffects || null
1277
1244
  };
1278
- this.emitFile = (file) => {
1279
- if (file.type !== "asset") return unimplemented("PluginContext.emitFile: only asset type is supported");
1280
- return context.emitFile({
1281
- ...file,
1282
- originalFileName: file.originalFileName || undefined,
1283
- source: bindingAssetSource(file.source)
1245
+ this.data.updateModuleOption(id, rawOptions);
1246
+ async function createLoadModulePromise(context, data) {
1247
+ const loadPromise = data.loadModulePromiseMap.get(id);
1248
+ if (loadPromise) return loadPromise;
1249
+ let resolveFn;
1250
+ const promise = new Promise((resolve, _) => {
1251
+ resolveFn = resolve;
1284
1252
  });
1253
+ data.loadModulePromiseMap.set(id, promise);
1254
+ try {
1255
+ await context.load(id, bindingifySideEffects(options.moduleSideEffects), resolveFn);
1256
+ } finally {
1257
+ data.loadModulePromiseMap.delete(id);
1258
+ }
1259
+ return promise;
1260
+ }
1261
+ await createLoadModulePromise(this.context, this.data);
1262
+ return this.data.getModuleInfo(id, this.context);
1263
+ }
1264
+ async resolve(source, importer, options) {
1265
+ let receipt = undefined;
1266
+ if (options != null) receipt = this.data.saveResolveOptions(options);
1267
+ const res = await this.context.resolve(source, importer, {
1268
+ custom: receipt,
1269
+ skipSelf: options?.skipSelf
1270
+ });
1271
+ if (receipt != null) this.data.removeSavedResolveOptions(receipt);
1272
+ if (res == null) return null;
1273
+ const info = this.data.getModuleOption(res.id) || {};
1274
+ return {
1275
+ ...res,
1276
+ ...info
1285
1277
  };
1286
- this.getFileName = context.getFileName.bind(context);
1287
- this.getModuleInfo = (id) => data.getModuleInfo(id, context);
1288
- this.getModuleIds = () => data.getModuleIds(context);
1289
- this.parse = unsupported("`PluginContext#parse` is not supported by rolldown.");
1290
- this.addWatchFile = context.addWatchFile.bind(context);
1278
+ }
1279
+ emitFile(file) {
1280
+ if (file.type !== "asset") return unimplemented("PluginContext.emitFile: only asset type is supported");
1281
+ return this.context.emitFile({
1282
+ ...file,
1283
+ originalFileName: file.originalFileName || undefined,
1284
+ source: bindingAssetSource(file.source)
1285
+ });
1286
+ }
1287
+ getFileName(referenceId) {
1288
+ return this.context.getFileName(referenceId);
1289
+ }
1290
+ getModuleInfo(id) {
1291
+ return this.data.getModuleInfo(id, this.context);
1292
+ }
1293
+ getModuleIds() {
1294
+ return this.data.getModuleIds(this.context);
1295
+ }
1296
+ addWatchFile(id) {
1297
+ this.context.addWatchFile(id);
1298
+ }
1299
+ /**
1300
+ * @deprecated This rollup API won't be supported by rolldown. Using this API will cause runtime error.
1301
+ */
1302
+ parse(_input, _options) {
1303
+ unsupported("`PluginContext#parse` is not supported by rolldown.");
1291
1304
  }
1292
1305
  };
1293
1306
 
1294
1307
  //#endregion
1295
1308
  //#region src/plugin/transform-plugin-context.ts
1296
1309
  var TransformPluginContext = class extends PluginContext {
1297
- error;
1298
- getCombinedSourcemap;
1299
1310
  constructor(context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption) {
1300
1311
  super(context, plugin, data, onLog, LogLevelOption, moduleId);
1312
+ this.inner = inner;
1313
+ this.moduleId = moduleId;
1314
+ this.moduleSource = moduleSource;
1301
1315
  const getLogHandler$1 = (handler) => (log, pos) => {
1302
1316
  log = normalizeLog(log);
1303
1317
  if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
@@ -1308,14 +1322,16 @@ var TransformPluginContext = class extends PluginContext {
1308
1322
  this.debug = getLogHandler$1(this.debug);
1309
1323
  this.warn = getLogHandler$1(this.warn);
1310
1324
  this.info = getLogHandler$1(this.info);
1311
- this.error = (e, pos) => {
1312
- if (typeof e === "string") e = { message: e };
1313
- if (pos) augmentCodeLocation(e, pos, moduleSource, moduleId);
1314
- e.id = moduleId;
1315
- e.hook = "transform";
1316
- return error(logPluginError(normalizeLog(e), plugin.name || "unknown"));
1317
- };
1318
- this.getCombinedSourcemap = () => JSON.parse(inner.getCombinedSourcemap());
1325
+ }
1326
+ error(e, pos) {
1327
+ if (typeof e === "string") e = { message: e };
1328
+ if (pos) augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
1329
+ e.id = this.moduleId;
1330
+ e.hook = "transform";
1331
+ return error(logPluginError(normalizeLog(e), this.pluginName));
1332
+ }
1333
+ getCombinedSourcemap() {
1334
+ return JSON.parse(this.inner.getCombinedSourcemap());
1319
1335
  }
1320
1336
  };
1321
1337
 
@@ -1548,7 +1564,9 @@ function bindingifyModuleParsed(args) {
1548
1564
  //#endregion
1549
1565
  //#region src/options/normalized-output-options.ts
1550
1566
  function mapFunctionOption(option, name) {
1551
- return typeof option === "undefined" ? unsupported(`You should not take \`NormalizedOutputOptions#${name}\` and call it directly`) : option;
1567
+ return typeof option === "undefined" ? () => {
1568
+ unsupported(`You should not take \`NormalizedOutputOptions#${name}\` and call it directly`);
1569
+ } : option;
1552
1570
  }
1553
1571
  var NormalizedOutputOptionsImpl = class {
1554
1572
  inner;
@@ -2100,15 +2118,20 @@ function bindingifyInput(input) {
2100
2118
  });
2101
2119
  }
2102
2120
  function bindingifyJsx(input) {
2121
+ if (input === false) return { type: "Disable" };
2103
2122
  if (input) {
2104
- const mode = input.mode ?? "classic";
2123
+ if (input.mode === "preserve") return { type: "Preserve" };
2124
+ const mode = input.mode ?? "automatic";
2105
2125
  return {
2106
- runtime: mode,
2107
- importSource: mode === "classic" ? input.importSource : mode === "automatic" ? input.jsxImportSource : undefined,
2108
- pragma: input.factory,
2109
- pragmaFrag: input.fragment,
2110
- development: input.development,
2111
- refresh: input.refresh
2126
+ type: "Enable",
2127
+ field0: {
2128
+ runtime: mode,
2129
+ importSource: mode === "classic" ? input.importSource : mode === "automatic" ? input.jsxImportSource : undefined,
2130
+ pragma: input.factory,
2131
+ pragmaFrag: input.fragment,
2132
+ development: input.development,
2133
+ refresh: input.refresh
2134
+ }
2112
2135
  };
2113
2136
  }
2114
2137
  }
@@ -2343,10 +2366,7 @@ function createComposedPlugin(plugins) {
2343
2366
  const createFixedPluginResolveFnMap = new Map();
2344
2367
  function applyFixedPluginResolveFn(ctx, plugin) {
2345
2368
  const createFixedPluginResolveFn = createFixedPluginResolveFnMap.get(plugin);
2346
- if (createFixedPluginResolveFn) return {
2347
- ...ctx,
2348
- resolve: createFixedPluginResolveFn(ctx)
2349
- };
2369
+ if (createFixedPluginResolveFn) ctx.resolve = createFixedPluginResolveFn(ctx, ctx.resolve.bind(ctx));
2350
2370
  return ctx;
2351
2371
  }
2352
2372
  if (batchedHooks.resolveId) {
@@ -2355,14 +2375,14 @@ function createComposedPlugin(plugins) {
2355
2375
  for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
2356
2376
  const [_handler, plugin] = batchedHandlers[handlerIdx];
2357
2377
  const handlerSymbol = handlerSymbols[handlerIdx];
2358
- const createFixedPluginResolveFn = (ctx) => {
2378
+ const createFixedPluginResolveFn = (ctx, resolve) => {
2359
2379
  return (source, importer, rawContextResolveOptions) => {
2360
2380
  const contextResolveOptions = rawContextResolveOptions ?? {};
2361
2381
  if (contextResolveOptions.skipSelf) {
2362
2382
  contextResolveOptions[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF] = handlerSymbol;
2363
2383
  contextResolveOptions.skipSelf = false;
2364
2384
  }
2365
- return ctx.resolve(source, importer, contextResolveOptions);
2385
+ return resolve(source, importer, contextResolveOptions);
2366
2386
  };
2367
2387
  };
2368
2388
  createFixedPluginResolveFnMap.set(plugin, createFixedPluginResolveFn);
@@ -2420,12 +2440,10 @@ function createComposedPlugin(plugins) {
2420
2440
  }
2421
2441
  for (const [handler, plugin] of batchedHandlers) {
2422
2442
  const { handler: handlerFn } = normalizeHook(handler);
2423
- const result = await handlerFn.call({
2424
- ...applyFixedPluginResolveFn(this, plugin),
2425
- getCombinedSourcemap() {
2426
- throw new Error(`The getCombinedSourcemap is not implement in transform hook at composedJsPlugins`);
2427
- }
2428
- }, code, id, moduleType);
2443
+ this.getCombinedSourcemap = () => {
2444
+ throw new Error(`The getCombinedSourcemap is not implement in transform hook at composedJsPlugins`);
2445
+ };
2446
+ const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code, id, moduleType);
2429
2447
  if (!isNullish(result)) {
2430
2448
  if (typeof result === "string") updateOutput(result);
2431
2449
  else if (result.code) updateOutput(result.code, result.moduleSideEffects);
@@ -2619,9 +2637,10 @@ async function createBundlerOptions(inputOptions, outputOptions) {
2619
2637
  if (inputOptions.treeshake !== undefined) TreeshakingOptionsSchema.parse(inputOptions.treeshake);
2620
2638
  const inputPlugins = await normalizePluginOption(inputOptions.plugins);
2621
2639
  const outputPlugins = await normalizePluginOption(outputOptions.plugins);
2622
- outputOptions = pluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions);
2623
2640
  const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
2624
2641
  const onLog = getLogger(getObjectPlugins(inputPlugins), getOnLog(inputOptions, logLevel), logLevel);
2642
+ outputOptions = pluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions);
2643
+ if (outputOptions.minify === true) onLog(LOG_LEVEL_WARN, logMinifyWarning());
2625
2644
  let plugins = [...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX), ...checkOutputPluginOption(normalizePlugins(await normalizePluginOption(outputOptions.plugins), ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)];
2626
2645
  if (inputOptions.experimental?.enableComposingJsPlugins ?? false) plugins = composeJsPlugins(plugins);
2627
2646
  const parallelPluginInitResult = await initializeParallelPlugins(plugins);
@@ -2824,7 +2843,7 @@ const watch = (input) => {
2824
2843
 
2825
2844
  //#endregion
2826
2845
  //#region package.json
2827
- var version = "0.15.0";
2846
+ var version = "0.15.1-commit.09cccaf";
2828
2847
  var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
2829
2848
 
2830
2849
  //#endregion