fix: embed node version requirement at compile time#1412
Open
liangmiQwQ wants to merge 1 commit intovoidzero-dev:mainfrom
Open
fix: embed node version requirement at compile time#1412liangmiQwQ wants to merge 1 commit intovoidzero-dev:mainfrom
liangmiQwQ wants to merge 1 commit intovoidzero-dev:mainfrom
Conversation
✅ Deploy Preview for viteplus-preview canceled.
|
Contributor
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There is for an edge case about
vp upgrade.If you are using an incompatible node version and you run
vp upgrade, it will not block your upgrading and install a broken vp cli (Node version outside the scope ofengine.nodewould prevent package manager from downloading binary bindings)Theoretically, the logic added in #1360 should resolve this problem, but as the code below, the node version is read at runtime not compile time.
vite-plus/crates/vite_global_cli/src/js_executor.rs
Lines 123 to 128 in 2e2c4c6
As
vp upgradewould delegate the cli installing task to the new downloaded vp binary, who has no valid package.json to read, it skips the node version's requirement check and causes this bug.A solution is to inject the node version at compile time as a enhancement for #1360.
This PR simply used
include_str!()to read package.json and the parsing is still at runtime. It is not the best way for performance.build.rsis required if we need even better runtime performance for it.