rolldown 0.14.0-snapshot-bd95eb1-20241124003631 → 0.14.0-snapshot-87f7277-20241125003644
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.
- package/dist/cjs/cli.cjs +1 -1
- package/dist/cjs/experimental-index.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/parallel-plugin-worker.cjs +2 -2
- package/dist/esm/cli.mjs +1 -1
- package/dist/esm/experimental-index.mjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/parallel-plugin-worker.mjs +2 -2
- package/dist/shared/rolldown-binding.wasi.cjs +26 -23
- package/dist/shared/{src_index-Xsvo29pK.mjs → src_index-AKIcG6mr.mjs} +166 -125
- package/dist/shared/{src_index-EpwDBsb5.cjs → src_index-AzJK-lP0.cjs} +166 -125
- package/dist/types/binding.d.ts +11 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/log/logger.d.ts +1 -15
- package/dist/types/options/normalized-input-options.d.ts +8 -2
- package/dist/types/options/normalized-output-options.d.ts +12 -3
- package/dist/types/plugin/bindingify-build-hooks.d.ts +9 -10
- package/dist/types/plugin/bindingify-output-hooks.d.ts +12 -15
- package/dist/types/plugin/bindingify-plugin.d.ts +12 -3
- package/dist/types/plugin/bindingify-watch-hooks.d.ts +3 -5
- package/dist/types/plugin/index.d.ts +1 -1
- package/dist/types/plugin/minimal-plugin-context.d.ts +15 -0
- package/dist/types/plugin/plugin-context.d.ts +3 -3
- package/dist/types/plugin/transform-plugin-context.d.ts +2 -3
- package/dist/types/utils/bindingify-input-options.d.ts +3 -3
- package/dist/types/utils/bindingify-output-options.d.ts +2 -2
- package/package.json +14 -14
|
@@ -564,6 +564,7 @@ var require_binding = __commonJSMin((exports, module) => {
|
|
|
564
564
|
module.exports.BindingCallableBuiltinPlugin = nativeBinding.BindingCallableBuiltinPlugin;
|
|
565
565
|
module.exports.BindingLog = nativeBinding.BindingLog;
|
|
566
566
|
module.exports.BindingModuleInfo = nativeBinding.BindingModuleInfo;
|
|
567
|
+
module.exports.BindingNormalizedOptions = nativeBinding.BindingNormalizedOptions;
|
|
567
568
|
module.exports.BindingOutputAsset = nativeBinding.BindingOutputAsset;
|
|
568
569
|
module.exports.BindingOutputChunk = nativeBinding.BindingOutputChunk;
|
|
569
570
|
module.exports.BindingOutputs = nativeBinding.BindingOutputs;
|
|
@@ -820,29 +821,6 @@ function normalizeHook(hook) {
|
|
|
820
821
|
|
|
821
822
|
//#endregion
|
|
822
823
|
//#region src/log/logger.ts
|
|
823
|
-
class MinimalPluginContext {
|
|
824
|
-
info;
|
|
825
|
-
warn;
|
|
826
|
-
debug;
|
|
827
|
-
meta;
|
|
828
|
-
error;
|
|
829
|
-
constructor(options, plugin) {
|
|
830
|
-
const onLog = options.onLog;
|
|
831
|
-
const pluginName = plugin.name || "unknown";
|
|
832
|
-
const logLevel = options.logLevel || LOG_LEVEL_INFO;
|
|
833
|
-
this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
|
|
834
|
-
this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
|
|
835
|
-
this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
|
|
836
|
-
this.error = (e) => {
|
|
837
|
-
return error(logPluginError(normalizeLog(e), pluginName));
|
|
838
|
-
};
|
|
839
|
-
this.meta = {
|
|
840
|
-
rollupVersion: "4.23.0",
|
|
841
|
-
rolldownVersion: VERSION,
|
|
842
|
-
watchMode: false
|
|
843
|
-
};
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
824
|
function getLogger(plugins, onLog, logLevel) {
|
|
847
825
|
const minimalPriority = logLevelPriority[logLevel];
|
|
848
826
|
const logger = (level, log, skipped = new Set()) => {
|
|
@@ -1112,6 +1090,30 @@ function transformModuleInfo(info, option) {
|
|
|
1112
1090
|
};
|
|
1113
1091
|
}
|
|
1114
1092
|
|
|
1093
|
+
//#endregion
|
|
1094
|
+
//#region src/plugin/minimal-plugin-context.ts
|
|
1095
|
+
class MinimalPluginContext {
|
|
1096
|
+
info;
|
|
1097
|
+
warn;
|
|
1098
|
+
debug;
|
|
1099
|
+
meta;
|
|
1100
|
+
error;
|
|
1101
|
+
constructor(onLog, logLevel, plugin) {
|
|
1102
|
+
const pluginName = plugin.name || "unknown";
|
|
1103
|
+
this.debug = getLogHandler(LOG_LEVEL_DEBUG, "PLUGIN_LOG", onLog, pluginName, logLevel);
|
|
1104
|
+
this.info = getLogHandler(LOG_LEVEL_INFO, "PLUGIN_LOG", onLog, pluginName, logLevel);
|
|
1105
|
+
this.warn = getLogHandler(LOG_LEVEL_WARN, "PLUGIN_WARNING", onLog, pluginName, logLevel);
|
|
1106
|
+
this.error = (e) => {
|
|
1107
|
+
return error(logPluginError(normalizeLog(e), pluginName));
|
|
1108
|
+
};
|
|
1109
|
+
this.meta = {
|
|
1110
|
+
rollupVersion: "4.23.0",
|
|
1111
|
+
rolldownVersion: VERSION,
|
|
1112
|
+
watchMode: false
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1115
1117
|
//#endregion
|
|
1116
1118
|
//#region src/utils/transform-side-effects.ts
|
|
1117
1119
|
var import_binding$5 = __toESM(require_binding());
|
|
@@ -1137,16 +1139,16 @@ class PluginContext extends MinimalPluginContext {
|
|
|
1137
1139
|
getModuleIds;
|
|
1138
1140
|
addWatchFile;
|
|
1139
1141
|
parse;
|
|
1140
|
-
constructor(
|
|
1141
|
-
super(
|
|
1142
|
-
this.load = async ({ id: id,...options
|
|
1142
|
+
constructor(context, plugin, data, onLog, logLevel) {
|
|
1143
|
+
super(onLog, logLevel, plugin);
|
|
1144
|
+
this.load = async ({ id: id,...options }) => {
|
|
1143
1145
|
const moduleInfo = data.getModuleInfo(id, context);
|
|
1144
1146
|
if (moduleInfo && moduleInfo.code !== null) {
|
|
1145
1147
|
return moduleInfo;
|
|
1146
1148
|
}
|
|
1147
1149
|
const rawOptions = {
|
|
1148
|
-
meta: options
|
|
1149
|
-
moduleSideEffects: options
|
|
1150
|
+
meta: options.meta || {},
|
|
1151
|
+
moduleSideEffects: options.moduleSideEffects || null
|
|
1150
1152
|
};
|
|
1151
1153
|
data.updateModuleOption(id, rawOptions);
|
|
1152
1154
|
async function createLoadModulePromise() {
|
|
@@ -1160,7 +1162,7 @@ class PluginContext extends MinimalPluginContext {
|
|
|
1160
1162
|
});
|
|
1161
1163
|
data.loadModulePromiseMap.set(id, promise);
|
|
1162
1164
|
try {
|
|
1163
|
-
await context.load(id, bindingifySideEffects(options
|
|
1165
|
+
await context.load(id, bindingifySideEffects(options.moduleSideEffects), resolveFn);
|
|
1164
1166
|
} finally {
|
|
1165
1167
|
data.loadModulePromiseMap.delete(id);
|
|
1166
1168
|
}
|
|
@@ -1169,14 +1171,14 @@ class PluginContext extends MinimalPluginContext {
|
|
|
1169
1171
|
await createLoadModulePromise();
|
|
1170
1172
|
return data.getModuleInfo(id, context);
|
|
1171
1173
|
};
|
|
1172
|
-
this.resolve = async (source, importer, options
|
|
1174
|
+
this.resolve = async (source, importer, options) => {
|
|
1173
1175
|
let receipt = undefined;
|
|
1174
|
-
if (options
|
|
1175
|
-
receipt = data.saveResolveOptions(options
|
|
1176
|
+
if (options != null) {
|
|
1177
|
+
receipt = data.saveResolveOptions(options);
|
|
1176
1178
|
}
|
|
1177
1179
|
const res = await context.resolve(source, importer, {
|
|
1178
1180
|
custom: receipt,
|
|
1179
|
-
skipSelf: options
|
|
1181
|
+
skipSelf: options?.skipSelf
|
|
1180
1182
|
});
|
|
1181
1183
|
if (receipt != null) {
|
|
1182
1184
|
data.removeSavedResolveOptions(receipt);
|
|
@@ -1210,8 +1212,8 @@ class PluginContext extends MinimalPluginContext {
|
|
|
1210
1212
|
//#region src/plugin/transform-plugin-context.ts
|
|
1211
1213
|
class TransformPluginContext extends PluginContext {
|
|
1212
1214
|
error;
|
|
1213
|
-
constructor(
|
|
1214
|
-
super(
|
|
1215
|
+
constructor(context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption) {
|
|
1216
|
+
super(context, plugin, data, onLog, LogLevelOption);
|
|
1215
1217
|
const getLogHandler$1 = (handler) => (log, pos) => {
|
|
1216
1218
|
log = normalizeLog(log);
|
|
1217
1219
|
if (pos) augmentCodeLocation(log, pos, moduleSource, moduleId);
|
|
@@ -1292,49 +1294,65 @@ function bindingifyTransformFilter(filterOption) {
|
|
|
1292
1294
|
};
|
|
1293
1295
|
}
|
|
1294
1296
|
|
|
1297
|
+
//#endregion
|
|
1298
|
+
//#region src/options/normalized-input-options.ts
|
|
1299
|
+
class NormalizedInputOptions {
|
|
1300
|
+
inner;
|
|
1301
|
+
constructor(inner, onLog) {
|
|
1302
|
+
this.inner = inner;
|
|
1303
|
+
this.onLog = onLog;
|
|
1304
|
+
}
|
|
1305
|
+
get shimMissingExports() {
|
|
1306
|
+
return this.inner.shimMissingExports;
|
|
1307
|
+
}
|
|
1308
|
+
get input() {
|
|
1309
|
+
return this.inner.input;
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1295
1313
|
//#endregion
|
|
1296
1314
|
//#region src/plugin/bindingify-build-hooks.ts
|
|
1297
|
-
function bindingifyBuildStart(
|
|
1298
|
-
const hook = plugin.buildStart;
|
|
1315
|
+
function bindingifyBuildStart(args) {
|
|
1316
|
+
const hook = args.plugin.buildStart;
|
|
1299
1317
|
if (!hook) {
|
|
1300
1318
|
return {};
|
|
1301
1319
|
}
|
|
1302
1320
|
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
1303
1321
|
return {
|
|
1304
|
-
plugin: async (ctx) => {
|
|
1305
|
-
await handler.call(new PluginContext(
|
|
1322
|
+
plugin: async (ctx, opts) => {
|
|
1323
|
+
await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), new NormalizedInputOptions(opts, args.onLog));
|
|
1306
1324
|
},
|
|
1307
1325
|
meta: bindingifyPluginHookMeta(meta)
|
|
1308
1326
|
};
|
|
1309
1327
|
}
|
|
1310
|
-
function bindingifyBuildEnd(
|
|
1311
|
-
const hook = plugin.buildEnd;
|
|
1328
|
+
function bindingifyBuildEnd(args) {
|
|
1329
|
+
const hook = args.plugin.buildEnd;
|
|
1312
1330
|
if (!hook) {
|
|
1313
1331
|
return {};
|
|
1314
1332
|
}
|
|
1315
1333
|
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
1316
1334
|
return {
|
|
1317
1335
|
plugin: async (ctx, err) => {
|
|
1318
|
-
await handler.call(new PluginContext(
|
|
1336
|
+
await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), err ? new Error(err) : undefined);
|
|
1319
1337
|
},
|
|
1320
1338
|
meta: bindingifyPluginHookMeta(meta)
|
|
1321
1339
|
};
|
|
1322
1340
|
}
|
|
1323
|
-
function bindingifyResolveId(
|
|
1324
|
-
const hook = plugin.resolveId;
|
|
1341
|
+
function bindingifyResolveId(args) {
|
|
1342
|
+
const hook = args.plugin.resolveId;
|
|
1325
1343
|
if (!hook) {
|
|
1326
1344
|
return {};
|
|
1327
1345
|
}
|
|
1328
1346
|
const { handler: handler, meta: meta, options: options } = normalizeHook(hook);
|
|
1329
1347
|
return {
|
|
1330
1348
|
plugin: async (ctx, specifier, importer, extraOptions) => {
|
|
1331
|
-
const contextResolveOptions = extraOptions.custom != null ? pluginContextData.getSavedResolveOptions(extraOptions.custom) : undefined;
|
|
1349
|
+
const contextResolveOptions = extraOptions.custom != null ? args.pluginContextData.getSavedResolveOptions(extraOptions.custom) : undefined;
|
|
1332
1350
|
const newExtraOptions = {
|
|
1333
1351
|
...extraOptions,
|
|
1334
1352
|
custom: contextResolveOptions?.custom,
|
|
1335
1353
|
[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]: contextResolveOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]
|
|
1336
1354
|
};
|
|
1337
|
-
const ret = await handler.call(new PluginContext(
|
|
1355
|
+
const ret = await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), specifier, importer ?? undefined, newExtraOptions);
|
|
1338
1356
|
if (ret == null) {
|
|
1339
1357
|
return;
|
|
1340
1358
|
}
|
|
@@ -1354,7 +1372,7 @@ function bindingifyResolveId(plugin, normalizedOptions, pluginContextData) {
|
|
|
1354
1372
|
if (ret.moduleSideEffects !== null) {
|
|
1355
1373
|
result.sideEffects = bindingifySideEffects(ret.moduleSideEffects);
|
|
1356
1374
|
}
|
|
1357
|
-
pluginContextData.updateModuleOption(ret.id, {
|
|
1375
|
+
args.pluginContextData.updateModuleOption(ret.id, {
|
|
1358
1376
|
meta: ret.meta || {},
|
|
1359
1377
|
moduleSideEffects: ret.moduleSideEffects || null
|
|
1360
1378
|
});
|
|
@@ -1364,15 +1382,15 @@ function bindingifyResolveId(plugin, normalizedOptions, pluginContextData) {
|
|
|
1364
1382
|
filter: bindingifyResolveIdFilter(options.filter)
|
|
1365
1383
|
};
|
|
1366
1384
|
}
|
|
1367
|
-
function bindingifyResolveDynamicImport(
|
|
1368
|
-
const hook = plugin.resolveDynamicImport;
|
|
1385
|
+
function bindingifyResolveDynamicImport(args) {
|
|
1386
|
+
const hook = args.plugin.resolveDynamicImport;
|
|
1369
1387
|
if (!hook) {
|
|
1370
1388
|
return {};
|
|
1371
1389
|
}
|
|
1372
1390
|
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
1373
1391
|
return {
|
|
1374
1392
|
plugin: async (ctx, specifier, importer) => {
|
|
1375
|
-
const ret = await handler.call(new PluginContext(
|
|
1393
|
+
const ret = await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), specifier, importer ?? undefined);
|
|
1376
1394
|
if (ret == null) {
|
|
1377
1395
|
return;
|
|
1378
1396
|
}
|
|
@@ -1392,7 +1410,7 @@ function bindingifyResolveDynamicImport(plugin, options, pluginContextData) {
|
|
|
1392
1410
|
if (ret.moduleSideEffects !== null) {
|
|
1393
1411
|
result.sideEffects = bindingifySideEffects(ret.moduleSideEffects);
|
|
1394
1412
|
}
|
|
1395
|
-
pluginContextData.updateModuleOption(ret.id, {
|
|
1413
|
+
args.pluginContextData.updateModuleOption(ret.id, {
|
|
1396
1414
|
meta: ret.meta || {},
|
|
1397
1415
|
moduleSideEffects: ret.moduleSideEffects || null
|
|
1398
1416
|
});
|
|
@@ -1401,22 +1419,22 @@ function bindingifyResolveDynamicImport(plugin, options, pluginContextData) {
|
|
|
1401
1419
|
meta: bindingifyPluginHookMeta(meta)
|
|
1402
1420
|
};
|
|
1403
1421
|
}
|
|
1404
|
-
function bindingifyTransform(
|
|
1405
|
-
const hook = plugin.transform;
|
|
1422
|
+
function bindingifyTransform(args) {
|
|
1423
|
+
const hook = args.plugin.transform;
|
|
1406
1424
|
if (!hook) {
|
|
1407
1425
|
return {};
|
|
1408
1426
|
}
|
|
1409
1427
|
const { handler: handler, meta: meta, options: options } = normalizeHook(hook);
|
|
1410
1428
|
return {
|
|
1411
1429
|
plugin: async (ctx, code, id, meta$1) => {
|
|
1412
|
-
const ret = await handler.call(new TransformPluginContext(
|
|
1430
|
+
const ret = await handler.call(new TransformPluginContext(ctx.inner(), args.plugin, args.pluginContextData, ctx, id, code, args.onLog, args.logLevel), code, id, meta$1);
|
|
1413
1431
|
if (ret == null) {
|
|
1414
1432
|
return undefined;
|
|
1415
1433
|
}
|
|
1416
1434
|
if (typeof ret === "string") {
|
|
1417
1435
|
return {code: ret};
|
|
1418
1436
|
}
|
|
1419
|
-
pluginContextData.updateModuleOption(id, {
|
|
1437
|
+
args.pluginContextData.updateModuleOption(id, {
|
|
1420
1438
|
meta: ret.meta || {},
|
|
1421
1439
|
moduleSideEffects: ret.moduleSideEffects || null
|
|
1422
1440
|
});
|
|
@@ -1431,15 +1449,15 @@ function bindingifyTransform(plugin, normalizedOptions, pluginContextData) {
|
|
|
1431
1449
|
filter: bindingifyTransformFilter(options.filter)
|
|
1432
1450
|
};
|
|
1433
1451
|
}
|
|
1434
|
-
function bindingifyLoad(
|
|
1435
|
-
const hook = plugin.load;
|
|
1452
|
+
function bindingifyLoad(args) {
|
|
1453
|
+
const hook = args.plugin.load;
|
|
1436
1454
|
if (!hook) {
|
|
1437
1455
|
return {};
|
|
1438
1456
|
}
|
|
1439
1457
|
const { handler: handler, meta: meta, options: options } = normalizeHook(hook);
|
|
1440
1458
|
return {
|
|
1441
1459
|
plugin: async (ctx, id) => {
|
|
1442
|
-
const ret = await handler.call(new PluginContext(
|
|
1460
|
+
const ret = await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), id);
|
|
1443
1461
|
if (ret == null) {
|
|
1444
1462
|
return;
|
|
1445
1463
|
}
|
|
@@ -1455,7 +1473,7 @@ function bindingifyLoad(plugin, normalized_options, pluginContextData) {
|
|
|
1455
1473
|
if (ret.moduleSideEffects !== null) {
|
|
1456
1474
|
result.sideEffects = bindingifySideEffects(ret.moduleSideEffects);
|
|
1457
1475
|
}
|
|
1458
|
-
pluginContextData.updateModuleOption(id, {
|
|
1476
|
+
args.pluginContextData.updateModuleOption(id, {
|
|
1459
1477
|
meta: ret.meta || {},
|
|
1460
1478
|
moduleSideEffects: ret.moduleSideEffects || null
|
|
1461
1479
|
});
|
|
@@ -1477,37 +1495,52 @@ function preProcessSourceMap(ret, id) {
|
|
|
1477
1495
|
}
|
|
1478
1496
|
return map;
|
|
1479
1497
|
}
|
|
1480
|
-
function bindingifyModuleParsed(
|
|
1481
|
-
const hook = plugin.moduleParsed;
|
|
1498
|
+
function bindingifyModuleParsed(args) {
|
|
1499
|
+
const hook = args.plugin.moduleParsed;
|
|
1482
1500
|
if (!hook) {
|
|
1483
1501
|
return {};
|
|
1484
1502
|
}
|
|
1485
1503
|
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
1486
1504
|
return {
|
|
1487
1505
|
plugin: async (ctx, moduleInfo) => {
|
|
1488
|
-
await handler.call(new PluginContext(
|
|
1506
|
+
await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), transformModuleInfo(moduleInfo, args.pluginContextData.moduleOptionMap.get(moduleInfo.id)));
|
|
1489
1507
|
},
|
|
1490
1508
|
meta: bindingifyPluginHookMeta(meta)
|
|
1491
1509
|
};
|
|
1492
1510
|
}
|
|
1493
1511
|
|
|
1512
|
+
//#endregion
|
|
1513
|
+
//#region src/options/normalized-output-options.ts
|
|
1514
|
+
class NormalizedOutputOptionsImpl {
|
|
1515
|
+
inner;
|
|
1516
|
+
constructor(inner) {
|
|
1517
|
+
this.inner = inner;
|
|
1518
|
+
}
|
|
1519
|
+
get entryFileNames() {
|
|
1520
|
+
return this.inner.entryFilenames || unsupported("You should not take `NormalizedOutputOptions#entryFileNames` and call it directly");
|
|
1521
|
+
}
|
|
1522
|
+
get format() {
|
|
1523
|
+
return this.inner.format;
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1494
1527
|
//#endregion
|
|
1495
1528
|
//#region src/plugin/bindingify-output-hooks.ts
|
|
1496
|
-
function bindingifyRenderStart(
|
|
1497
|
-
const hook = plugin.renderStart;
|
|
1529
|
+
function bindingifyRenderStart(args) {
|
|
1530
|
+
const hook = args.plugin.renderStart;
|
|
1498
1531
|
if (!hook) {
|
|
1499
1532
|
return {};
|
|
1500
1533
|
}
|
|
1501
1534
|
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
1502
1535
|
return {
|
|
1503
|
-
plugin: async (ctx) => {
|
|
1504
|
-
handler.call(new PluginContext(
|
|
1536
|
+
plugin: async (ctx, opts) => {
|
|
1537
|
+
handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), new NormalizedOutputOptionsImpl(opts), new NormalizedInputOptions(opts, args.onLog));
|
|
1505
1538
|
},
|
|
1506
1539
|
meta: bindingifyPluginHookMeta(meta)
|
|
1507
1540
|
};
|
|
1508
1541
|
}
|
|
1509
|
-
function bindingifyRenderChunk(
|
|
1510
|
-
const hook = plugin.renderChunk;
|
|
1542
|
+
function bindingifyRenderChunk(args) {
|
|
1543
|
+
const hook = args.plugin.renderChunk;
|
|
1511
1544
|
if (!hook) {
|
|
1512
1545
|
return {};
|
|
1513
1546
|
}
|
|
@@ -1517,7 +1550,7 @@ function bindingifyRenderChunk(plugin, options, outputOptions, pluginContextData
|
|
|
1517
1550
|
(Object.entries(chunk.modules)).forEach(([key, module$1]) => {
|
|
1518
1551
|
chunk.modules[key] = transformToRenderedModule(module$1);
|
|
1519
1552
|
});
|
|
1520
|
-
const ret = await handler.call(new PluginContext(
|
|
1553
|
+
const ret = await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), code, chunk, {});
|
|
1521
1554
|
if (ret == null) {
|
|
1522
1555
|
return;
|
|
1523
1556
|
}
|
|
@@ -1535,8 +1568,8 @@ function bindingifyRenderChunk(plugin, options, outputOptions, pluginContextData
|
|
|
1535
1568
|
meta: bindingifyPluginHookMeta(meta)
|
|
1536
1569
|
};
|
|
1537
1570
|
}
|
|
1538
|
-
function bindingifyAugmentChunkHash(
|
|
1539
|
-
const hook = plugin.augmentChunkHash;
|
|
1571
|
+
function bindingifyAugmentChunkHash(args) {
|
|
1572
|
+
const hook = args.plugin.augmentChunkHash;
|
|
1540
1573
|
if (!hook) {
|
|
1541
1574
|
return {};
|
|
1542
1575
|
}
|
|
@@ -1546,45 +1579,45 @@ function bindingifyAugmentChunkHash(plugin, options, pluginContextData) {
|
|
|
1546
1579
|
(Object.entries(chunk.modules)).forEach(([key, module$1]) => {
|
|
1547
1580
|
chunk.modules[key] = transformToRenderedModule(module$1);
|
|
1548
1581
|
});
|
|
1549
|
-
return await handler.call(new PluginContext(
|
|
1582
|
+
return await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), chunk);
|
|
1550
1583
|
},
|
|
1551
1584
|
meta: bindingifyPluginHookMeta(meta)
|
|
1552
1585
|
};
|
|
1553
1586
|
}
|
|
1554
|
-
function bindingifyRenderError(
|
|
1555
|
-
const hook = plugin.renderError;
|
|
1587
|
+
function bindingifyRenderError(args) {
|
|
1588
|
+
const hook = args.plugin.renderError;
|
|
1556
1589
|
if (!hook) {
|
|
1557
1590
|
return {};
|
|
1558
1591
|
}
|
|
1559
1592
|
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
1560
1593
|
return {
|
|
1561
1594
|
plugin: async (ctx, err) => {
|
|
1562
|
-
handler.call(new PluginContext(
|
|
1595
|
+
handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), new Error(err));
|
|
1563
1596
|
},
|
|
1564
1597
|
meta: bindingifyPluginHookMeta(meta)
|
|
1565
1598
|
};
|
|
1566
1599
|
}
|
|
1567
|
-
function bindingifyGenerateBundle(
|
|
1568
|
-
const hook = plugin.generateBundle;
|
|
1600
|
+
function bindingifyGenerateBundle(args) {
|
|
1601
|
+
const hook = args.plugin.generateBundle;
|
|
1569
1602
|
if (!hook) {
|
|
1570
1603
|
return {};
|
|
1571
1604
|
}
|
|
1572
1605
|
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
1573
1606
|
return {
|
|
1574
|
-
plugin: async (ctx, bundle, isWrite) => {
|
|
1607
|
+
plugin: async (ctx, bundle, isWrite, opts) => {
|
|
1575
1608
|
const changed = {
|
|
1576
1609
|
updated: new Set(),
|
|
1577
1610
|
deleted: new Set()
|
|
1578
1611
|
};
|
|
1579
1612
|
const output = transformToOutputBundle(bundle, changed);
|
|
1580
|
-
await handler.call(new PluginContext(
|
|
1613
|
+
await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), new NormalizedOutputOptionsImpl(opts), output, isWrite);
|
|
1581
1614
|
return collectChangedBundle(changed, output);
|
|
1582
1615
|
},
|
|
1583
1616
|
meta: bindingifyPluginHookMeta(meta)
|
|
1584
1617
|
};
|
|
1585
1618
|
}
|
|
1586
|
-
function bindingifyWriteBundle(
|
|
1587
|
-
const hook = plugin.writeBundle;
|
|
1619
|
+
function bindingifyWriteBundle(args) {
|
|
1620
|
+
const hook = args.plugin.writeBundle;
|
|
1588
1621
|
if (!hook) {
|
|
1589
1622
|
return {};
|
|
1590
1623
|
}
|
|
@@ -1596,27 +1629,27 @@ function bindingifyWriteBundle(plugin, options, outputOptions, pluginContextData
|
|
|
1596
1629
|
deleted: new Set()
|
|
1597
1630
|
};
|
|
1598
1631
|
const output = transformToOutputBundle(bundle, changed);
|
|
1599
|
-
await handler.call(new PluginContext(
|
|
1632
|
+
await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), {}, output);
|
|
1600
1633
|
return collectChangedBundle(changed, output);
|
|
1601
1634
|
},
|
|
1602
1635
|
meta: bindingifyPluginHookMeta(meta)
|
|
1603
1636
|
};
|
|
1604
1637
|
}
|
|
1605
|
-
function bindingifyCloseBundle(
|
|
1606
|
-
const hook = plugin.closeBundle;
|
|
1638
|
+
function bindingifyCloseBundle(args) {
|
|
1639
|
+
const hook = args.plugin.closeBundle;
|
|
1607
1640
|
if (!hook) {
|
|
1608
1641
|
return {};
|
|
1609
1642
|
}
|
|
1610
1643
|
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
1611
1644
|
return {
|
|
1612
1645
|
plugin: async (ctx) => {
|
|
1613
|
-
await handler.call(new PluginContext(
|
|
1646
|
+
await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel));
|
|
1614
1647
|
},
|
|
1615
1648
|
meta: bindingifyPluginHookMeta(meta)
|
|
1616
1649
|
};
|
|
1617
1650
|
}
|
|
1618
|
-
function bindingifyBanner(
|
|
1619
|
-
const hook = plugin.banner;
|
|
1651
|
+
function bindingifyBanner(args) {
|
|
1652
|
+
const hook = args.plugin.banner;
|
|
1620
1653
|
if (!hook) {
|
|
1621
1654
|
return {};
|
|
1622
1655
|
}
|
|
@@ -1626,13 +1659,13 @@ function bindingifyBanner(plugin, options, pluginContextData) {
|
|
|
1626
1659
|
if (typeof handler === "string") {
|
|
1627
1660
|
return handler;
|
|
1628
1661
|
}
|
|
1629
|
-
return handler.call(new PluginContext(
|
|
1662
|
+
return handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), chunk);
|
|
1630
1663
|
},
|
|
1631
1664
|
meta: bindingifyPluginHookMeta(meta)
|
|
1632
1665
|
};
|
|
1633
1666
|
}
|
|
1634
|
-
function bindingifyFooter(
|
|
1635
|
-
const hook = plugin.footer;
|
|
1667
|
+
function bindingifyFooter(args) {
|
|
1668
|
+
const hook = args.plugin.footer;
|
|
1636
1669
|
if (!hook) {
|
|
1637
1670
|
return {};
|
|
1638
1671
|
}
|
|
@@ -1642,13 +1675,13 @@ function bindingifyFooter(plugin, options, pluginContextData) {
|
|
|
1642
1675
|
if (typeof handler === "string") {
|
|
1643
1676
|
return handler;
|
|
1644
1677
|
}
|
|
1645
|
-
return handler.call(new PluginContext(
|
|
1678
|
+
return handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), chunk);
|
|
1646
1679
|
},
|
|
1647
1680
|
meta: bindingifyPluginHookMeta(meta)
|
|
1648
1681
|
};
|
|
1649
1682
|
}
|
|
1650
|
-
function bindingifyIntro(
|
|
1651
|
-
const hook = plugin.intro;
|
|
1683
|
+
function bindingifyIntro(args) {
|
|
1684
|
+
const hook = args.plugin.intro;
|
|
1652
1685
|
if (!hook) {
|
|
1653
1686
|
return {};
|
|
1654
1687
|
}
|
|
@@ -1658,13 +1691,13 @@ function bindingifyIntro(plugin, options, pluginContextData) {
|
|
|
1658
1691
|
if (typeof handler === "string") {
|
|
1659
1692
|
return handler;
|
|
1660
1693
|
}
|
|
1661
|
-
return handler.call(new PluginContext(
|
|
1694
|
+
return handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), chunk);
|
|
1662
1695
|
},
|
|
1663
1696
|
meta: bindingifyPluginHookMeta(meta)
|
|
1664
1697
|
};
|
|
1665
1698
|
}
|
|
1666
|
-
function bindingifyOutro(
|
|
1667
|
-
const hook = plugin.outro;
|
|
1699
|
+
function bindingifyOutro(args) {
|
|
1700
|
+
const hook = args.plugin.outro;
|
|
1668
1701
|
if (!hook) {
|
|
1669
1702
|
return {};
|
|
1670
1703
|
}
|
|
@@ -1674,7 +1707,7 @@ function bindingifyOutro(plugin, options, pluginContextData) {
|
|
|
1674
1707
|
if (typeof handler === "string") {
|
|
1675
1708
|
return handler;
|
|
1676
1709
|
}
|
|
1677
|
-
return handler.call(new PluginContext(
|
|
1710
|
+
return handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), chunk);
|
|
1678
1711
|
},
|
|
1679
1712
|
meta: bindingifyPluginHookMeta(meta)
|
|
1680
1713
|
};
|
|
@@ -1682,28 +1715,28 @@ function bindingifyOutro(plugin, options, pluginContextData) {
|
|
|
1682
1715
|
|
|
1683
1716
|
//#endregion
|
|
1684
1717
|
//#region src/plugin/bindingify-watch-hooks.ts
|
|
1685
|
-
function bindingifyWatchChange(
|
|
1686
|
-
const hook = plugin.watchChange;
|
|
1718
|
+
function bindingifyWatchChange(args) {
|
|
1719
|
+
const hook = args.plugin.watchChange;
|
|
1687
1720
|
if (!hook) {
|
|
1688
1721
|
return {};
|
|
1689
1722
|
}
|
|
1690
1723
|
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
1691
1724
|
return {
|
|
1692
1725
|
plugin: async (ctx, id, event) => {
|
|
1693
|
-
await handler.call(new PluginContext(
|
|
1726
|
+
await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), id, {event: event});
|
|
1694
1727
|
},
|
|
1695
1728
|
meta: bindingifyPluginHookMeta(meta)
|
|
1696
1729
|
};
|
|
1697
1730
|
}
|
|
1698
|
-
function bindingifyCloseWatcher(
|
|
1699
|
-
const hook = plugin.closeWatcher;
|
|
1731
|
+
function bindingifyCloseWatcher(args) {
|
|
1732
|
+
const hook = args.plugin.closeWatcher;
|
|
1700
1733
|
if (!hook) {
|
|
1701
1734
|
return {};
|
|
1702
1735
|
}
|
|
1703
1736
|
const { handler: handler, meta: meta } = normalizeHook(hook);
|
|
1704
1737
|
return {
|
|
1705
1738
|
plugin: async (ctx) => {
|
|
1706
|
-
await handler.call(new PluginContext(
|
|
1739
|
+
await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel));
|
|
1707
1740
|
},
|
|
1708
1741
|
meta: bindingifyPluginHookMeta(meta)
|
|
1709
1742
|
};
|
|
@@ -1711,27 +1744,35 @@ function bindingifyCloseWatcher(plugin, options, pluginContextData) {
|
|
|
1711
1744
|
|
|
1712
1745
|
//#endregion
|
|
1713
1746
|
//#region src/plugin/bindingify-plugin.ts
|
|
1714
|
-
function bindingifyPlugin(plugin, options, outputOptions, pluginContextData) {
|
|
1715
|
-
const
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
const { plugin:
|
|
1724
|
-
const { plugin:
|
|
1725
|
-
const { plugin:
|
|
1726
|
-
const { plugin:
|
|
1727
|
-
const { plugin:
|
|
1728
|
-
const { plugin:
|
|
1729
|
-
const { plugin:
|
|
1730
|
-
const { plugin:
|
|
1731
|
-
const { plugin:
|
|
1732
|
-
const { plugin:
|
|
1733
|
-
const { plugin:
|
|
1734
|
-
const { plugin:
|
|
1747
|
+
function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, onLog, logLevel) {
|
|
1748
|
+
const args = {
|
|
1749
|
+
plugin,
|
|
1750
|
+
options,
|
|
1751
|
+
outputOptions,
|
|
1752
|
+
pluginContextData,
|
|
1753
|
+
onLog,
|
|
1754
|
+
logLevel
|
|
1755
|
+
};
|
|
1756
|
+
const { plugin: buildStart, meta: buildStartMeta } = bindingifyBuildStart(args);
|
|
1757
|
+
const { plugin: resolveId, meta: resolveIdMeta, filter: resolveIdFilter } = bindingifyResolveId(args);
|
|
1758
|
+
const { plugin: resolveDynamicImport, meta: resolveDynamicImportMeta } = bindingifyResolveDynamicImport(args);
|
|
1759
|
+
const { plugin: buildEnd, meta: buildEndMeta } = bindingifyBuildEnd(args);
|
|
1760
|
+
const { plugin: transform, meta: transformMeta, filter: transformFilter } = bindingifyTransform(args);
|
|
1761
|
+
const { plugin: moduleParsed, meta: moduleParsedMeta } = bindingifyModuleParsed(args);
|
|
1762
|
+
const { plugin: load, meta: loadMeta, filter: loadFilter } = bindingifyLoad(args);
|
|
1763
|
+
const { plugin: renderChunk, meta: renderChunkMeta } = bindingifyRenderChunk(args);
|
|
1764
|
+
const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args);
|
|
1765
|
+
const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args);
|
|
1766
|
+
const { plugin: renderError, meta: renderErrorMeta } = bindingifyRenderError(args);
|
|
1767
|
+
const { plugin: generateBundle, meta: generateBundleMeta } = bindingifyGenerateBundle(args);
|
|
1768
|
+
const { plugin: writeBundle, meta: writeBundleMeta } = bindingifyWriteBundle(args);
|
|
1769
|
+
const { plugin: closeBundle, meta: closeBundleMeta } = bindingifyCloseBundle(args);
|
|
1770
|
+
const { plugin: banner, meta: bannerMeta } = bindingifyBanner(args);
|
|
1771
|
+
const { plugin: footer, meta: footerMeta } = bindingifyFooter(args);
|
|
1772
|
+
const { plugin: intro, meta: introMeta } = bindingifyIntro(args);
|
|
1773
|
+
const { plugin: outro, meta: outroMeta } = bindingifyOutro(args);
|
|
1774
|
+
const { plugin: watchChange, meta: watchChangeMeta } = bindingifyWatchChange(args);
|
|
1775
|
+
const { plugin: closeWatcher, meta: closeWatcherMeta } = bindingifyCloseWatcher(args);
|
|
1735
1776
|
const result = {
|
|
1736
1777
|
name: plugin.name ?? "unknown",
|
|
1737
1778
|
buildStart,
|
|
@@ -1900,7 +1941,7 @@ function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions) {
|
|
|
1900
1941
|
if (plugin instanceof BuiltinPlugin) {
|
|
1901
1942
|
return bindingifyBuiltInPlugin(plugin);
|
|
1902
1943
|
}
|
|
1903
|
-
return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData);
|
|
1944
|
+
return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData, onLog, logLevel);
|
|
1904
1945
|
});
|
|
1905
1946
|
return {
|
|
1906
1947
|
input: bindingifyInput(inputOptions.input),
|
package/dist/types/binding.d.ts
CHANGED
|
@@ -36,6 +36,13 @@ export declare class BindingModuleInfo {
|
|
|
36
36
|
get code(): string | null
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
export declare class BindingNormalizedOptions {
|
|
40
|
+
get shimMissingExports(): boolean
|
|
41
|
+
get input(): Array<string> | Record<string, string>
|
|
42
|
+
get entryFilenames(): string | null
|
|
43
|
+
get format(): 'es' | 'cjs' | 'app' | 'iife' | 'umd'
|
|
44
|
+
}
|
|
45
|
+
|
|
39
46
|
export declare class BindingOutputAsset {
|
|
40
47
|
get fileName(): string
|
|
41
48
|
get originalFileName(): string | null
|
|
@@ -397,7 +404,7 @@ export interface BindingPluginHookMeta {
|
|
|
397
404
|
|
|
398
405
|
export interface BindingPluginOptions {
|
|
399
406
|
name: string
|
|
400
|
-
buildStart?: (ctx: BindingPluginContext) => MaybePromise<VoidNullable>
|
|
407
|
+
buildStart?: (ctx: BindingPluginContext, opts: BindingNormalizedOptions) => MaybePromise<VoidNullable>
|
|
401
408
|
buildStartMeta?: BindingPluginHookMeta
|
|
402
409
|
resolveId?: (ctx: BindingPluginContext, specifier: string, importer: Nullable<string>, options: BindingHookResolveIdExtraArgs) => MaybePromise<VoidNullable<BindingHookResolveIdOutput>>
|
|
403
410
|
resolveIdMeta?: BindingPluginHookMeta
|
|
@@ -418,11 +425,11 @@ export interface BindingPluginOptions {
|
|
|
418
425
|
renderChunkMeta?: BindingPluginHookMeta
|
|
419
426
|
augmentChunkHash?: (ctx: BindingPluginContext, chunk: RenderedChunk) => MaybePromise<void | string>
|
|
420
427
|
augmentChunkHashMeta?: BindingPluginHookMeta
|
|
421
|
-
renderStart?: (ctx: BindingPluginContext) => void
|
|
428
|
+
renderStart?: (ctx: BindingPluginContext, opts: BindingNormalizedOptions) => void
|
|
422
429
|
renderStartMeta?: BindingPluginHookMeta
|
|
423
430
|
renderError?: (ctx: BindingPluginContext, error: string) => void
|
|
424
431
|
renderErrorMeta?: BindingPluginHookMeta
|
|
425
|
-
generateBundle?: (ctx: BindingPluginContext, bundle: BindingOutputs, isWrite: boolean) => MaybePromise<VoidNullable<JsChangedOutputs>>
|
|
432
|
+
generateBundle?: (ctx: BindingPluginContext, bundle: BindingOutputs, isWrite: boolean, opts: BindingNormalizedOptions) => MaybePromise<VoidNullable<JsChangedOutputs>>
|
|
426
433
|
generateBundleMeta?: BindingPluginHookMeta
|
|
427
434
|
writeBundle?: (ctx: BindingPluginContext, bundle: BindingOutputs) => MaybePromise<VoidNullable<JsChangedOutputs>>
|
|
428
435
|
writeBundleMeta?: BindingPluginHookMeta
|
|
@@ -687,7 +694,7 @@ export interface JsxOptions {
|
|
|
687
694
|
/**
|
|
688
695
|
* Enable React Fast Refresh .
|
|
689
696
|
*
|
|
690
|
-
* Conforms to the implementation in {@link https://github.com/facebook/react/tree/
|
|
697
|
+
* Conforms to the implementation in {@link https://github.com/facebook/react/tree/v18.3.1/packages/react-refresh}
|
|
691
698
|
*
|
|
692
699
|
* @default false
|
|
693
700
|
*/
|