rolldown 0.15.0-snapshot-3cea4f5-20241211003613 → 0.15.1-commit.4e41a08

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.
@@ -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
 
@@ -851,7 +849,8 @@ function getLogger(plugins, onLog, logLevel) {
851
849
  rolldownVersion: VERSION,
852
850
  watchMode: false
853
851
  },
854
- warn: getLogHandler$1(LOG_LEVEL_WARN)
852
+ warn: getLogHandler$1(LOG_LEVEL_WARN),
853
+ pluginName: plugin.name || "unknown"
855
854
  }, level, log) === false) return;
856
855
  }
857
856
  }
@@ -1074,7 +1073,8 @@ var PluginDriver = class {
1074
1073
  rolldownVersion: VERSION,
1075
1074
  watchMode: false
1076
1075
  },
1077
- warn: getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", logger, name, logLevel)
1076
+ warn: getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", logger, name, logLevel),
1077
+ pluginName: name
1078
1078
  }, inputOptions);
1079
1079
  if (result) inputOptions = result;
1080
1080
  }
@@ -1174,6 +1174,7 @@ function transformModuleInfo(info, option) {
1174
1174
  dynamicImporters: info.dynamicImporters,
1175
1175
  importedIds: info.importedIds,
1176
1176
  dynamicallyImportedIds: info.dynamicallyImportedIds,
1177
+ exports: info.exports,
1177
1178
  isEntry: info.isEntry,
1178
1179
  ...option
1179
1180
  };
@@ -1186,21 +1187,20 @@ var MinimalPluginContext = class {
1186
1187
  warn;
1187
1188
  debug;
1188
1189
  meta;
1189
- error;
1190
- constructor(onLog, logLevel, plugin) {
1191
- const pluginName = plugin.name || "unknown";
1190
+ constructor(onLog, logLevel, pluginName) {
1191
+ this.pluginName = pluginName;
1192
1192
  this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
1193
1193
  this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
1194
1194
  this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
1195
- this.error = (e) => {
1196
- return error(logPluginError(normalizeLog(e), pluginName));
1197
- };
1198
1195
  this.meta = {
1199
1196
  rollupVersion: "4.23.0",
1200
1197
  rolldownVersion: VERSION,
1201
1198
  watchMode: false
1202
1199
  };
1203
1200
  }
1201
+ error(e) {
1202
+ return error(logPluginError(normalizeLog(e), this.pluginName));
1203
+ }
1204
1204
  };
1205
1205
 
1206
1206
  //#endregion
@@ -1220,84 +1220,92 @@ function bindingifySideEffects(sideEffects) {
1220
1220
  //#endregion
1221
1221
  //#region src/plugin/plugin-context.ts
1222
1222
  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
1223
  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
- };
1224
+ super(onLog, logLevel, plugin.name);
1225
+ this.context = context;
1226
+ this.data = data;
1227
+ this.onLog = onLog;
1228
+ this.currentLoadingModule = currentLoadingModule;
1229
+ }
1230
+ async load(options) {
1231
+ const id = options.id;
1232
+ if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(super.pluginName, this.currentLoadingModule));
1233
+ const moduleInfo = this.data.getModuleInfo(id, this.context);
1234
+ if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
1235
+ const rawOptions = {
1236
+ meta: options.meta || {},
1237
+ moduleSideEffects: options.moduleSideEffects || null
1277
1238
  };
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)
1239
+ this.data.updateModuleOption(id, rawOptions);
1240
+ async function createLoadModulePromise(context, data) {
1241
+ const loadPromise = data.loadModulePromiseMap.get(id);
1242
+ if (loadPromise) return loadPromise;
1243
+ let resolveFn;
1244
+ const promise = new Promise((resolve, _) => {
1245
+ resolveFn = resolve;
1284
1246
  });
1247
+ data.loadModulePromiseMap.set(id, promise);
1248
+ try {
1249
+ await context.load(id, bindingifySideEffects(options.moduleSideEffects), resolveFn);
1250
+ } finally {
1251
+ data.loadModulePromiseMap.delete(id);
1252
+ }
1253
+ return promise;
1254
+ }
1255
+ await createLoadModulePromise(this.context, this.data);
1256
+ return this.data.getModuleInfo(id, this.context);
1257
+ }
1258
+ async resolve(source, importer, options) {
1259
+ let receipt = undefined;
1260
+ if (options != null) receipt = this.data.saveResolveOptions(options);
1261
+ const res = await this.context.resolve(source, importer, {
1262
+ custom: receipt,
1263
+ skipSelf: options?.skipSelf
1264
+ });
1265
+ if (receipt != null) this.data.removeSavedResolveOptions(receipt);
1266
+ if (res == null) return null;
1267
+ const info = this.data.getModuleOption(res.id) || {};
1268
+ return {
1269
+ ...res,
1270
+ ...info
1285
1271
  };
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);
1272
+ }
1273
+ emitFile(file) {
1274
+ if (file.type !== "asset") return unimplemented("PluginContext.emitFile: only asset type is supported");
1275
+ return this.context.emitFile({
1276
+ ...file,
1277
+ originalFileName: file.originalFileName || undefined,
1278
+ source: bindingAssetSource(file.source)
1279
+ });
1280
+ }
1281
+ getFileName(referenceId) {
1282
+ return this.context.getFileName(referenceId);
1283
+ }
1284
+ getModuleInfo(id) {
1285
+ return this.data.getModuleInfo(id, this.context);
1286
+ }
1287
+ getModuleIds() {
1288
+ return this.data.getModuleIds(this.context);
1289
+ }
1290
+ addWatchFile(id) {
1291
+ this.context.addWatchFile(id);
1292
+ }
1293
+ /**
1294
+ * @deprecated This rollup API won't be supported by rolldown. Using this API will cause runtime error.
1295
+ */
1296
+ parse(_input, _options) {
1297
+ unsupported("`PluginContext#parse` is not supported by rolldown.");
1291
1298
  }
1292
1299
  };
1293
1300
 
1294
1301
  //#endregion
1295
1302
  //#region src/plugin/transform-plugin-context.ts
1296
1303
  var TransformPluginContext = class extends PluginContext {
1297
- error;
1298
- getCombinedSourcemap;
1299
1304
  constructor(context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption) {
1300
1305
  super(context, plugin, data, onLog, LogLevelOption, moduleId);
1306
+ this.inner = inner;
1307
+ this.moduleId = moduleId;
1308
+ this.moduleSource = moduleSource;
1301
1309
  const getLogHandler$1 = (handler) => (log, pos) => {
1302
1310
  log = normalizeLog(log);
1303
1311
  if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
@@ -1308,14 +1316,16 @@ var TransformPluginContext = class extends PluginContext {
1308
1316
  this.debug = getLogHandler$1(this.debug);
1309
1317
  this.warn = getLogHandler$1(this.warn);
1310
1318
  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());
1319
+ }
1320
+ error(e, pos) {
1321
+ if (typeof e === "string") e = { message: e };
1322
+ if (pos) augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
1323
+ e.id = this.moduleId;
1324
+ e.hook = "transform";
1325
+ return error(logPluginError(normalizeLog(e), super.pluginName));
1326
+ }
1327
+ getCombinedSourcemap() {
1328
+ return JSON.parse(this.inner.getCombinedSourcemap());
1319
1329
  }
1320
1330
  };
1321
1331
 
@@ -1548,7 +1558,9 @@ function bindingifyModuleParsed(args) {
1548
1558
  //#endregion
1549
1559
  //#region src/options/normalized-output-options.ts
1550
1560
  function mapFunctionOption(option, name) {
1551
- return typeof option === "undefined" ? unsupported(`You should not take \`NormalizedOutputOptions#${name}\` and call it directly`) : option;
1561
+ return typeof option === "undefined" ? () => {
1562
+ unsupported(`You should not take \`NormalizedOutputOptions#${name}\` and call it directly`);
1563
+ } : option;
1552
1564
  }
1553
1565
  var NormalizedOutputOptionsImpl = class {
1554
1566
  inner;
@@ -2100,15 +2112,20 @@ function bindingifyInput(input) {
2100
2112
  });
2101
2113
  }
2102
2114
  function bindingifyJsx(input) {
2115
+ if (input === false) return { type: "Disable" };
2103
2116
  if (input) {
2104
- const mode = input.mode ?? "classic";
2117
+ if (input.mode === "preserve") return { type: "Preserve" };
2118
+ const mode = input.mode ?? "automatic";
2105
2119
  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
2120
+ type: "Enable",
2121
+ field0: {
2122
+ runtime: mode,
2123
+ importSource: mode === "classic" ? input.importSource : mode === "automatic" ? input.jsxImportSource : undefined,
2124
+ pragma: input.factory,
2125
+ pragmaFrag: input.fragment,
2126
+ development: input.development,
2127
+ refresh: input.refresh
2128
+ }
2112
2129
  };
2113
2130
  }
2114
2131
  }
@@ -2343,10 +2360,7 @@ function createComposedPlugin(plugins) {
2343
2360
  const createFixedPluginResolveFnMap = new Map();
2344
2361
  function applyFixedPluginResolveFn(ctx, plugin) {
2345
2362
  const createFixedPluginResolveFn = createFixedPluginResolveFnMap.get(plugin);
2346
- if (createFixedPluginResolveFn) return {
2347
- ...ctx,
2348
- resolve: createFixedPluginResolveFn(ctx)
2349
- };
2363
+ if (createFixedPluginResolveFn) ctx.resolve = createFixedPluginResolveFn(ctx, ctx.resolve.bind(ctx));
2350
2364
  return ctx;
2351
2365
  }
2352
2366
  if (batchedHooks.resolveId) {
@@ -2355,14 +2369,14 @@ function createComposedPlugin(plugins) {
2355
2369
  for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
2356
2370
  const [_handler, plugin] = batchedHandlers[handlerIdx];
2357
2371
  const handlerSymbol = handlerSymbols[handlerIdx];
2358
- const createFixedPluginResolveFn = (ctx) => {
2372
+ const createFixedPluginResolveFn = (ctx, resolve) => {
2359
2373
  return (source, importer, rawContextResolveOptions) => {
2360
2374
  const contextResolveOptions = rawContextResolveOptions ?? {};
2361
2375
  if (contextResolveOptions.skipSelf) {
2362
2376
  contextResolveOptions[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF] = handlerSymbol;
2363
2377
  contextResolveOptions.skipSelf = false;
2364
2378
  }
2365
- return ctx.resolve(source, importer, contextResolveOptions);
2379
+ return resolve(source, importer, contextResolveOptions);
2366
2380
  };
2367
2381
  };
2368
2382
  createFixedPluginResolveFnMap.set(plugin, createFixedPluginResolveFn);
@@ -2420,12 +2434,10 @@ function createComposedPlugin(plugins) {
2420
2434
  }
2421
2435
  for (const [handler, plugin] of batchedHandlers) {
2422
2436
  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);
2437
+ this.getCombinedSourcemap = () => {
2438
+ throw new Error(`The getCombinedSourcemap is not implement in transform hook at composedJsPlugins`);
2439
+ };
2440
+ const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code, id, moduleType);
2429
2441
  if (!isNullish(result)) {
2430
2442
  if (typeof result === "string") updateOutput(result);
2431
2443
  else if (result.code) updateOutput(result.code, result.moduleSideEffects);
@@ -2824,7 +2836,7 @@ const watch = (input) => {
2824
2836
 
2825
2837
  //#endregion
2826
2838
  //#region package.json
2827
- var version = "0.15.0";
2839
+ var version = "0.15.1-commit.4e41a08";
2828
2840
  var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
2829
2841
 
2830
2842
  //#endregion