rolldown 0.15.0-snapshot-3cea4f5-20241211003613 → 0.15.1-commit.10b045b

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--iQGF1P9.cjs} +127 -108
  10. package/dist/shared/{src-0e08MJIp.mjs → src-2pTf5dIo.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 +16 -16
  39. package/dist/types/rollup-types.d.ts +0 -1
  40. package/dist/types/rollup.d.ts +0 -1118
@@ -580,9 +580,7 @@ function unreachable(info) {
580
580
  throw new Error("unreachable");
581
581
  }
582
582
  function unsupported(info) {
583
- return () => {
584
- throw new Error(`UNSUPPORTED: ${info}`);
585
- };
583
+ throw new Error(`UNSUPPORTED: ${info}`);
586
584
  }
587
585
  function noop(..._args) {}
588
586
 
@@ -697,7 +695,13 @@ function locate(source, search, options) {
697
695
 
698
696
  //#endregion
699
697
  //#region src/log/logs.ts
700
- 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";
698
+ 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";
699
+ function logMinifyWarning() {
700
+ return {
701
+ code: MINIFY_WARNING,
702
+ message: "The built-in minifier is still under development. Setting \"minify: true\" is not recommended for production use."
703
+ };
704
+ }
701
705
  function logInvalidLogPosition(pluginName) {
702
706
  return {
703
707
  code: INVALID_LOG_POSITION,
@@ -825,7 +829,8 @@ function getLogger(plugins, onLog, logLevel) {
825
829
  rolldownVersion: VERSION,
826
830
  watchMode: false
827
831
  },
828
- warn: getLogHandler$1(LOG_LEVEL_WARN)
832
+ warn: getLogHandler$1(LOG_LEVEL_WARN),
833
+ pluginName: plugin.name || "unknown"
829
834
  }, level, log) === false) return;
830
835
  }
831
836
  }
@@ -1048,7 +1053,8 @@ var PluginDriver = class {
1048
1053
  rolldownVersion: VERSION,
1049
1054
  watchMode: false
1050
1055
  },
1051
- warn: getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", logger, name, logLevel)
1056
+ warn: getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", logger, name, logLevel),
1057
+ pluginName: name
1052
1058
  }, inputOptions);
1053
1059
  if (result) inputOptions = result;
1054
1060
  }
@@ -1148,6 +1154,7 @@ function transformModuleInfo(info, option) {
1148
1154
  dynamicImporters: info.dynamicImporters,
1149
1155
  importedIds: info.importedIds,
1150
1156
  dynamicallyImportedIds: info.dynamicallyImportedIds,
1157
+ exports: info.exports,
1151
1158
  isEntry: info.isEntry,
1152
1159
  ...option
1153
1160
  };
@@ -1160,21 +1167,20 @@ var MinimalPluginContext = class {
1160
1167
  warn;
1161
1168
  debug;
1162
1169
  meta;
1163
- error;
1164
- constructor(onLog, logLevel, plugin) {
1165
- const pluginName = plugin.name || "unknown";
1170
+ constructor(onLog, logLevel, pluginName) {
1171
+ this.pluginName = pluginName;
1166
1172
  this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
1167
1173
  this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
1168
1174
  this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
1169
- this.error = (e) => {
1170
- return error(logPluginError(normalizeLog(e), pluginName));
1171
- };
1172
1175
  this.meta = {
1173
1176
  rollupVersion: "4.23.0",
1174
1177
  rolldownVersion: VERSION,
1175
1178
  watchMode: false
1176
1179
  };
1177
1180
  }
1181
+ error(e) {
1182
+ return error(logPluginError(normalizeLog(e), this.pluginName));
1183
+ }
1178
1184
  };
1179
1185
 
1180
1186
  //#endregion
@@ -1194,84 +1200,92 @@ function bindingifySideEffects(sideEffects) {
1194
1200
  //#endregion
1195
1201
  //#region src/plugin/plugin-context.ts
1196
1202
  var PluginContext = class extends MinimalPluginContext {
1197
- load;
1198
- resolve;
1199
- emitFile;
1200
- getFileName;
1201
- getModuleInfo;
1202
- getModuleIds;
1203
- addWatchFile;
1204
- /**
1205
- * @deprecated This rollup API won't be supported by rolldown. Using this API will cause runtime error.
1206
- */
1207
- parse;
1208
1203
  constructor(context, plugin, data, onLog, logLevel, currentLoadingModule) {
1209
- super(onLog, logLevel, plugin);
1210
- this.load = async ({ id,...options }) => {
1211
- if (id === currentLoadingModule) onLog(LOG_LEVEL_WARN, logCycleLoading(plugin.name, currentLoadingModule));
1212
- const moduleInfo = data.getModuleInfo(id, context);
1213
- if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
1214
- const rawOptions = {
1215
- meta: options.meta || {},
1216
- moduleSideEffects: options.moduleSideEffects || null
1217
- };
1218
- data.updateModuleOption(id, rawOptions);
1219
- async function createLoadModulePromise() {
1220
- const loadPromise = data.loadModulePromiseMap.get(id);
1221
- if (loadPromise) return loadPromise;
1222
- let resolveFn;
1223
- const promise = new Promise((resolve, _) => {
1224
- resolveFn = resolve;
1225
- });
1226
- data.loadModulePromiseMap.set(id, promise);
1227
- try {
1228
- await context.load(id, bindingifySideEffects(options.moduleSideEffects), resolveFn);
1229
- } finally {
1230
- data.loadModulePromiseMap.delete(id);
1231
- }
1232
- return promise;
1233
- }
1234
- await createLoadModulePromise();
1235
- return data.getModuleInfo(id, context);
1236
- };
1237
- this.resolve = async (source, importer, options) => {
1238
- let receipt = undefined;
1239
- if (options != null) receipt = data.saveResolveOptions(options);
1240
- const res = await context.resolve(source, importer, {
1241
- custom: receipt,
1242
- skipSelf: options?.skipSelf
1243
- });
1244
- if (receipt != null) data.removeSavedResolveOptions(receipt);
1245
- if (res == null) return null;
1246
- const info = data.getModuleOption(res.id) || {};
1247
- return {
1248
- ...res,
1249
- ...info
1250
- };
1204
+ super(onLog, logLevel, plugin.name);
1205
+ this.context = context;
1206
+ this.data = data;
1207
+ this.onLog = onLog;
1208
+ this.currentLoadingModule = currentLoadingModule;
1209
+ }
1210
+ async load(options) {
1211
+ const id = options.id;
1212
+ if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
1213
+ const moduleInfo = this.data.getModuleInfo(id, this.context);
1214
+ if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
1215
+ const rawOptions = {
1216
+ meta: options.meta || {},
1217
+ moduleSideEffects: options.moduleSideEffects || null
1251
1218
  };
1252
- this.emitFile = (file) => {
1253
- if (file.type !== "asset") return unimplemented("PluginContext.emitFile: only asset type is supported");
1254
- return context.emitFile({
1255
- ...file,
1256
- originalFileName: file.originalFileName || undefined,
1257
- source: bindingAssetSource(file.source)
1219
+ this.data.updateModuleOption(id, rawOptions);
1220
+ async function createLoadModulePromise(context, data) {
1221
+ const loadPromise = data.loadModulePromiseMap.get(id);
1222
+ if (loadPromise) return loadPromise;
1223
+ let resolveFn;
1224
+ const promise = new Promise((resolve, _) => {
1225
+ resolveFn = resolve;
1258
1226
  });
1227
+ data.loadModulePromiseMap.set(id, promise);
1228
+ try {
1229
+ await context.load(id, bindingifySideEffects(options.moduleSideEffects), resolveFn);
1230
+ } finally {
1231
+ data.loadModulePromiseMap.delete(id);
1232
+ }
1233
+ return promise;
1234
+ }
1235
+ await createLoadModulePromise(this.context, this.data);
1236
+ return this.data.getModuleInfo(id, this.context);
1237
+ }
1238
+ async resolve(source, importer, options) {
1239
+ let receipt = undefined;
1240
+ if (options != null) receipt = this.data.saveResolveOptions(options);
1241
+ const res = await this.context.resolve(source, importer, {
1242
+ custom: receipt,
1243
+ skipSelf: options?.skipSelf
1244
+ });
1245
+ if (receipt != null) this.data.removeSavedResolveOptions(receipt);
1246
+ if (res == null) return null;
1247
+ const info = this.data.getModuleOption(res.id) || {};
1248
+ return {
1249
+ ...res,
1250
+ ...info
1259
1251
  };
1260
- this.getFileName = context.getFileName.bind(context);
1261
- this.getModuleInfo = (id) => data.getModuleInfo(id, context);
1262
- this.getModuleIds = () => data.getModuleIds(context);
1263
- this.parse = unsupported("`PluginContext#parse` is not supported by rolldown.");
1264
- this.addWatchFile = context.addWatchFile.bind(context);
1252
+ }
1253
+ emitFile(file) {
1254
+ if (file.type !== "asset") return unimplemented("PluginContext.emitFile: only asset type is supported");
1255
+ return this.context.emitFile({
1256
+ ...file,
1257
+ originalFileName: file.originalFileName || undefined,
1258
+ source: bindingAssetSource(file.source)
1259
+ });
1260
+ }
1261
+ getFileName(referenceId) {
1262
+ return this.context.getFileName(referenceId);
1263
+ }
1264
+ getModuleInfo(id) {
1265
+ return this.data.getModuleInfo(id, this.context);
1266
+ }
1267
+ getModuleIds() {
1268
+ return this.data.getModuleIds(this.context);
1269
+ }
1270
+ addWatchFile(id) {
1271
+ this.context.addWatchFile(id);
1272
+ }
1273
+ /**
1274
+ * @deprecated This rollup API won't be supported by rolldown. Using this API will cause runtime error.
1275
+ */
1276
+ parse(_input, _options) {
1277
+ unsupported("`PluginContext#parse` is not supported by rolldown.");
1265
1278
  }
1266
1279
  };
1267
1280
 
1268
1281
  //#endregion
1269
1282
  //#region src/plugin/transform-plugin-context.ts
1270
1283
  var TransformPluginContext = class extends PluginContext {
1271
- error;
1272
- getCombinedSourcemap;
1273
1284
  constructor(context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption) {
1274
1285
  super(context, plugin, data, onLog, LogLevelOption, moduleId);
1286
+ this.inner = inner;
1287
+ this.moduleId = moduleId;
1288
+ this.moduleSource = moduleSource;
1275
1289
  const getLogHandler$1 = (handler) => (log, pos) => {
1276
1290
  log = normalizeLog(log);
1277
1291
  if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
@@ -1282,14 +1296,16 @@ var TransformPluginContext = class extends PluginContext {
1282
1296
  this.debug = getLogHandler$1(this.debug);
1283
1297
  this.warn = getLogHandler$1(this.warn);
1284
1298
  this.info = getLogHandler$1(this.info);
1285
- this.error = (e, pos) => {
1286
- if (typeof e === "string") e = { message: e };
1287
- if (pos) augmentCodeLocation(e, pos, moduleSource, moduleId);
1288
- e.id = moduleId;
1289
- e.hook = "transform";
1290
- return error(logPluginError(normalizeLog(e), plugin.name || "unknown"));
1291
- };
1292
- this.getCombinedSourcemap = () => JSON.parse(inner.getCombinedSourcemap());
1299
+ }
1300
+ error(e, pos) {
1301
+ if (typeof e === "string") e = { message: e };
1302
+ if (pos) augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
1303
+ e.id = this.moduleId;
1304
+ e.hook = "transform";
1305
+ return error(logPluginError(normalizeLog(e), this.pluginName));
1306
+ }
1307
+ getCombinedSourcemap() {
1308
+ return JSON.parse(this.inner.getCombinedSourcemap());
1293
1309
  }
1294
1310
  };
1295
1311
 
@@ -1522,7 +1538,9 @@ function bindingifyModuleParsed(args) {
1522
1538
  //#endregion
1523
1539
  //#region src/options/normalized-output-options.ts
1524
1540
  function mapFunctionOption(option, name) {
1525
- return typeof option === "undefined" ? unsupported(`You should not take \`NormalizedOutputOptions#${name}\` and call it directly`) : option;
1541
+ return typeof option === "undefined" ? () => {
1542
+ unsupported(`You should not take \`NormalizedOutputOptions#${name}\` and call it directly`);
1543
+ } : option;
1526
1544
  }
1527
1545
  var NormalizedOutputOptionsImpl = class {
1528
1546
  inner;
@@ -2074,15 +2092,20 @@ function bindingifyInput(input) {
2074
2092
  });
2075
2093
  }
2076
2094
  function bindingifyJsx(input) {
2095
+ if (input === false) return { type: "Disable" };
2077
2096
  if (input) {
2078
- const mode = input.mode ?? "classic";
2097
+ if (input.mode === "preserve") return { type: "Preserve" };
2098
+ const mode = input.mode ?? "automatic";
2079
2099
  return {
2080
- runtime: mode,
2081
- importSource: mode === "classic" ? input.importSource : mode === "automatic" ? input.jsxImportSource : undefined,
2082
- pragma: input.factory,
2083
- pragmaFrag: input.fragment,
2084
- development: input.development,
2085
- refresh: input.refresh
2100
+ type: "Enable",
2101
+ field0: {
2102
+ runtime: mode,
2103
+ importSource: mode === "classic" ? input.importSource : mode === "automatic" ? input.jsxImportSource : undefined,
2104
+ pragma: input.factory,
2105
+ pragmaFrag: input.fragment,
2106
+ development: input.development,
2107
+ refresh: input.refresh
2108
+ }
2086
2109
  };
2087
2110
  }
2088
2111
  }
@@ -2317,10 +2340,7 @@ function createComposedPlugin(plugins) {
2317
2340
  const createFixedPluginResolveFnMap = new Map();
2318
2341
  function applyFixedPluginResolveFn(ctx, plugin) {
2319
2342
  const createFixedPluginResolveFn = createFixedPluginResolveFnMap.get(plugin);
2320
- if (createFixedPluginResolveFn) return {
2321
- ...ctx,
2322
- resolve: createFixedPluginResolveFn(ctx)
2323
- };
2343
+ if (createFixedPluginResolveFn) ctx.resolve = createFixedPluginResolveFn(ctx, ctx.resolve.bind(ctx));
2324
2344
  return ctx;
2325
2345
  }
2326
2346
  if (batchedHooks.resolveId) {
@@ -2329,14 +2349,14 @@ function createComposedPlugin(plugins) {
2329
2349
  for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
2330
2350
  const [_handler, plugin] = batchedHandlers[handlerIdx];
2331
2351
  const handlerSymbol = handlerSymbols[handlerIdx];
2332
- const createFixedPluginResolveFn = (ctx) => {
2352
+ const createFixedPluginResolveFn = (ctx, resolve) => {
2333
2353
  return (source, importer, rawContextResolveOptions) => {
2334
2354
  const contextResolveOptions = rawContextResolveOptions ?? {};
2335
2355
  if (contextResolveOptions.skipSelf) {
2336
2356
  contextResolveOptions[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF] = handlerSymbol;
2337
2357
  contextResolveOptions.skipSelf = false;
2338
2358
  }
2339
- return ctx.resolve(source, importer, contextResolveOptions);
2359
+ return resolve(source, importer, contextResolveOptions);
2340
2360
  };
2341
2361
  };
2342
2362
  createFixedPluginResolveFnMap.set(plugin, createFixedPluginResolveFn);
@@ -2394,12 +2414,10 @@ function createComposedPlugin(plugins) {
2394
2414
  }
2395
2415
  for (const [handler, plugin] of batchedHandlers) {
2396
2416
  const { handler: handlerFn } = normalizeHook(handler);
2397
- const result = await handlerFn.call({
2398
- ...applyFixedPluginResolveFn(this, plugin),
2399
- getCombinedSourcemap() {
2400
- throw new Error(`The getCombinedSourcemap is not implement in transform hook at composedJsPlugins`);
2401
- }
2402
- }, code, id, moduleType);
2417
+ this.getCombinedSourcemap = () => {
2418
+ throw new Error(`The getCombinedSourcemap is not implement in transform hook at composedJsPlugins`);
2419
+ };
2420
+ const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code, id, moduleType);
2403
2421
  if (!isNullish(result)) {
2404
2422
  if (typeof result === "string") updateOutput(result);
2405
2423
  else if (result.code) updateOutput(result.code, result.moduleSideEffects);
@@ -2593,9 +2611,10 @@ async function createBundlerOptions(inputOptions, outputOptions) {
2593
2611
  if (inputOptions.treeshake !== undefined) TreeshakingOptionsSchema.parse(inputOptions.treeshake);
2594
2612
  const inputPlugins = await normalizePluginOption(inputOptions.plugins);
2595
2613
  const outputPlugins = await normalizePluginOption(outputOptions.plugins);
2596
- outputOptions = pluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions);
2597
2614
  const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
2598
2615
  const onLog = getLogger(getObjectPlugins(inputPlugins), getOnLog(inputOptions, logLevel), logLevel);
2616
+ outputOptions = pluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions);
2617
+ if (outputOptions.minify === true) onLog(LOG_LEVEL_WARN, logMinifyWarning());
2599
2618
  let plugins = [...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX), ...checkOutputPluginOption(normalizePlugins(await normalizePluginOption(outputOptions.plugins), ANONYMOUS_OUTPUT_PLUGIN_PREFIX), onLog)];
2600
2619
  if (inputOptions.experimental?.enableComposingJsPlugins ?? false) plugins = composeJsPlugins(plugins);
2601
2620
  const parallelPluginInitResult = await initializeParallelPlugins(plugins);
@@ -2798,7 +2817,7 @@ const watch = (input) => {
2798
2817
 
2799
2818
  //#endregion
2800
2819
  //#region package.json
2801
- var version = "0.15.0";
2820
+ var version = "0.15.1-commit.10b045b";
2802
2821
  var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
2803
2822
 
2804
2823
  //#endregion