endo
endo copied to clipboard
feat(compartment-mapper): full support of __esModule
Fixes: #927
- This looks correct to me.
- This is horrible.
I’m content to follow your lead on this behavior. If that means holding this back until we have a motivating case, I’m fine with that.
I woke up with a case that's likely to break it. None of the transpilers would do it, but this won't work:
module.exports=()=>{•••}
module.exports.__esModule=true
module.exports.default=something
The function becomes unreachable if required because we're gonna return the module record namespace because default is taken over by esmodule.
Transpiled code will not create this type of abomination though. (they're into other stuff 😉)
This is in theory a breaking change, so if we ever want to introduce it, we better introduce it early. But! I want to at least find proof it's needed for anything.
This solution doesn't stand up to the test of real ecosystem examples. Adding it has not improved test results on real packages and has broken a few.