-
Notifications
You must be signed in to change notification settings - Fork 63
fix Start Code Analysis: use correct binary paths for ReScript v12+ #1171
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
Conversation
fc05c53 to
848eba1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fc05c532fb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
ReScript v12 changed its binary distribution to use @rescript/{platform}/bin.js.
This PR updates the extension to correctly locate binaries for v12+ projects.
Changes:
- Add dedicated v12+ binary finding via @rescript/{target}/bin.js
- Move legacy (<v12) binary finding to separate utils-legacy.ts files
- Clean top-level version check routes to v12+ or legacy code path
- Code Analyzer uses rescript-tools.exe for v12+, rescript-editor-analysis.exe for legacy
- Add findRescriptToolsBinary export for v12+ projects
No functional changes for pre-v12 projects - legacy behavior is preserved exactly.
848eba1 to
19a813d
Compare
nojaf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not going to claim what we have today is the crown jewel or can't be improved, but this PR makes too many assumptions and misses a lot of recent developments.
Makes me wonder whether we should add a rescript binaries command that outputs all the info as JSON to stdout. That would essentially be what compiler-info.json contains today, but without invoking a full build.
Can you elaborate what wasn't working for you? This feels more like a rewrite for the fun of it, presented as "v12 never worked so here is the fix." We fixed a lot over the summer, so I'm curious which setups failed and what exactly went wrong.
| * Finds binaries for ReScript < 12 using the old path structure. | ||
| * Checks compiler-info.json first, then falls back to node_modules/rescript/${platformDir}/. | ||
| * NOTE: This preserves the original behavior exactly - do not add existence checks | ||
| * to the compiler-info.json branch as the original code returned immediately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compiler-info.json is NOT at all legacy.
It is a ReScript (Rewatch) 12 feature that has a significant higher accuracy to determine the bsc_exe value.
It gets written after a rescript build and has significant accurate information about the compiler and runtime. Respecting environment variables that can override these locations which is crucial for local testing.
The original intent is actually quite simple. The original intent is to at least eliminate the v12 vs other versions complexity. And fix code analyzer binary lookup. Is there a spec anywhere of what binary resolution should look like? Is there a reason why it should be different than what the compiler does (if not, then the compiler code could be the spec). Even a few tiny example projects checked in that "should not break" could work as substitute for a proper spec. Otherwise, "change the existing code as little as possible or something will break" is the only thing that can be done at the moment. Which is one way to do the PR if there's no alternative. |
|
moved to different PR for simplicty. |
Not really, this is mostly the consequence of situation x or y was not working. The const targetPackagePath = path.join(
fs.realpathSync(rescriptDir),
"..",
`@rescript/${target}/bin.js`,
);part was a recent addition. If we had that sooner, we probably would not have done the |
More in style with the existing codebase.
Just add one more path to try, on top of all the others already tried.