Skip to content

vm.compileFunction is missing importModuleDynamically #31860

@SimenB

Description

@SimenB

Is your feature request related to a problem? Please describe.

I'm currently working on implementing support for native ES Modules in Jest. While both vm.SourceTextModule and vm.Script allows us to define an importModuleDynamically option, this is missing from vm.compileFunction. The option is also present in runInContext and runInThisContext.

(I'm aware that vm's ESM APIs are experimental - I'm just playing with the APIs to see if they fit with Jest's use cases for them. It's currently looking really good! 🙂)

Describe the solution you'd like

The option should be added to compileFunction as well, to have parity with the other vm functions/constructs.

Describe alternatives you've considered

Not using compileFunction and sticking to vm.Script for CommonJS. I'd really like to avoid that as we just migrated to compileFunction which made V8 code coverage mapping from source maps way easier than the old manual module wrapper we use in vm.Scripts. Also, it's a bit cleaner on our side when we can avoid manually creating the module wrapper.

Metadata

Metadata

Assignees

Labels

vmIssues and PRs related to the vm subsystem.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions