Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for loading ESM #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

JulioC
Copy link

@JulioC JulioC commented Sep 2, 2023

This is an initial workaround for loading files with ESM imports.

This works by adding the importModuleDynamically option in vm.Script constructor, which is required when the script has dynamics imports(). In this case, the cache is also disabled because otherwise it would throw "Invalid host defined options" (I wasn't able to find out why).

I've added a couple benchmark cases, all of them are working with Node 10 and 18.

I'm not familiar with Node vm logic. This said, I believe this change only affects required files with ESM imports, which are not working at all now, so it shouldn't have side effects for other cases.

Edit: fixes #41

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.

question: can the package be used in esm?
1 participant