-
-
Notifications
You must be signed in to change notification settings - Fork 638
Migrate from Yarn Classic to pnpm #2121
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
4bf91db
Migrate from Yarn Classic to pnpm (#2120)
justin808 2a74aae
Fix pnpm/action-setup version conflict
justin808 3b98806
Fix CI failures after pnpm migration
justin808 3ae666b
Fix knip config, ESLint errors, and lefthook scripts
justin808 0f74293
Add CHANGELOG entry for pnpm migration
justin808 70cfbf6
Fix knip configuration for pnpm migration
justin808 149011f
Revert LazyApolloGraphQL.tsx to master version
justin808 b23dc0d
Reset knip.ts to master version
justin808 0b91b0a
Update knip.ts for pnpm compatibility
justin808 6a3d6d3
Fix remaining knip issues for pnpm migration
justin808 60e75c1
Fix knip config: add worker.ts as entry point
justin808 05a1852
Add @babel/runtime and mini-css-extract-plugin back to ignoreDependen…
justin808 1464424
Fix lint workflow to use nps eslint command
justin808 45f92eb
Fix package.json scripts for pnpm compatibility
justin808 1768e2e
Add .npmrc to prettierignore
justin808 10cafc1
Fix markdown formatting for prettier
justin808 0a26774
Fix lint:scss path for monorepo structure
justin808 1fa0de9
Fix ESLint no-base-to-string error in LazyApolloGraphQL
justin808 0b160a5
Fix ESLint no-base-to-string with JSON.stringify
justin808 33c5127
Update dummy app Babel to ^7.22.0 for pnpm compatibility
justin808 722b532
Fix Prettier formatting in LazyApolloGraphQL
justin808 8001b3d
Fix Pro lint workflow Check TypeScript working directory
justin808 283298b
Fix check-typescript to use pnpm instead of yarn workspace
justin808 a0f62cd
Fix release.rake to use pnpm instead of yarn
justin808 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,8 @@ | |
|
|
||
| ## Why This Matters | ||
|
|
||
| - The `prepack`/`prepare` scripts in package.json/package-scripts.yml run during: | ||
| - `npm install` / `yarn install` (for git dependencies) | ||
| - The `prepack`/`prepare` scripts in package.json run during: | ||
| - `npm install` / `pnpm install` (for git dependencies) | ||
| - `yalc publish` (critical for local development) | ||
| - `npm publish` | ||
| - Package manager prepare phase | ||
|
|
@@ -40,7 +40,7 @@ gh pr view --json statusCheckRollup | jq '.statusCheckRollup[] | select(.conclus | |
|
|
||
| ## Mandatory Testing After ANY Changes | ||
|
|
||
| **If you modify package.json, package-scripts.yml, or build configs:** | ||
| **If you modify package.json or build configs:** | ||
|
|
||
| ### Step 1: ALWAYS Test Clean Install First | ||
|
|
||
|
|
@@ -51,7 +51,7 @@ This is the **MOST CRITICAL** test - it's what CI does first, and installation f | |
| rm -rf node_modules | ||
|
|
||
| # Test the exact command CI uses | ||
| yarn install --frozen-lockfile | ||
| pnpm install --frozen-lockfile | ||
|
|
||
| # If this fails, STOP and fix it before testing anything else | ||
| ``` | ||
|
|
@@ -62,7 +62,7 @@ yarn install --frozen-lockfile | |
|
|
||
| ```bash | ||
| # Build all packages | ||
| yarn run build | ||
| pnpm run build | ||
|
|
||
| # Should succeed without errors | ||
| ``` | ||
|
|
@@ -71,10 +71,10 @@ yarn run build | |
|
|
||
| ```bash | ||
| # Test prepack/prepare scripts work | ||
| yarn nps build.prepack | ||
| pnpm run prepack | ||
|
|
||
| # Test yalc publish (CRITICAL for local development) | ||
| yarn run yalc:publish | ||
| pnpm run yalc:publish | ||
|
|
||
| # Should publish all workspace packages successfully | ||
| ``` | ||
|
|
@@ -97,48 +97,48 @@ ls -la packages/react-on-rails-pro-node-renderer/lib/ReactOnRailsProNodeRenderer | |
| bundle exec rubocop | ||
|
|
||
| # JS/TS formatting | ||
| yarn start format.listDifferent | ||
| pnpm run format.listDifferent | ||
| ``` | ||
|
|
||
| ## When Directory Structure Changes | ||
|
|
||
| If you rename/move directories that contain build artifacts: | ||
|
|
||
| 1. **Update ALL path references in package-scripts.yml** | ||
| 1. **Update ALL path references in package.json** | ||
| 2. **Test yalc publish BEFORE pushing** | ||
| 3. **Test in a fresh clone to ensure no local assumptions** | ||
| 4. **Consider adding a CI job to validate artifact paths** | ||
|
|
||
| ## Workspace Dependencies: Yarn Classic vs Yarn Berry | ||
| ## Workspace Dependencies: PNPM | ||
|
|
||
| **CRITICAL: This project uses Yarn Classic (v1.x), not Yarn Berry (v2+)** | ||
| **CRITICAL: This project uses PNPM (v9+)** | ||
|
|
||
| Check `package.json` for: `"packageManager": "[email protected]"` | ||
| Check `package.json` for: `"packageManager": "[email protected]"` | ||
|
|
||
| ### Correct Workspace Dependency Syntax | ||
|
|
||
| For Yarn Classic workspaces: | ||
| For PNPM workspaces: | ||
|
|
||
| ```json | ||
| { | ||
| "dependencies": { | ||
| "react-on-rails": "*" | ||
| "react-on-rails": "workspace:*" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| **DO NOT USE:** | ||
|
|
||
| - `"workspace:*"` - This is Yarn Berry v2+ syntax, will cause installation errors | ||
| - `"*"` - This is Yarn Classic v1.x syntax | ||
| - `"file:../react-on-rails"` - This bypasses workspace resolution | ||
|
|
||
| ### Why `*` Works | ||
| ### Why `workspace:*` Works | ||
|
|
||
| In Yarn Classic workspaces: | ||
| In PNPM workspaces: | ||
|
|
||
| - `"*"` tells Yarn to resolve to the local workspace package | ||
| - Yarn automatically links to the workspace version | ||
| - This is the official Yarn v1 workspace syntax | ||
| - `"workspace:*"` tells PNPM to resolve to the local workspace package | ||
| - PNPM automatically links to the workspace version | ||
| - This is the official PNPM workspace syntax | ||
|
|
||
| ### Testing Workspace Changes | ||
|
|
||
|
|
@@ -149,32 +149,34 @@ When modifying workspace dependencies in package.json: | |
| rm -rf node_modules | ||
|
|
||
| # 2. Test CI command - this will fail immediately if syntax is wrong | ||
| yarn install --frozen-lockfile | ||
| pnpm install --frozen-lockfile | ||
|
|
||
| # 3. Verify workspace linking worked | ||
| yarn workspaces info | ||
| pnpm -r list | ||
|
|
||
| # 4. Test that packages can import each other | ||
| yarn run build | ||
| pnpm run build | ||
| ``` | ||
|
|
||
| ## Real Examples: What Went Wrong | ||
|
|
||
| ### Example 1: Path Reference Issue (Sep 2024) | ||
|
|
||
| We moved `node_package/` → `packages/react-on-rails/`. The path in | ||
| package-scripts.yml was updated to `packages/react-on-rails/lib/ReactOnRails.full.js`. | ||
| Later, the structure was partially reverted to `lib/` at root, but package-scripts.yml | ||
| package.json was updated to `packages/react-on-rails/lib/ReactOnRails.full.js`. | ||
| Later, the structure was partially reverted to `lib/` at root, but package.json | ||
| wasn't updated. This broke yalc publish silently for 7 weeks. Manual testing of | ||
| `yarn run yalc.publish` would have caught this immediately. | ||
| `pnpm run yalc:publish` would have caught this immediately. | ||
|
|
||
| ### Example 2: Workspace Protocol Issue (Nov 2024) | ||
| ### Example 2: Workspace Protocol Migration (2024) | ||
|
|
||
| Changed workspace dependencies from `"*"` to `"workspace:*"` without testing clean install. | ||
| This caused CI to fail with: `Couldn't find any versions for "react-on-rails" that matches "workspace:*"` | ||
| When migrating from Yarn to PNPM, workspace dependencies needed to change from `"*"` to `"workspace:*"`. | ||
|
|
||
| **Root cause:** Assumed `workspace:*` was standard, but it's only supported in Yarn Berry v2+. | ||
| This project uses Yarn Classic v1.x which requires `"*"` for workspace dependencies. | ||
| **Root cause:** Different package managers use different workspace protocols: | ||
|
|
||
| **Lesson:** ALWAYS test `yarn install --frozen-lockfile` after modifying workspace dependencies. | ||
| - Yarn Classic v1.x uses `"*"` for workspace dependencies | ||
| - PNPM uses `"workspace:*"` for workspace dependencies | ||
| - Yarn Berry v2+ also uses `"workspace:*"` | ||
|
|
||
| **Lesson:** ALWAYS test `pnpm install --frozen-lockfile` after modifying workspace dependencies. | ||
| Your local node_modules masked the issue - CI starts fresh and caught it immediately. | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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 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.
Fix markdown formatting: convert emphasis to proper heading.
Line 114 uses emphasis (
**Workspace Dependencies: PNPM**) where a proper Markdown heading (##) is more semantically correct and improves document navigation.Apply this diff:
Per markdownlint (MD036), prefer heading syntax over emphasis formatting for section headers.
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)
114-114: Emphasis used instead of a heading
(MD036, no-emphasis-as-heading)
🤖 Prompt for AI Agents