Skip to content

feat(js_runtime): add multi-source Node version reading#522

Merged
fengmk2 merged 10 commits intomainfrom
improve-js-runtime
Feb 7, 2026
Merged

feat(js_runtime): add multi-source Node version reading#522
fengmk2 merged 10 commits intomainfrom
improve-js-runtime

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Jan 29, 2026

Read Node.js version from multiple sources with priority:

  1. .node-version file (highest)
  2. engines.node in package.json
  3. devEngines.runtime in package.json (lowest)

Key behaviors:

  • Only write to .node-version when no version source exists
  • Always fetch latest LTS from network when no version specified
  • Warn when resolved version conflicts with lower-priority constraints
  • node-semver handles partial versions natively (20, 20.18, etc.)

@fengmk2 fengmk2 self-assigned this Jan 29, 2026
Copy link
Copy Markdown
Member Author

fengmk2 commented Jan 29, 2026

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Jan 29, 2026

Deploying vite-plus with  Cloudflare Pages  Cloudflare Pages

Latest commit: 256cd9b
Status: ✅  Deploy successful!
Preview URL: https://3f73d7d1.vite-plus.pages.dev
Branch Preview URL: https://improve-js-runtime.vite-plus.pages.dev

View logs

@fengmk2 fengmk2 marked this pull request as ready for review January 29, 2026 13:22
@fengmk2 fengmk2 requested a review from Brooooooklyn January 29, 2026 13:22
@fengmk2 fengmk2 force-pushed the improve-js-runtime branch from 72c1b11 to 03093b9 Compare January 30, 2026 11:30
@fengmk2 fengmk2 requested a review from cpojer February 3, 2026 05:43
@fengmk2 fengmk2 force-pushed the improve-js-runtime branch from 03093b9 to e865f32 Compare February 3, 2026 09:26
@fengmk2 fengmk2 changed the base branch from main to graphite-base/522 February 3, 2026 10:08
@fengmk2 fengmk2 force-pushed the improve-js-runtime branch from e865f32 to a166bdb Compare February 3, 2026 10:08
@fengmk2 fengmk2 changed the base branch from graphite-base/522 to 02-03-chore_fix_the_build_dependency_order February 3, 2026 10:09
@fengmk2 fengmk2 changed the base branch from 02-03-chore_fix_the_build_dependency_order to graphite-base/522 February 3, 2026 10:17
@fengmk2 fengmk2 force-pushed the improve-js-runtime branch from a166bdb to 2937a7c Compare February 3, 2026 10:18
@graphite-app graphite-app Bot changed the base branch from graphite-base/522 to main February 3, 2026 10:19
@fengmk2 fengmk2 force-pushed the improve-js-runtime branch from 2937a7c to 5c6ebe7 Compare February 3, 2026 10:19
@Brooooooklyn
Copy link
Copy Markdown
Member

cursor review

Read Node.js version from multiple sources with priority:
1. .node-version file (highest)
2. engines.node in package.json
3. devEngines.runtime in package.json (lowest)

Key behaviors:
- Only write to .node-version when no version source exists
- Always fetch latest LTS from network when no version specified
- Warn when resolved version conflicts with lower-priority constraints
- node-semver handles partial versions natively (20, 20.18, etc.)
Invalid version strings from .node-version, engines.node, and
devEngines.runtime are now ignored with a warning, allowing fallthrough
to lower-priority sources or the latest LTS version.

The normalize_version function trims whitespace and validates the
version as either an exact semver version or a valid range.
…hanges

- Add Version Validation section documenting trim and semver validation
- Update Version Write-Back section to reflect current behavior (only
  write when no version source exists)
- Add success criteria #19 for invalid version fallthrough behavior
When resolving semver ranges like `^20.19.0 || >=22.12.0`, now prefers
LTS versions over non-LTS versions. Previously it would return v25
(non-LTS), but now returns the latest LTS that satisfies the range.
Only falls back to non-LTS if no LTS version matches the range.

Changes:
- Updated resolve_version_from_list to prefer highest LTS version
- Updated find_cached_version to cross-reference with version index
  for LTS status of cached versions
- Added tests for LTS preference behavior
When fetching the version index fails due to network errors and a local
cache exists (even if expired), log a warning and return the cached
version instead of failing. This ensures network issues don't interrupt
the normal flow when we have a usable cache fallback.
Add visual feedback when downloading JS runtimes using indicatif crate.
Shows download progress with bytes, speed, and ETA in TTY environments.
Automatically hidden in CI or when output is piped.
Display what is being downloaded (e.g., "Downloading Node.js v22.13.1...")
above the progress bar so users understand what the download is for.
Copy link
Copy Markdown
Member Author

fengmk2 commented Feb 7, 2026

Merge activity

  • Feb 7, 8:24 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Feb 7, 8:25 AM UTC: @fengmk2 merged this pull request with Graphite.

@fengmk2 fengmk2 merged commit 4446c3c into main Feb 7, 2026
17 checks passed
@fengmk2 fengmk2 deleted the improve-js-runtime branch February 7, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants