ESM test & small refactor #1
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
_wrap
function to handle a Proxy object fromimport-in-the-middle
internals
tofalse
to make things work with modules from filesUnwrap
After looking into this a lot, it doesn't seem like
_unwrap
will work reliably because of the wayimport-in-the-middle
takes actions on a Module. It uses a Proxy handler to take over theset
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 fromimport-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.