nodejs / nodejs/node

Provide built-in implementations of module linker, initializeImportMeta, importModuleDynamically

Open
#31,234 12 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

vm
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

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

When using vm.SourceTextModule we have to implement a linker, initializeImportMeta, and importModuleDynamically, even if we just want the default behavior of built-in module support. There are many subtle ways to get that wrong.

Describe the solution you'd like

Default implementations that do basically what built-in module support does:

  • A linker function that:
    • Reads files from disk, within a specified root.
    • Uses Node module resolution as implemented for modules
    • Uses a specified module cache
    • initializeImportMeta that sets url property
    • By configuration, allows access to built-in modules.

Describe alternatives you've considered

Userland libraries can take the first cuts at easy-to-use vm.Modules, but I think something for common use cases should likely be included.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the vm.SourceTextModule entry point and the Node module-resolution behavior referenced in the issue. Work through the requested linker, initializeImportMeta, and importModuleDynamically defaults, including the root, module cache, and built-in-module configuration. Done means common vm.Modules can use built-in implementations without custom callbacks.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.