镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

vm.compileFunction is missing importModuleDynamically #31860

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.

Activity

  1. self-assigned this
    on Feb 19, 2020
  2. added
    vmIssues and PRs related to the vm subsystem.
    on Feb 19, 2020
  3. SimenB commented on Apr 21, 2020

    @SimenB
    MemberAuthor

    @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.)

  4. SimenB commented on Apr 25, 2020

    @SimenB
    MemberAuthor

    Ah thank you!

  5. mcollina commented on May 20, 2020

    @mcollina
    SponsorMember

    Reopening as this was reverted due to #33166.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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