Skip to content

npm -> pnpm#8035

Merged
zurfyx merged 61 commits intomainfrom
pnpm
Dec 21, 2025
Merged

npm -> pnpm#8035
zurfyx merged 61 commits intomainfrom
pnpm

Conversation

@zurfyx
Copy link
Copy Markdown
Member

@zurfyx zurfyx commented Dec 17, 2025

We have made the decision to migrate to PNPM. We believe Lexical can benefit from its security and performance.

This PR encapsulates the minimum viables changes to get there, which boil down to:

  • Replacing npm for pnpm and adjusting the syntax
  • Declaring phantom dependencies
  • Small tweaks to the CI (including an upgrade to Node 22 LTS)

Test plan:

  • Compare build side-by-side
  • Compare (Meta) WWW build side-by-side
  • Meta's PNPM internal deployment (D89383966)
  • CI passes
  • NPM publish (let's merge this PR first)
  • Updating CONTRIBUTING.md
  • Create new package (will be followed up separately after docs/)

@vercel
Copy link
Copy Markdown

vercel bot commented Dec 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
lexical Ready Ready Preview, Comment Dec 21, 2025 10:11pm
lexical-playground Ready Ready Preview, Comment Dec 21, 2025 10:11pm

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 17, 2025
.pnpmrc Outdated
@@ -0,0 +1 @@
legacy-peer-deps=true
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think this is a config option at all in pnpm

Copy link
Copy Markdown
Collaborator

@etrepum etrepum left a comment

Choose a reason for hiding this comment

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

Haven't had a chance to look through all of it or try it locally yet but this is what I noticed with a quick look

strategy:
matrix:
node-version: [22.19.0]
node-version: [22.x]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is there a strong reason to keep 22.x instead of upgrading to the active lts 24.x?

Copy link
Copy Markdown
Member Author

@zurfyx zurfyx Dec 19, 2025

Choose a reason for hiding this comment

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

For some reason, 24.x and 25.x hang when running Playwright, which I why I intentionally put an engine restriction of < 23.0. I was thinking to look at it separately, maybe upgrading the latest Playwright version will do but there's already a lot going on in this PR

Comment on lines +13 to +24
"@lexical/clipboard": "file:../../npm/lexical-clipboard-0.39.0.tgz",
"@lexical/dragon": "file:../../npm/lexical-dragon-0.39.0.tgz",
"@lexical/extension": "file:../../npm/lexical-extension-0.39.0.tgz",
"@lexical/history": "file:../../npm/lexical-history-0.39.0.tgz",
"@lexical/html": "file:../../npm/lexical-html-0.39.0.tgz",
"@lexical/list": "file:../../npm/lexical-list-0.39.0.tgz",
"@lexical/rich-text": "file:../../npm/lexical-rich-text-0.39.0.tgz",
"@lexical/selection": "file:../../npm/lexical-selection-0.39.0.tgz",
"@lexical/table": "file:../../npm/lexical-table-0.39.0.tgz",
"@lexical/utils": "file:../../npm/lexical-utils-0.39.0.tgz",
"emoji-datasource-facebook": "15.1.2",
"lexical": "0.39.0"
"lexical": "file:../../npm/lexical-0.39.0.tgz"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this looks like an accident

"vitest-browser-svelte": "^0.1.0"
},
"optionalDependencies": {
"@rollup/rollup-linux-x64-gnu": "4.6.1"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I wonder if we might want to add other platforms to this or to include @rollup/wasm-node or something

async () => {
await withCwd(exampleDir, () => expectSuccessfulExec('npm run test'));
await withCwd(exampleDir, () =>
expectSuccessfulExec('pnpm run test'),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is a bit inconsistent, right now everything else with examples and integration tests is run with npm and uses package-lock.json. I think it happens to work because the node_modules is set up properly but it is a bit strange

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@etrepum This was actually intentional but I'm happy to do either way. My thought process is, documentation and examples are user-oriented, and folks are the most familiar with NPM. For developers in our repo, PNPM is preferable option. Would you agree with this / or do you think that these examples are more test oriented as opposed to user facing?

Copy link
Copy Markdown
Collaborator

@etrepum etrepum Dec 20, 2025

Choose a reason for hiding this comment

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

I think either is fine but it should be consistent, if we’re installing example with npm we should be testing the examples with npm (and making sure to handle the correct lock files). I don’t think it’s a big deal either way, the examples should still work for users with any package manager, the only difference should be whether a lockfile is used or not.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah yes, you're completely right, sorry I misread the code pointer

await exec(cmd);
await exec(
`git checkout package-lock.json package.json packages/*/package.json`,
`git checkout pnpm-lock.yaml package.json packages/*/package.json`,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This might not be working correctly because the examples are still using npm and package-lock.json?

CONTRIBUTING.md Outdated
Comment on lines +13 to +15
npm install -g pnpm
# or if you have Node.js 16.13+
corepack enable
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think these instructions might be a bit out of date, the latest node versions have moved corepack out of the distribution so it might be something more like

npx corepack@latest enable

@etrepum
Copy link
Copy Markdown
Collaborator

etrepum commented Dec 20, 2025

I confirmed that installing and running the unit tests & e2e tests works as expected.

After a closer look I think it's probably worth auditing each pnpm run that uses -- since those might not be correct anymore. Those exist because npm run arg --foo has npm parse the argument --foo but pnpm run arg --foo passes the argument to the script like npm run arg -- --foo which is what's wanted in 99.99% of the cases (and how npx behaves). It also gets really messy in npm when scripts invoke other scripts so you have multiple layers of --.

The solution is probably to just get rid of all the --.

@thedjpetersen
Copy link
Copy Markdown

Neat - curious to learn more about the advantages of PNPM

@etrepum
Copy link
Copy Markdown
Collaborator

etrepum commented Dec 22, 2025

The primary motivation for this PR is better security defaults. There are also some developer ergonomic improvements such as better script argument passing with pnpm run vs. npm run (no need for -- escaping).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants