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

Roadmap for stabilization of vm modules #37648

Open
3 of 5 tasks
targos opened this issue Mar 7, 2021 · 32 comments
Open
3 of 5 tasks

Roadmap for stabilization of vm modules #37648

targos opened this issue Mar 7, 2021 · 32 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

@targos
Copy link
Member

targos commented Mar 7, 2021

According to @SimenB, here are the issues that should probably be taken care of before we unflag and mark vm modules as stable:

/cc @devsnek

@targos targos added esm Issues and PRs related to the ECMAScript Modules implementation. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. vm Issues and PRs related to the vm subsystem. labels Mar 7, 2021
@SimenB
Copy link
Member

SimenB commented Mar 7, 2021

That last one might be a bug/race condition in Jest's implementation still. I haven't found the time to dig into it properly since opening up the issue, unfortunately. It feels like it's related to some module caching or context GC thing, but that's pure speculation. I have some hope it's related to whatever needs fixing for #36351 (again, speculating)

@devsnek
Copy link
Member

devsnek commented Mar 7, 2021

definitely blocked on v8:9968

@SimenB
Copy link
Member

SimenB commented Aug 25, 2021

The above linked v8 issue has been closed as fixed now (:tada:) - any idea of when we'll know if it's enough for Node's use cases?

@targos
Copy link
Member Author

targos commented Aug 25, 2021

The commit fixing the above V8 issue is in V8 9.4. I'll probably open a PR upgrading to that version next week.

@devsnek
Copy link
Member

devsnek commented Aug 25, 2021

it is not fixed quite yet, check v8:10284

@SimenB
Copy link
Member

SimenB commented Aug 25, 2021

Ah ok, thanks for the link! Seems there's quite a bit of activity recently, so hopefully it's not too far away 🙂

@vjeux
Copy link

vjeux commented Feb 2, 2022

Just wanted to say that Jest is blocked on those tasks being completed in order to properly support ESM. It would be amazing if this could be prioritized!

@jasonwilliams
Copy link

jasonwilliams commented Feb 28, 2022

Vitest is also blocked on those tasks too by the looks of vitest-dev/vitest#795 (comment). It seems to segfault on vm.runInThisContext when ran in debug mode on VSCode

@benmccann
Copy link
Contributor

I got another segfault in Vitest: vitest-dev/vitest#317

@piranna
Copy link
Contributor

piranna commented Jun 7, 2022

bytenode is also blocked by this.

@devsnek devsnek added the experimental Issues and PRs related to experimental features. label Jul 19, 2022
@silverwind
Copy link
Contributor

vite also would have a use case for VM modules, if they were made stable.

@HarikrishnanBalagopal
Copy link

HarikrishnanBalagopal commented May 3, 2023

Any update on this? As mentioned earlier, using imports in jest test files needs the experimental flag

NODE_OPTIONS=--experimental-vm-modules jest

jestjs/jest#12990 (comment)

@GeoffreyBooth
Copy link
Member

Any update on this?

Pull requests are welcome!

@AlbertMarashi
Copy link

cmon.. it's been years. This feature would help w/ so much in the JS ecosystem

@targos
Copy link
Member Author

targos commented May 9, 2023

Pull requests are still welcome.

@SimenB
Copy link
Member

SimenB commented Sep 14, 2023

After 2.5 years, one of the issues in the OP can finally be checked off 😀

@thernstig
Copy link
Contributor

@joyeecheung can the first item be ticked off since #33439 is closed?

@SimenB
Copy link
Member

SimenB commented Oct 26, 2023

Not sure if there's an issue for it, but the cache misses in vm.Script that was mitigated in #50137 (released in 21.1.0) will resurface when vm modules are unflagged - so fixing the cache in those cases should probably also be a blocker before unflagging/stabilizing.

rekmarks added a commit to MetaMask/create-release-branch that referenced this issue Dec 8, 2023
This PR updates `execa` to `^8.0.1`. Since `execa@>=6.0.0` is ESM-only and `jest` only has experimental ESM support (jestjs/jest#10976), this required switching from `ts-jest` to `babel-jest`. To minimize dependency transpilation, the ESM packages that are necessary to transpile are enumerated in `jest.config.js`.

This version of `execa` includes [automatic escaping of shell arguments](https://github.com/sindresorhus/execa/tree/v8.0.1#execafile-arguments-options), which was the entire point of #112, #113, and this PR.

The state of ESM support in the Node.js ecosystem is absolutely horrible, and I would not recommend further migrations for the time being. We should continue to dual-release our packages and avoid ESM-only dependencies until the ecosystem has matured. For details see the above `jest` issue and nodejs/node#37648.
@metawrap-dev
Copy link

Just to be clear, is this what is blocking VSCode extensions from using ES modules?

@woss
Copy link

woss commented Apr 5, 2024

@metawrap-dev no

@avivkeller
Copy link
Member

@nodejs/vm
I believe that #36351 may be fixed (See #36351 (comment))

@SimenB
Copy link
Member

SimenB commented Jul 11, 2024

2 of the linked issues in the OP have been closed - can probably tick them off yeah.

As for the remaining 2, #35714 is arguably a change that can be made as semver minor? And #33216 is hard to say whether is a bug in Node or in Jest, so probably shouldn't block stabilization.

Having --experimental-vm-modules be the default with a --no-experimental-vm-modules would be greatly beneficial, so with the blatent memory bugs fixed, maybe this can proceed?

coryasilva added a commit to coryasilva/open-api that referenced this issue Sep 10, 2024
When using jest this code gets transpiled to `require` and the file URL syntax of the import is not supported and breaks the testing environment.  This change only uses file URL import syntax on windows machines.  This fixes our tests and is still supported on linux and mac operating systems.

I think windows is definitely in the minority here and we should not optimize for it.  Furthermore, I believe using a UNC path would be a better solution outright but I cannot test because I don't have a window machine at hand.

Why not just use jest's `--experimental-vm-modules` flag? Glad you asked.  Because of this [jest bug](jestjs/jest#11434 (comment)) which is caused by this [node bug](nodejs/node#37648) which is ultimately caused by this [v8 bug](https://issues.chromium.org/issues/40784051)
@tats-u
Copy link

tats-u commented Sep 23, 2024

@targos Could you update the checklist?

#33439 and #36351 were closed.

@targos
Copy link
Member Author

targos commented Sep 28, 2024

Updated

@SimenB
Copy link
Member

SimenB commented Sep 28, 2024

Thoughts on making vm modules opt-out rather than opt-in for Node 23?

@piranna
Copy link
Contributor

piranna commented Sep 28, 2024

What do you mean? Can you elaborate?

@thernstig
Copy link
Contributor

@piranna I would wager @SimenB means this: https://nodejs.org/api/vm.html#class-vmmodule

I.e. to not enforce --experimental-vm-modules but to enable it by default, but to opt out via a new flag instead if it is not wanted.

@SimenB
Copy link
Member

SimenB commented Sep 30, 2024

Yeah 👍 Last sentence of #37648 (comment)

Having --experimental-vm-modules be the default with a --no-experimental-vm-modules would be greatly beneficial, so with the blatent memory bugs fixed, maybe this can proceed?

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