You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
vm.compileFunction is missing importModuleDynamically #31860
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.
@devsnek hey 👋 Starting to land ESM support in Jest now, and was looking into supporting import() in CJS, and hit this again (forgot I filed it 😅). I would offer to help, but I've never done any C++ except for simplistic school assignments some years ago. Looking at #22381 it seems like it's almost entirely C++, but if I can do anything else to help I'd love to!
(As an aside, Jest 25.4 includes primitive support for ESM - I'm really digging the APIs! Thanks for all your hard work on this.)
Activity
SimenB commentedon Apr 21, 2020
@devsnek hey 👋 Starting to land ESM support in Jest now, and was looking into supporting
import()in CJS, and hit this again (forgot I filed it 😅). I would offer to help, but I've never done any C++ except for simplistic school assignments some years ago. Looking at #22381 it seems like it's almost entirely C++, but if I can do anything else to help I'd love to!(As an aside, Jest 25.4 includes primitive support for ESM - I'm really digging the APIs! Thanks for all your hard work on this.)
SimenB commentedon Apr 25, 2020
Ah thank you!
vm: add importModuleDynamically option to compileFunction
vm: add importModuleDynamically option to compileFunction
vm: add importModuleDynamically option to compileFunction
vm: add importModuleDynamically option to compileFunction
mcollina commentedon May 20, 2020
Reopening as this was reverted due to #33166.
vm: add importModuleDynamically option to compileFunction