Skip to content

Refactor: Migrate to Yarn 4 and Corepack - #26

Merged
jrhoads merged 5 commits into
mainfrom
yarn4
Jun 3, 2026
Merged

jrhoads merged 5 commits into
mainfrom
yarn4

Conversation

@jrhoads

@jrhoads jrhoads commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Purpose

This PR updates the project's build and dependency management tooling to leverage Yarn 4 and Corepack. This includes updating the GitHub Actions workflow to use Yarn 4 for dependency installation and building, and implementing a more robust .gitignore to handle Yarn's cache and build artifacts.

Approach

The primary approach involves migrating from Yarn Classic to Yarn 4. This is achieved by:

  • Enabling Corepack: Corepack is a tool that comes with Node.js and helps manage package manager versions. It's enabled by default and will automatically install Yarn 4 based on the packageManager field in package.json.
  • Updating GitHub Actions Workflow:
    • The checkout action is updated to v6.
    • Corepack is explicitly enabled in the workflow.
    • The setup-node action is updated to v6 and configured to cache dependencies based on yarn.lock.
    • Dependency installation command is changed to yarn install --immutable, which is a Yarn 4 feature for more robust and predictable installations.
    • The build command remains yarn build.
  • Updating .gitignore: The .gitignore file is updated to correctly exclude Yarn's cache, build artifacts, and other Yarn-specific files, ensuring these are not committed to the repository.
  • Adding .tool-versions: A .tool-versions file is added to explicitly pin the Node.js version to 22, aligning with the version used in the build workflow.
  • Adding .yarnrc.yml: A .yarnrc.yml file is introduced to configure Yarn, disabling scripts by default and setting the nodeLinker to node-modules. The npmMinimalAgeGate is also set, which is a standard Yarn 4 configuration.
  • Updating README: The README is updated to reflect the new prerequisites (Node.js 22+ with Corepack, Yarn 4) and the updated installation steps.

Key Modifications

  • .github/workflows/build_dist_on_merge.yml: Updated to use Yarn 4, Corepack, and immutable installs.
  • .gitignore: Modified to include new Yarn-related files and directories.
  • .tool-versions: Added to specify the Node.js version.
  • .yarnrc.yml: Added to configure Yarn settings.
  • README.md: Updated to reflect changes in dependencies and installation steps.
  • yarn.lock: Updated to reflect the new dependency resolution for Yarn 4.

Important Technical Details

  • Yarn 4: This PR fully adopts Yarn 4, which offers improved performance, caching, and dependency management features like immutable installs.
  • Corepack: Leveraged to manage the Node.js package manager versions, ensuring consistency across environments.
  • Immutable Installs: The yarn install --immutable command ensures that the yarn.lock file is strictly adhered to, preventing unexpected dependency changes.
  • PNPM vs. Yarn: This PR implies a shift from potentially using PNPM to Yarn 4 for dependency management.
  • Cache Configuration: The cache: yarn and cache-dependency-path: yarn.lock in setup-node ensure that Yarn's dependencies are cached effectively in the GitHub Actions workflow.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Reviewer, please remember our guidelines:

  • Be humble in the language and feedback you give, ask don't tell.
  • Consider using positive language as opposed to neutral when offering feedback. This is to avoid the negative bias that can occur with neutral language appearing negative.
  • Offer suggestions on how to improve code e.g. simplification or expanding clarity.
  • Ensure you give reasons for the changes you are proposing.

@jrhoads
jrhoads requested review from a team and bklaing2 June 2, 2026 21:39
@jrhoads
jrhoads merged commit 8803039 into main Jun 3, 2026
3 checks passed
@jrhoads
jrhoads deleted the yarn4 branch June 3, 2026 08:30
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