X Tutup
The Wayback Machine - https://web.archive.org/web/20221221145809/https://github.com/nodejs/node/issues/43899
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify vm.Module #43899

Open
GeoffreyBooth opened this issue Jul 19, 2022 · 6 comments
Open

Simplify vm.Module #43899

GeoffreyBooth opened this issue Jul 19, 2022 · 6 comments
Labels
esm Issues and PRs related to the ECMAScript Modules implementation. experimental Issues and PRs related to experimental features. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. loaders Issues and PRs related to ES module loaders never-stale Mark issue so that it is never considered stale vm Issues and PRs related to the vm subsystem.

Comments

@GeoffreyBooth
Copy link
Member

GeoffreyBooth commented Jul 19, 2022

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 #43288 (comment).

@GeoffreyBooth GeoffreyBooth added help wanted Issues that need assistance from volunteers or PRs that need help to proceed. vm Issues and PRs related to the vm subsystem. experimental Issues and PRs related to experimental features. esm Issues and PRs related to the ECMAScript Modules implementation. loaders Issues and PRs related to ES module loaders never-stale Mark issue so that it is never considered stale labels Jul 19, 2022
@legendecas
Copy link
Member

legendecas commented Jul 19, 2022

There are several open issues on vm.SourceTextModule, like:

I'm still looking into these problems as part of the effort on bringing module support to ShadowRealm in Node.js, but they depend on the work on the v8 side to enable arbitrary values to be saved in the host_defined_options and the v8 team is also working on refactoring how host_defined_option takes effects on code caching (https://docs.google.com/document/d/1vyfTs9pJVeDeguSVhYts3uolkhPk03eg5IvJeSR4IKI/edit#).

Also, there is a roadmap issue for stabling VM modules: #37648.

@devsnek
Copy link
Member

devsnek commented Jul 19, 2022

closing as a duplicate of #37648

@devsnek devsnek closed this as completed Jul 19, 2022
@GeoffreyBooth
Copy link
Member Author

GeoffreyBooth commented Jul 19, 2022

Thanks. I guess what's missing in that issue that I have here are the UX concerns, about using good defaults so that users can reduce boilerplate. I couldn't find an issue for that part, which maybe we could tackle now while we wait for V8?

@devsnek
Copy link
Member

devsnek commented Jul 19, 2022

there are a lot of footguns you can hit if you are not careful with the vm api. for example when you point vm modules at node's main context, you create a memory leak which can't be fixed without changes to v8. i'm all for improving the vm api of course, but be wary that you'll likely hit lots of annoying roadblocks on the v8 side.

@GeoffreyBooth
Copy link
Member Author

GeoffreyBooth commented Jul 19, 2022

I didn't say it would be easy 😀 but I think reducing the complexity is a worthy goal. If that request isn't captured elsewhere, perhaps this issue should stay open to track that?

@GeoffreyBooth GeoffreyBooth changed the title Stabilize vm.Module Simplify vm.Module Jul 20, 2022
@GeoffreyBooth
Copy link
Member Author

GeoffreyBooth commented Jul 20, 2022

Reopening to focus on the UX changes. If that’s duplicated elsewhere we can close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
esm Issues and PRs related to the ECMAScript Modules implementation. experimental Issues and PRs related to experimental features. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. loaders Issues and PRs related to ES module loaders never-stale Mark issue so that it is never considered stale vm Issues and PRs related to the vm subsystem.
Projects
None yet
Development

No branches or pull requests

3 participants
X Tutup