endo icon indicating copy to clipboard operation
endo copied to clipboard

feat(compartment-mapper): full support of __esModule

Open naugtur opened this issue 2 years ago • 3 comments

Fixes: #927

naugtur avatar Apr 11 '22 10:04 naugtur

  1. This looks correct to me.
  2. 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.

kriskowal avatar Apr 12 '22 05:04 kriskowal

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.

naugtur avatar Apr 12 '22 05:04 naugtur

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.

naugtur avatar May 04 '22 12:05 naugtur