nodejs/node

Simplify vm.Module

Open

#43,899 opened on Jul 19, 2022

View on GitHub
 (7 comments) (5 reactions) (0 assignees)JavaScript (35,535 forks)batch import
esmexperimentalhelp wantedloadersnever-stalevm

Repository metrics

Stars
 (117,218 stars)
PR merge metrics
 (Avg merge 13d 4h) (233 merged PRs in 30d)

Description

One thing that comes up in user feedback about the vm.Module API is that it requires excessive boilerplate, as you can see in the example in the docs: https://nodejs.org/api/vm.html#class-vmmodule. I think that most users want a straightforward ESM equivalent to vm.Script, without needing to define a context or a custom function for linking; the default should be to link modules as Node itself normally does. See also https://github.com/nodejs/node/issues/43288#issuecomment-1144112887.

Contributor guide