Skip to content

Conversation

pkanal
Copy link

@pkanal pkanal commented Apr 3, 2023

Which problem is this PR solving?

While working on the tests it became clear that in order to make things work more consistently with ESM modules, we had to change the location of where we change the Proxy object into a regular object because import-in-the-middle has to deal with a Proxy object always.

Short description of the changes

  • Update the _wrap function to handle a Proxy object from import-in-the-middle
  • Set internals to false to make things work with modules from files

Unwrap

After looking into this a lot, it doesn't seem like _unwrap will work reliably because of the way import-in-the-middle takes actions on a Module. It uses a Proxy handler to take over the set function of the Module that will directly modify the Module but never give us access to the changed Module itself. This means that when we try to unwrap it, all we get is the original Proxy object from import-in-the-middle which already appears to be unwrapped even though the actual Module itself is not. I'm not totally sure what the solution is to that yet but I figure we can deal with it separately.

@pkanal pkanal changed the title Purvi/esm tests ESM test & small refactor Apr 3, 2023
@pkanal pkanal self-assigned this Apr 3, 2023
@JamieDanielson JamieDanielson merged commit 3ddb3a9 into esm-support Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants