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
import("hermes-parser")
changes process.exitCode
#978
Comments
This seems to be a side effect of the Emscripten glue code. A quick examination of HermesParserWASM.js narrows it down to this:
I am not really sure what the correct approach here is. The whole Emscripten glue situation feels like a bit of a mess. This is definitely fixable, but somebody will have to really dig down and figure it out. |
Hey @fisker, i had a look into this issue. Its a bit tricky since the code that has this behavior is generated by Emscripten code: https://github.com/emscripten-core/emscripten/blob/3c822ef6ba6b3be58b73fd8dde4422538fdbe3dc/src/shell.js#LL260C31-L260C31 There are some options thought:
The downside is this uses globals which won't work with @fisker i assume you are looking at this to be able to include it in prettier v3? (i would love to see this happen so happy to help out with this work btw).
@fisker any preference? Ill try giving 2) a go. |
@pieterv can this be addressed using |
Nice! I tested this and its working, |
Summary: The default emscripten code overrides the `process.exitCode` value to `0` on module init. This means if someone has already set an `exitCode` it will be reset. This change fixes this by switching emscripten to use the `MODULARIZE` flag which allows us to pass in function overrides, we then pass a modified implementation of `quit` that only adds the exitCode if its non zero. Fixes: facebook#978 Differential Revision: D45705102 fbshipit-source-id: e3b7980e491e02836a21f182a495027aa8282ffa
@pieterv Thank you for looking into this. Actually this is not really an issue for Prettier anymore, since we only need the visitorKeys. The following - import { VisitorKeys as flowVisitorKeys } from "hermes-eslint";
+ import flowVisitorKeys from "hermes-parser/dist/generated/ESTreeVisitorKeys.js"; already work for us. https://github.com/prettier/prettier/pull/14756/files#diff-26f745c3d0a653bf61c52f9adfd251e9a3fc619ec20ab1792b95e7296266edcaL3 I thought it worth to raise an issue since it took me a while to locate the problem. 😄 |
@fisker Oh nice, glad you were able to get unblocked! I was wondering, is size still an issue with the prettier V3 architecture? I know this was a concern for adding hermes parser as a core parser in the past (prettier/prettier#13818), i would love to get it in at some point since we actually patch prettier in Meta to use |
Unfortunately yes, people has been complainted. We can try to support it after we fix prettier/prettier#13912. No promises. |
Weird i wonder why people care. The module system would be nice though! If size is a limitation maybe it would be ok to swap |
…acebook#989) Summary: Pull Request resolved: facebook#989 The default emscripten code overrides the `process.exitCode` value to `0` on module init. This means if someone has already set an `exitCode` it will be reset. This change fixes this by switching emscripten to use the `MODULARIZE` flag which allows us to pass in function overrides, we then pass a modified implementation of `quit` that only adds the exitCode if its non zero. Fixes: facebook#978 Differential Revision: D45705102 fbshipit-source-id: c9b5bf5c74f55d047ad07c0a81390f8ba6932dfb
…acebook#989) Summary: Pull Request resolved: facebook#989 The default emscripten code overrides the `process.exitCode` value to `0` on module init. This means if someone has already set an `exitCode` it will be reset. This change fixes this by switching emscripten to use the `MODULARIZE` flag which allows us to pass in function overrides, we then pass a modified implementation of `quit` that only adds the exitCode if its non zero. Fixes: facebook#978 Differential Revision: D45705102 fbshipit-source-id: 4022b34d24994b10843161811395768cd344cea0
Summary: Original Author: pieterv@meta.com Original Git: d1be3ff The default emscripten code overrides the `process.exitCode` value to `0` on module init. This means if someone has already set an `exitCode` it will be reset. This change fixes this by switching emscripten to use the `MODULARIZE` flag which allows us to pass in function overrides, we then pass a modified implementation of `quit` that only adds the exitCode if its non zero. Fixes: #978 Original Reviewed By: tmikov Original Revision: D45705102 Reviewed By: neildhar Differential Revision: D47690263 fbshipit-source-id: afda31d02534f5ae4bd9366b215a03101f8a7c06
Bug Description
gradle clean
and confirmed this bug does not occur with JSCHermes version: 0.10.1
React Native version (if any):
OS version (if any): Windows
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64): x86_64
Steps To Reproduce
code example:
The Expected Behavior
Should not change
process.exitCode
.Possible related to #942
The text was updated successfully, but these errors were encountered: