My loader analyzes source to determine module shape. It uses the nextResolve and nextLoad routines to access the source. To ensure correct results from these routines, I pass export conditions to them. They're extracted by the resolve hook.
async function resolve (specifier, context, next) {
// Retain export conditions for analysis
state.conditions ??= [...context.conditions]
...
I think (?) export conditions are static across a run (modulo require vs import signaling which loader it's from).
It would be cleaner if there were some global access to these, so they don't need extracting.
function initialize (port, conditions) {
state.conditions = conditions
...
My loader analyzes source to determine module shape. It uses the
nextResolveandnextLoadroutines to access the source. To ensure correct results from these routines, I pass export conditions to them. They're extracted by theresolvehook.I think (?) export conditions are static across a run (modulo
requirevsimportsignaling which loader it's from).It would be cleaner if there were some global access to these, so they don't need extracting.