rolldown 0.15.0-commit.ac58858 → 0.15.0-commit.f0c42f8

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;
@@ -2343,10 +2355,7 @@ function createComposedPlugin(plugins) {
2343
2355
  const createFixedPluginResolveFnMap = new Map();
2344
2356
  function applyFixedPluginResolveFn(ctx, plugin) {
2345
2357
  const createFixedPluginResolveFn = createFixedPluginResolveFnMap.get(plugin);
2346
- if (createFixedPluginResolveFn) return {
2347
- ...ctx,
2348
- resolve: createFixedPluginResolveFn(ctx)
2349
- };
2358
+ if (createFixedPluginResolveFn) ctx.resolve = createFixedPluginResolveFn(ctx, ctx.resolve.bind(ctx));
2350
2359
  return ctx;
2351
2360
  }
2352
2361
  if (batchedHooks.resolveId) {
@@ -2355,14 +2364,14 @@ function createComposedPlugin(plugins) {
2355
2364
  for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
2356
2365
  const [_handler, plugin] = batchedHandlers[handlerIdx];
2357
2366
  const handlerSymbol = handlerSymbols[handlerIdx];
2358
- const createFixedPluginResolveFn = (ctx) => {
2367
+ const createFixedPluginResolveFn = (ctx, resolve) => {
2359
2368
  return (source, importer, rawContextResolveOptions) => {
2360
2369
  const contextResolveOptions = rawContextResolveOptions ?? {};
2361
2370
  if (contextResolveOptions.skipSelf) {
2362
2371
  contextResolveOptions[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF] = handlerSymbol;
2363
2372
  contextResolveOptions.skipSelf = false;
2364
2373
  }
2365
- return ctx.resolve(source, importer, contextResolveOptions);
2374
+ return resolve(source, importer, contextResolveOptions);
2366
2375
  };
2367
2376
  };
2368
2377
  createFixedPluginResolveFnMap.set(plugin, createFixedPluginResolveFn);
@@ -2420,12 +2429,10 @@ function createComposedPlugin(plugins) {
2420
2429
  }
2421
2430
  for (const [handler, plugin] of batchedHandlers) {
2422
2431
  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);
2432
+ this.getCombinedSourcemap = () => {
2433
+ throw new Error(`The getCombinedSourcemap is not implement in transform hook at composedJsPlugins`);
2434
+ };
2435
+ const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code, id, moduleType);
2429
2436
  if (!isNullish(result)) {
2430
2437
  if (typeof result === "string") updateOutput(result);
2431
2438
  else if (result.code) updateOutput(result.code, result.moduleSideEffects);
@@ -2824,7 +2831,7 @@ const watch = (input) => {
2824
2831
 
2825
2832
  //#endregion
2826
2833
  //#region package.json
2827
- var version = "0.15.0-commit.ac58858";
2834
+ var version = "0.15.0-commit.f0c42f8";
2828
2835
  var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
2829
2836
 
2830
2837
  //#endregion
@@ -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
 
@@ -825,7 +823,8 @@ function getLogger(plugins, onLog, logLevel) {
825
823
  rolldownVersion: VERSION,
826
824
  watchMode: false
827
825
  },
828
- warn: getLogHandler$1(LOG_LEVEL_WARN)
826
+ warn: getLogHandler$1(LOG_LEVEL_WARN),
827
+ pluginName: plugin.name || "unknown"
829
828
  }, level, log) === false) return;
830
829
  }
831
830
  }
@@ -1048,7 +1047,8 @@ var PluginDriver = class {
1048
1047
  rolldownVersion: VERSION,
1049
1048
  watchMode: false
1050
1049
  },
1051
- warn: getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", logger, name, logLevel)
1050
+ warn: getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", logger, name, logLevel),
1051
+ pluginName: name
1052
1052
  }, inputOptions);
1053
1053
  if (result) inputOptions = result;
1054
1054
  }
@@ -1148,6 +1148,7 @@ function transformModuleInfo(info, option) {
1148
1148
  dynamicImporters: info.dynamicImporters,
1149
1149
  importedIds: info.importedIds,
1150
1150
  dynamicallyImportedIds: info.dynamicallyImportedIds,
1151
+ exports: info.exports,
1151
1152
  isEntry: info.isEntry,
1152
1153
  ...option
1153
1154
  };
@@ -1160,21 +1161,20 @@ var MinimalPluginContext = class {
1160
1161
  warn;
1161
1162
  debug;
1162
1163
  meta;
1163
- error;
1164
- constructor(onLog, logLevel, plugin) {
1165
- const pluginName = plugin.name || "unknown";
1164
+ constructor(onLog, logLevel, pluginName) {
1165
+ this.pluginName = pluginName;
1166
1166
  this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
1167
1167
  this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
1168
1168
  this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
1169
- this.error = (e) => {
1170
- return error(logPluginError(normalizeLog(e), pluginName));
1171
- };
1172
1169
  this.meta = {
1173
1170
  rollupVersion: "4.23.0",
1174
1171
  rolldownVersion: VERSION,
1175
1172
  watchMode: false
1176
1173
  };
1177
1174
  }
1175
+ error(e) {
1176
+ return error(logPluginError(normalizeLog(e), this.pluginName));
1177
+ }
1178
1178
  };
1179
1179
 
1180
1180
  //#endregion
@@ -1194,84 +1194,92 @@ function bindingifySideEffects(sideEffects) {
1194
1194
  //#endregion
1195
1195
  //#region src/plugin/plugin-context.ts
1196
1196
  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
1197
  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
- };
1198
+ super(onLog, logLevel, plugin.name);
1199
+ this.context = context;
1200
+ this.data = data;
1201
+ this.onLog = onLog;
1202
+ this.currentLoadingModule = currentLoadingModule;
1203
+ }
1204
+ async load(options) {
1205
+ const id = options.id;
1206
+ if (id === this.currentLoadingModule) this.onLog(LOG_LEVEL_WARN, logCycleLoading(super.pluginName, this.currentLoadingModule));
1207
+ const moduleInfo = this.data.getModuleInfo(id, this.context);
1208
+ if (moduleInfo && moduleInfo.code !== null) return moduleInfo;
1209
+ const rawOptions = {
1210
+ meta: options.meta || {},
1211
+ moduleSideEffects: options.moduleSideEffects || null
1251
1212
  };
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)
1213
+ this.data.updateModuleOption(id, rawOptions);
1214
+ async function createLoadModulePromise(context, data) {
1215
+ const loadPromise = data.loadModulePromiseMap.get(id);
1216
+ if (loadPromise) return loadPromise;
1217
+ let resolveFn;
1218
+ const promise = new Promise((resolve, _) => {
1219
+ resolveFn = resolve;
1258
1220
  });
1221
+ data.loadModulePromiseMap.set(id, promise);
1222
+ try {
1223
+ await context.load(id, bindingifySideEffects(options.moduleSideEffects), resolveFn);
1224
+ } finally {
1225
+ data.loadModulePromiseMap.delete(id);
1226
+ }
1227
+ return promise;
1228
+ }
1229
+ await createLoadModulePromise(this.context, this.data);
1230
+ return this.data.getModuleInfo(id, this.context);
1231
+ }
1232
+ async resolve(source, importer, options) {
1233
+ let receipt = undefined;
1234
+ if (options != null) receipt = this.data.saveResolveOptions(options);
1235
+ const res = await this.context.resolve(source, importer, {
1236
+ custom: receipt,
1237
+ skipSelf: options?.skipSelf
1238
+ });
1239
+ if (receipt != null) this.data.removeSavedResolveOptions(receipt);
1240
+ if (res == null) return null;
1241
+ const info = this.data.getModuleOption(res.id) || {};
1242
+ return {
1243
+ ...res,
1244
+ ...info
1259
1245
  };
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);
1246
+ }
1247
+ emitFile(file) {
1248
+ if (file.type !== "asset") return unimplemented("PluginContext.emitFile: only asset type is supported");
1249
+ return this.context.emitFile({
1250
+ ...file,
1251
+ originalFileName: file.originalFileName || undefined,
1252
+ source: bindingAssetSource(file.source)
1253
+ });
1254
+ }
1255
+ getFileName(referenceId) {
1256
+ return this.context.getFileName(referenceId);
1257
+ }
1258
+ getModuleInfo(id) {
1259
+ return this.data.getModuleInfo(id, this.context);
1260
+ }
1261
+ getModuleIds() {
1262
+ return this.data.getModuleIds(this.context);
1263
+ }
1264
+ addWatchFile(id) {
1265
+ this.context.addWatchFile(id);
1266
+ }
1267
+ /**
1268
+ * @deprecated This rollup API won't be supported by rolldown. Using this API will cause runtime error.
1269
+ */
1270
+ parse(_input, _options) {
1271
+ unsupported("`PluginContext#parse` is not supported by rolldown.");
1265
1272
  }
1266
1273
  };
1267
1274
 
1268
1275
  //#endregion
1269
1276
  //#region src/plugin/transform-plugin-context.ts
1270
1277
  var TransformPluginContext = class extends PluginContext {
1271
- error;
1272
- getCombinedSourcemap;
1273
1278
  constructor(context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption) {
1274
1279
  super(context, plugin, data, onLog, LogLevelOption, moduleId);
1280
+ this.inner = inner;
1281
+ this.moduleId = moduleId;
1282
+ this.moduleSource = moduleSource;
1275
1283
  const getLogHandler$1 = (handler) => (log, pos) => {
1276
1284
  log = normalizeLog(log);
1277
1285
  if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
@@ -1282,14 +1290,16 @@ var TransformPluginContext = class extends PluginContext {
1282
1290
  this.debug = getLogHandler$1(this.debug);
1283
1291
  this.warn = getLogHandler$1(this.warn);
1284
1292
  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());
1293
+ }
1294
+ error(e, pos) {
1295
+ if (typeof e === "string") e = { message: e };
1296
+ if (pos) augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
1297
+ e.id = this.moduleId;
1298
+ e.hook = "transform";
1299
+ return error(logPluginError(normalizeLog(e), super.pluginName));
1300
+ }
1301
+ getCombinedSourcemap() {
1302
+ return JSON.parse(this.inner.getCombinedSourcemap());
1293
1303
  }
1294
1304
  };
1295
1305
 
@@ -1522,7 +1532,9 @@ function bindingifyModuleParsed(args) {
1522
1532
  //#endregion
1523
1533
  //#region src/options/normalized-output-options.ts
1524
1534
  function mapFunctionOption(option, name) {
1525
- return typeof option === "undefined" ? unsupported(`You should not take \`NormalizedOutputOptions#${name}\` and call it directly`) : option;
1535
+ return typeof option === "undefined" ? () => {
1536
+ unsupported(`You should not take \`NormalizedOutputOptions#${name}\` and call it directly`);
1537
+ } : option;
1526
1538
  }
1527
1539
  var NormalizedOutputOptionsImpl = class {
1528
1540
  inner;
@@ -2317,10 +2329,7 @@ function createComposedPlugin(plugins) {
2317
2329
  const createFixedPluginResolveFnMap = new Map();
2318
2330
  function applyFixedPluginResolveFn(ctx, plugin) {
2319
2331
  const createFixedPluginResolveFn = createFixedPluginResolveFnMap.get(plugin);
2320
- if (createFixedPluginResolveFn) return {
2321
- ...ctx,
2322
- resolve: createFixedPluginResolveFn(ctx)
2323
- };
2332
+ if (createFixedPluginResolveFn) ctx.resolve = createFixedPluginResolveFn(ctx, ctx.resolve.bind(ctx));
2324
2333
  return ctx;
2325
2334
  }
2326
2335
  if (batchedHooks.resolveId) {
@@ -2329,14 +2338,14 @@ function createComposedPlugin(plugins) {
2329
2338
  for (let handlerIdx = 0; handlerIdx < batchedHandlers.length; handlerIdx++) {
2330
2339
  const [_handler, plugin] = batchedHandlers[handlerIdx];
2331
2340
  const handlerSymbol = handlerSymbols[handlerIdx];
2332
- const createFixedPluginResolveFn = (ctx) => {
2341
+ const createFixedPluginResolveFn = (ctx, resolve) => {
2333
2342
  return (source, importer, rawContextResolveOptions) => {
2334
2343
  const contextResolveOptions = rawContextResolveOptions ?? {};
2335
2344
  if (contextResolveOptions.skipSelf) {
2336
2345
  contextResolveOptions[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF] = handlerSymbol;
2337
2346
  contextResolveOptions.skipSelf = false;
2338
2347
  }
2339
- return ctx.resolve(source, importer, contextResolveOptions);
2348
+ return resolve(source, importer, contextResolveOptions);
2340
2349
  };
2341
2350
  };
2342
2351
  createFixedPluginResolveFnMap.set(plugin, createFixedPluginResolveFn);
@@ -2394,12 +2403,10 @@ function createComposedPlugin(plugins) {
2394
2403
  }
2395
2404
  for (const [handler, plugin] of batchedHandlers) {
2396
2405
  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);
2406
+ this.getCombinedSourcemap = () => {
2407
+ throw new Error(`The getCombinedSourcemap is not implement in transform hook at composedJsPlugins`);
2408
+ };
2409
+ const result = await handlerFn.call(applyFixedPluginResolveFn(this, plugin), code, id, moduleType);
2403
2410
  if (!isNullish(result)) {
2404
2411
  if (typeof result === "string") updateOutput(result);
2405
2412
  else if (result.code) updateOutput(result.code, result.moduleSideEffects);
@@ -2798,7 +2805,7 @@ const watch = (input) => {
2798
2805
 
2799
2806
  //#endregion
2800
2807
  //#region package.json
2801
- var version = "0.15.0-commit.ac58858";
2808
+ var version = "0.15.0-commit.f0c42f8";
2802
2809
  var description = "Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.";
2803
2810
 
2804
2811
  //#endregion