chore: migrate from Yarn to pnpm as the package manager#622
Conversation
- 更新 .gitignore,添加 pnpm 相关文件 - 修改 package.json,设置 packageManager 为 pnpm,并更新相关脚本 - 更新 GitHub Actions 工作流,替换 Yarn 为 pnpm - 更新开发文档,反映 pnpm 的使用 - 更新 editor 和 frontend 示例的 package.json,使用 pnpm 进行依赖管理
🦋 Changeset detectedLatest commit: 21a3566 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThe project has transitioned its package management system from Yarn to pnpm. All workflow files, scripts, documentation, and configuration have been updated to use pnpm commands and conventions. New pnpm-specific configuration files were added, and references to Yarn were removed or replaced throughout the codebase, documentation, and continuous integration processes. Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant pnpm
participant CI Workflow
participant Node.js
Developer->>pnpm: Run install/build/test commands
pnpm->>Node.js: Resolve and install dependencies
CI Workflow->>pnpm: Install dependencies in CI
CI Workflow->>pnpm: Run build/test/lint scripts
pnpm->>Node.js: Execute scripts using workspace settings
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 6
🔭 Outside diff range comments (4)
packages/editor/package.json (1)
1-1: Align pnpm versions between package.json and CI workflowsYour root package.json pins pnpm to 9.15.0 (line 4), but the GitHub Actions workflows install “latest v9” by default, causing a CLI–packageManager mismatch. To fix this, pin the action to the same patch release:
• Root package.json (package.json:4)
"packageManager": "pnpm@9.15.0",• In each workflow (.github/workflows/release.yml, e2e.yml, test.yml, coverage.yml), update the pnpm setup step:
- name: Install pnpm - uses: pnpm/action-setup@v4 + name: Install pnpm + uses: pnpm/action-setup@v4 with: + version: 9.15.0Alternatively, if you’d rather track patch updates automatically, you can relax the packageManager field to
"pnpm@9"..github/workflows/coverage.yml (1)
42-48: Cache key uses undefinedmatrix.node-version
matrixis not declared in this job, so the expression expands to an empty string and
action-lint flags it.-key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }} +key: ${{ runner.os }}-node-18-${{ hashFiles('**/pnpm-lock.yaml') }}Apply the same fix to the restore-key if present.
.github/workflows/test.yml (1)
55-61: Undefinedmatrix.node-versionin cache keyReplicate the fix applied to
coverage.yml.-key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }} +key: ${{ runner.os }}-node-18-${{ hashFiles('**/pnpm-lock.yaml') }}.github/workflows/e2e.yml (1)
48-60: Undefinedmatrix.node-versionbreaks cache keyThe job does not declare a
matrix, yet the cache key uses${{ matrix.node-version }}.
GitHub Actions will render that as an empty string, defeating cache hits and triggering actionlint errors.Quick fix:
- key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }} + key: ${{ runner.os }}-node-18-${{ hashFiles('**/pnpm-lock.yaml') }}(or introduce a matrix like in
release.yml).
♻️ Duplicate comments (1)
.github/workflows/e2e.yml (1)
42-47: Same pnpm version mismatch as in other workflowsPlease pin
pnpm/action-setupto9.15.0(or relaxpackageManager).
🧹 Nitpick comments (9)
pnpm-workspace.yaml (1)
1-3: Fix YAML formatting issues.The workspace configuration is correct, but there are formatting issues that need to be addressed:
- Missing newline at the end of the file
- Trailing spaces on line 3
Apply this diff to fix the formatting:
packages: - 'packages/*' - - 'shared/*' + - 'shared/*' +packages/yjs/examples/frontend/package.json (1)
9-9:pnpmCLI will fail ifnetlify-cliis not hoistedBecause
pnpmis strict-by-default, thenetlifybinary is only added to this package’s local.binfolder.
The script will work when executed from this workspace only if it is called from this package directory or ifshamefully-hoist=true(which you enabled).
If another workspace script (pnpm -F :frontend deploy) calls it, the binary might be missing.Consider adding the
-wflag or movingnetlify-clito the repo-rootdevDependenciesso the binary is always on the execution path, e.g.:"devDependencies": { - "netlify-cli": "^8.6.0", + "netlify-cli": "^8.6.0", // keep here + "@wangeditor-next/root": { // or move to root package.json + "netlify-cli": "^8.6.0" + } }.npmrc (1)
5-7:shamefully-hoistand the two workspace flags overlap
shamefully-hoist=trueflattens all dependencies into the rootnode_modules, while
prefer-workspace-packages=trueandlink-workspace-packages=truealready ensure local links between packages.Flattening defeats pnpm’s disk-saving goal and can hide duplicate-version problems.
Unless you have a hard tooling constraint that requires a flat tree, drop
shamefully-hoistto keep the install lightweight:-shamefully-hoist=truedocs/dev.md (2)
37-44: Out-of-date Lerna instructions
lerna linkis Yarn-classic specific; with pnpm workspaces the equivalent is handled automatically (pnpm install) or viapnpm link – recursive.Update the note to prevent confusion for new contributors.
- 如果本地包依赖有问题,试试 `lerna link` 关联内部包 + 如果本地包依赖有问题,执行 `pnpm install -r` 重新链接 workspace 依赖
47-56:pnpm size-statsis not a core commandThis is provided by
@pnpm/size-statswhich is not listed anywhere in devDependencies.
Either document the prerequisite:pnpm add -w -D @pnpm/size-statsor change the step to a built-in alternative like
pnpm dlx size-limit.Leaving it undocumented will give newcomers “command not found”.
.github/workflows/coverage.yml (1)
50-56: Missed turbo/pnpm store path optimisation
~/.pnpm-storeis correct for Linux, but the cache entry should point to
${{ env.PNPM_HOME }}/storeto remain future-proof when pnpm switches default
store location.Not blocking, but worth tracking.
.github/workflows/test.yml (1)
62-65: Usepnpm install --frozen-lockfilein CIGuarantees reproducible installs and will fail the job if the lock-file is out of sync.
-run: pnpm install +run: pnpm install --frozen-lockfilepackage.json (2)
19-22: Minor: prefer the shorterpnpm execform in scriptsUsing the binary through pnpm’s shim (
pnpm changeset …) spawns an extra process.
For brevity and tiny perf gain:- "publish": "pnpm changeset publish", - "prerelease": "pnpm build", - "format": "pnpm prettier --write", + "publish": "pnpm exec changeset publish", + "prerelease": "pnpm run build", + "format": "pnpm exec prettier --write",Not blocking, just a nicety.
28-29: Usepnpm runinside concurrently for consistencyInside the
concurrentlystrings you’re bypassing the script runner:- "e2e:dev": "concurrently \"pnpm example\" \"pnpm run cypress:open\"", - "e2e": "concurrently \"pnpm example\" \"pnpm run cypress:run\"", + "e2e:dev": "concurrently \"pnpm run example\" \"pnpm run cypress:open\"", + "e2e": "concurrently \"pnpm run example\" \"pnpm run cypress:run\"",This guarantees lifecycle hooks such as
preexamplerun if they ever exist.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (13)
.github/workflows/coverage.yml(2 hunks).github/workflows/e2e.yml(2 hunks).github/workflows/release.yml(2 hunks).github/workflows/test.yml(2 hunks).gitignore(2 hunks).husky/pre-commit(1 hunks).npmrc(1 hunks)docs/dev.md(1 hunks)docs/test.md(3 hunks)package.json(4 hunks)packages/editor/package.json(1 hunks)packages/yjs/examples/frontend/package.json(1 hunks)pnpm-workspace.yaml(1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Cypress tests
packages/editor/package.json
[error] 1-1: Multiple versions of pnpm specified: version 9 in GitHub Action config and pnpm@9.15.0 in package.json. Remove one to avoid version mismatch errors like ERR_PNPM_BAD_PM_VERSION.
packages/yjs/examples/frontend/package.json
[error] 1-1: Multiple versions of pnpm specified: version 9 in GitHub Action config and pnpm@9.15.0 in package.json. Remove one to avoid version mismatch errors like ERR_PNPM_BAD_PM_VERSION.
package.json
[error] 1-1: Multiple versions of pnpm specified: version 9 in GitHub Action config and pnpm@9.15.0 in package.json. Remove one to avoid version mismatch errors like ERR_PNPM_BAD_PM_VERSION.
🪛 GitHub Actions: Unit Test
packages/editor/package.json
[error] 1-1: Multiple versions of pnpm specified: version 9 in GitHub Action config and pnpm@9.15.0 in package.json. Remove one to avoid version mismatch errors like ERR_PNPM_BAD_PM_VERSION.
packages/yjs/examples/frontend/package.json
[error] 1-1: Multiple versions of pnpm specified: version 9 in GitHub Action config and pnpm@9.15.0 in package.json. Remove one to avoid version mismatch errors like ERR_PNPM_BAD_PM_VERSION.
package.json
[error] 1-1: Multiple versions of pnpm specified: version 9 in GitHub Action config and pnpm@9.15.0 in package.json. Remove one to avoid version mismatch errors like ERR_PNPM_BAD_PM_VERSION.
🪛 YAMLlint (1.37.1)
pnpm-workspace.yaml
[error] 3-3: no new line character at the end of file
(new-line-at-end-of-file)
[error] 3-3: trailing spaces
(trailing-spaces)
🪛 actionlint (1.7.7)
.github/workflows/test.yml
60-60: property "node-version" is not defined in object type {}
(expression)
.github/workflows/coverage.yml
47-47: property "node-version" is not defined in object type {}
(expression)
.github/workflows/e2e.yml
58-58: property "node-version" is not defined in object type {}
(expression)
🔇 Additional comments (7)
packages/editor/package.json (1)
45-45: Script migration looks correct.The change from
yarn dev-watchtopnpm dev-watchis appropriate for the package manager migration..husky/pre-commit (1)
1-1: Pre-commit hook migration looks good.The change from
yarn lint:stagedtopnpm lint:stagedis correct for the package manager migration. The simplified format is appropriate for modern Husky versions..gitignore (2)
68-68: Good generalization of the comment.Changing from "# Yarn Integrity file" to "# Package manager files" makes the comment more generic and appropriate for supporting multiple package managers.
78-80: Proper pnpm-specific entries added.The addition of
pnpm-lock.yamland.pnpm-debug.log*entries is correct and ensures pnpm-specific files are properly excluded from version control.docs/test.md (1)
10-10: Documentation migration is comprehensive and correct.All test-related commands have been properly updated from
yarntopnpm, including unit tests, coverage, build, and E2E test commands. The documentation now accurately reflects the new package manager.Also applies to: 14-14, 18-18, 30-30, 42-42
pnpm-workspace.yaml (1)
1-3: Workspace configuration looks appropriate.The workspace packages configuration correctly includes both
packages/*andshared/*directories, which aligns with the monorepo structure mentioned in the documentation..github/workflows/coverage.yml (1)
58-60: Script name driftThe workflow calls
pnpm run test-c, yet the typical script in this repo istest:cov.
Double-check the package.json scripts to avoid “missing script” failures.
There was a problem hiding this comment.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
.github/workflows/e2e.yml (1)
51-57: Define or Replacematrix.node-versionin Cache KeyThe cache key is currently using an undefined
${{ matrix.node-version }}(lines 51–57 in.github/workflows/e2e.yml), which always resolves to an empty string—breaking cache lookups and triggering Actionlint.Please update one of the following:
• Add a
strategy.matrixfornode-versionin the job:jobs: e2e: strategy: matrix: node-version: [18, 20] runs-on: ubuntu-latest # … steps: - uses: actions/cache@v3 with: key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}• Expose the version from
setup-nodeand reference its output:- id: setup-node uses: actions/setup-node@v4 with: node-version: '18' # … - uses: actions/cache@v3 with: key: ${{ runner.os }}-node-${{ steps.setup-node.outputs.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}• Or hard-code the version if only one Node version is used:
- key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }} + key: ${{ runner.os }}-node-18-${{ hashFiles('**/pnpm-lock.yaml') }}These changes will restore correct cache behavior and silence the lint error.
🧹 Nitpick comments (2)
.github/workflows/e2e.yml (2)
42-45: Pin pnpm version and enable built-in cache instead of a custom stepRelying on the latest pnpm every run can introduce breaking changes without warning.
pnpm/action-setupsupports both version pinning and automatic cache restore, which lets you delete the manualactions/cachestanza altogether:-# 安装 pnpm -- name: Install pnpm -uses: pnpm/action-setup@v4 +# 安装 pnpm(锁定版本并启用缓存) +- name: Install pnpm +uses: pnpm/action-setup@v4 +with: + version: 8 # stick to a major you have tested + cache: trueThis keeps builds reproducible and avoids maintaining two separate cache mechanisms.
61-66: Use--frozen-lockfilefor deterministic installs
pnpm install --frozen-lockfile(or--frozen-if-presentwith v8) fails the build whenpnpm-lock.yamlis out of sync, catching accidental drift early.- - name: Install dependencies - run: pnpm install + - name: Install dependencies + run: pnpm install --frozen-lockfileA tiny guardrail that saves CI time and surprises.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
.github/workflows/e2e.yml(2 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/e2e.yml
56-56: property "node-version" is not defined in object type {}
(expression)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
.github/workflows/e2e.yml (2)
42-45: Pin the pnpm version for deterministic builds
pnpm/action-setup@v4will install the latest pnpm available at workflow-runtime.
Explicitly settingwith: version: '8.x'(or the version the repo is tested with) prevents future, unexpected CI failures when a new major pnpm is released.- - name: Install pnpm - uses: pnpm/action-setup@v4 + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: '8.15.5' # keep in sync with packageManager field in package.json
61-66: Use the lock-file-strict flag to ensure reproducible installs
pnpm installwithout--frozen-lockfile(or--immutable) may rewritepnpm-lock.yaml, causing noisy diffs or divergent environments between local and CI.- run: pnpm install + run: pnpm install --frozen-lockfile --prefer-offlineThis mirrors the strictness you likely had with Yarn and speeds up CI by re-using the cache when possible.
(If you rely onpnpm imodifying the lockfile in CI, ignore this.)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.github/workflows/e2e.yml(2 hunks)package.json(3 hunks)packages/custom-types.d.ts(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- package.json
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/e2e.yml
56-56: property "node-version" is not defined in object type {}
(expression)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: test
- GitHub Check: test-e2e
🔇 Additional comments (2)
packages/custom-types.d.ts (2)
5-5: LGTM: Proper placement of triple-slash directive.The
/// <reference types="slate" />directive is correctly placed at the top of the file before imports, ensuring Slate type definitions are available throughout the module. This explicit reference improves type safety and is good practice, especially with pnpm's stricter dependency resolution.
107-107: LGTM: Explicit type exports improve module interface.The explicit export of
BaseElement,CustomElement, andElementTypemakes these core types available for import in other modules. All exported types are properly defined within the file and represent the key type definitions that other parts of the codebase would likely need to reference.
Changes Overview
Implementation Approach
Testing Done
Verification Steps
Additional Notes
Checklist
Related Issues
Summary by CodeRabbit
Chores
Documentation