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

[ENHC] Create Yarn constraints to validate node version #10542

Merged
merged 6 commits into from
Feb 27, 2025

Conversation

prastoin
Copy link
Contributor

@prastoin prastoin commented Feb 27, 2025

Introduction

This is PR is a suggestion ! And should be discussed

With yarn ^4, during installation won't raise an error if current dev env does not satisfies the engines policy.
We have usually 10+ contributors support request regarding higher node version issue per week

I would have preferred a very declarative integration using npm engines but this does not seems to be natively supported by yarn

We should keep in mind that this might block any machines from our CICD if they have diff node version installed ( such as running the project on a different node version could result in bugs too )

Implem

Created a yarn constraints run after each installation that checking if current node version satisfies defined engines range ( might also be done for others engines entries )

I assume we will always have the same engines policy for every packages, at least that's not a consideration from now

Further

We could refactor our package.json engines into only one using Yarn.set etc

Resource

Note

Conclusion

As always any suggestions are more than welcomed !

@prastoin prastoin changed the title [ENHC] Define Yarn constraints engines [ENHC] Create Yarn constraints to validate node version Feb 27, 2025
@prastoin prastoin self-assigned this Feb 27, 2025
@prastoin prastoin force-pushed the yarn-constraints-engines branch from 14de555 to edff2a1 Compare February 27, 2025 11:40
@prastoin prastoin marked this pull request as ready for review February 27, 2025 11:55
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR adds Yarn constraints to validate Node.js version compatibility, addressing frequent support requests related to version mismatches.

  • Added enableConstraintsChecks: true in .yarnrc.yml to enable Yarn's constraints feature
  • Created new yarn.config.cjs file that implements Node.js version validation using semver
  • Added engineStrict: true to package.json to enforce Node.js version requirements
  • Added @yarnpkg/types as a dev dependency to support type checking in the constraints configuration
  • Implementation checks current Node version against required version (^18.17.1) and throws clear error messages when mismatched

3 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile

@charlesBochet charlesBochet merged commit 65e5699 into main Feb 27, 2025
53 of 54 checks passed
@charlesBochet charlesBochet deleted the yarn-constraints-engines branch February 27, 2025 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants