Skip to content

feat(infra): adopt pnpm #7662

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

feat(infra): adopt pnpm #7662

wants to merge 2 commits into from

Conversation

bmuenzenmeyer
Copy link
Collaborator

@bmuenzenmeyer bmuenzenmeyer commented Apr 17, 2025

  • next.config.js, next-intl, i18n work — commit
  • pnpm build — import errors resolved, packages cleaned up
    • pnpm build when installed with --prod
  • pnpm dev
    • pnpm dev when installed with --prod
  • pnpm test - subpath import work needed
  • pnpm test:ci
  • pnpm lint
  • pnpm lint:fix
  • pnpm prettier
  • pnpm prettier:fix
  • pnpm format
  • pnpm storybook
  • pnpm storybook:build
  • pnpm check-types
  • pnpm scripts:release-post
  • Vercel Deployments
  • npm use cases

Tasks from Vote

Copy link

vercel bot commented Apr 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nodejs-org ❌ Failed (Inspect) Apr 25, 2025 11:43pm

@bmuenzenmeyer
Copy link
Collaborator Author

running full ci just for fun

@avivkeller
Copy link
Member

running full ci just for fun

FWIW because this changes the pull_request_target workflows, a full CI will almost certainly fail every time (as the main branch CI doesn't set up pnpm). What I would do is, add a workflow_dispatch trigger to each of the CIs you want to test, and trigger them with:

gh workflow run lint-and-tests.yml --ref pnpm

Before merging, just remove the trigger.

@avivkeller
Copy link
Member

Locally with npm:

> cd apps/site
> npm install --omit=dev --include-workspace-root
> npm run dev

Runs fine

@ovflowd
Copy link
Member

ovflowd commented Apr 24, 2025

npm error code EBADDEVENGINES
npm error EBADDEVENGINES The developer of this package has specified the following through devEngines
npm error EBADDEVENGINES Invalid engine "packageManager"
npm error EBADDEVENGINES Invalid name "pnpm" does not match "npm" for "packageManager"
npm error EBADDEVENGINES {
npm error EBADDEVENGINES   current: { name: 'npm', version: '10.9.2' },
npm error EBADDEVENGINES   required: {
npm error EBADDEVENGINES     name: 'pnpm',
npm error EBADDEVENGINES     version: '10.8.0+sha256.29bf2c5ceaea7991ee82eec15fe7162e0fad816d0c4a6b35a16c01d39274bf69'
npm error EBADDEVENGINES   }
npm error EBADDEVENGINES }
npm error A complete log of this run can be found in: /vercel/.npm/_logs/2025-04-24T20_40_20_242Z-debug-0.log
Error: Command "turbo build" exited with 1

@avivkeller
Copy link
Member

avivkeller commented Apr 24, 2025

Ugh! What more does Vercel want from us?! I'm going to try to turbo build and see.

@avivkeller
Copy link
Member

avivkeller commented Apr 24, 2025

Yep, Vercel is definetely going to throw a temper tantrum. I think we need to suck it up and enable pnpm on it right before merge.

@bmuenzenmeyer
Copy link
Collaborator Author

can we add devEngines as a fast-follow?

@AugustinMauroy
Copy link
Member

I've just had a look, and I didn't see a link/explanation to get the right version of pnpm.

@avivkeller
Copy link
Member

avivkeller commented Apr 25, 2025

can we add devEngines as a fast-follow?

It's more than that to satisfy Vercel. IIUC, Vercel does the following (among other things):

cd apps/site
npm i
npx turbo build

You'll see that the steps will fail for various reasons. After doing some (failed) testing, IMHO It's easier to switch Vercel to pnpm, at the risk of a few broken PRs, than to rework this PR to satisfy npm.

I've just had a look, and I didn't see a link/explanation to get the right version of pnpm.

What do you mean? The version of pnpm we use is 10.x.

  • npm use cases

@bmuenzenmeyer I don't understand what this task is? It's really the only thing left to complete (besides Vercel deployments).

@bmuenzenmeyer
Copy link
Collaborator Author

@bmuenzenmeyer I don't understand what this task is? It's really the only thing left to complete (besides Vercel deployments).

I want to explore what the experience is when someone casually tries to use npm, per #5334 (comment) - I now know that devEngines will likely stop them in their tracks. so... that request of @AugustinMauroy's might be in direct conflict with the devEngines vote

@avivkeller avivkeller marked this pull request as ready for review April 25, 2025 16:28
@avivkeller avivkeller requested review from a team as code owners April 25, 2025 16:28
@avivkeller
Copy link
Member

avivkeller commented Apr 25, 2025

IMO we should prioritize the vote rather than the request. On that note, since everything is working (well, except Vercel), I've marked this Ready for Review.

@@ -1 +1 @@
v22
v22.13.0
Copy link
Member

Choose a reason for hiding this comment

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

Can we not just use v22?

Copy link
Member

@MattIPv4 MattIPv4 left a comment

Choose a reason for hiding this comment

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

Why have a bunch of @/ shorthand imports been changed to relative imports?

Comment on lines +72 to +74
"cross-env": "7.0.3",
"@types/node": "22.14.0",
"@types/react": "^19.1.0"
Copy link
Member

Choose a reason for hiding this comment

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

These should be alphabetical?

Copy link
Member

Choose a reason for hiding this comment

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

should

"vfile-matter": "~5.0.1"
"vfile-matter": "~5.0.1",
"cross-env": "7.0.3",
"@types/node": "22.14.0",
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't match the minor version in .nvmrc (afaik @types/node should match on major/minor, but patch does not match)

"@types/node": "22.14.0",
"@types/react": "^19.1.0",
"@types/react-dom": "^19.1.1",
"cross-env": "7.0.3",
Copy link
Member

Choose a reason for hiding this comment

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

Why is this pinned to an exact version, and present here as well as in the site's dependencies?

Copy link
Member

Choose a reason for hiding this comment

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

It's present b/c we use it in the scripts section of the package.json. In pnpm (IIUC), you need to declare dependencies in each package.json that they are used.

Copy link
Member

Choose a reason for hiding this comment

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

Ah okay, that's news to me if that's the case -- can we double-check it is? If it is, can we have it reference the parent package's version for it?

And, I'm not sure that was an answer to why it is pinned to a specific version?

"eslint-plugin-react": "~7.37.4",
"eslint-plugin-storybook": "~0.12.0",
"global-jsdom": "^26.0.0",
"postcss-loader": "~8.1.1",
"react": "19.1.0",
Copy link
Member

Choose a reason for hiding this comment

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

Confirming if this is intentionally pinned, when the types for it aren't?

Copy link
Member

Choose a reason for hiding this comment

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

We should use peer dependencies for these cases.

Check out other applications (https://github.com/dubinc/dub/blob/93c76aaf304a10fcf914c1c4dc344f6011e2bc6b/packages/ui/package.json#L35)

@MattIPv4
Copy link
Member

On my --frozen-lockfile comments, happy to have dissenting opinions there -- https://pnpm.io/settings#preferfrozenlockfile pnpm does default to respecting it exactly if it's valid, so it should be fine to not pass the arg, but I tend to like being explicit about it?

@avivkeller
Copy link
Member

I mean, SGTM, we can always change it if needed.

import useClientContext from '@/hooks/react-client/useClientContext';
import { MatterContext } from '@/providers/matterProvider';
import useClientContext from '../useClientContext';
import { MatterContext } from '../../../providers/matterProvider';
Copy link
Member

Choose a reason for hiding this comment

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

Why can’t "@/" be used anymore? pnpm should not affect the path aliases.

Comment on lines +5 to +9
onlyBuiltDependencies:
- '@swc/core'
- '@vercel/speed-insights'
- esbuild
- sharp
Copy link
Member

Choose a reason for hiding this comment

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

A comment on why it's necessary would be great.

Comment on lines +29 to +32
"@opentelemetry/api-logs": "~0.200.0",
"@opentelemetry/instrumentation": "~0.200.0",
"@opentelemetry/resources": "~1.30.1",
"@opentelemetry/sdk-logs": "~0.200.0",
Copy link
Member

Choose a reason for hiding this comment

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

Why do we have to add all those new dependencies?

Co-authored-by: Matt Cowley <me@mattcowley.co.uk>
Signed-off-by: Aviv Keller <me@aviv.sh>
@ovflowd
Copy link
Member

ovflowd commented Apr 26, 2025

npm error code EUNSUPPORTEDPROTOCOL
npm error Unsupported URL Type "workspace:": workspace:*
npm error A complete log of this run can be found in: /vercel/.npm/_logs/2025-04-25T23_42_55_527Z-debug-0.log
Error: Command "npm install --omit=dev --include-workspace-root" exited with 1

@MattIPv4
Copy link
Member

Is that from Vercel? That makes sense, the install/build commands for the entire project will need to be changed IIRC. So, I imagine we'll want to flip them for a second to pnpm, deploy this branch, and then flip them back to npm to allow main and other PRs to work.

@MattIPv4
Copy link
Member

Ah, looks like we can add vercel.json to override it for this specific branch: https://vercel.com/docs/package-managers#deployment-override

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.

7 participants