Repo: Migrate from yarn to pnpm
Suggestion
We (@bradzacher, @JoshuaKGoldberg and I) decided instead of moving to yarn v4, we will migrate to pnpm.
Additional Info
- As part of the PR, we can switch all intra-package references to use the
workspace:protocol, becausenx releasecan delegate topnpm publishbehind the scenes and dynamically swap these references at publish time
Is it still actual?
I've started working on this. Please let me know if there are any recent updates or considerations I should keep in mind.
Why? I love yarn over pnpm: https://x.com/JounQin/status/1920014194629369941.
Why?
I can't find the deeper technical discussion on demand, but a few general reasons:
- As great as Yarn is, it's pretty configuration-heavy
- pnpm has a lot of great defaults and workspaces support - e.g. the OP's mention
- Several of us on the team have been using pnpm for our projects & quite liking it
https://x.com/JounQin/status/1920014194629369941
That looks like a specific bug in pnpm rather than anything intentional & structural, right? From the replies, https://github.com/pnpm/pnpm/issues/7543? I personally haven't experienced that bug.
That looks like a specific bug in pnpm rather than anything intentional & structural, right?
It's about TypeScript integration.
https://x.com/isukkaw/status/1920031880369352806
https://github.com/orgs/pnpm/discussions/5535
See aslo TypeScript related issues: https://github.com/pnpm/pnpm/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20TypeScript
https://x.com/JounQin/status/1924721715701321764 :(
AIUI this isn't a bug in pnpm or TS -- it's a bug in the packages -- they're not declaring their dependencies correctly.
AUIU PNPM is adhering to the declared dependencies and symlinking appropriately, and then TS can't see the types because the types aren't even there.
AIUI this isn't a bug in pnpm or TS -- it's a bug in the packages -- they're not declaring their dependencies correctly.
Nope, it's just not presented in my local configed registry at that time, it should result http 404 error instead of local not found error. After syncing the package in the registry, everything just works fine then.
AUIU PNPM is adhering to the declared dependencies and symlinking appropriately, and then TS can't see the types because the types aren't even there.
I met several times when bumping @types/node package in a pnpm mono repo, it just conflicts even with pnpm.overrides to enforce a single version, only removing node_modules and reinstalling helps. What means it doesn't clean up unused dependencies in the store.
Oh, poor pnpm. https://github.com/un-ts/eslint-plugin-import-x/issues/364
AIUI this isn't a bug in pnpm or TS -- it's a bug in the packages -- they're not declaring their dependencies correctly.
AUIU PNPM is adhering to the declared dependencies and symlinking appropriately, and then TS can't see the types because the types aren't even there.
Are you saying that typescript-eslint is not correctly declaring @typescript-eslint/estree as @typescript-eslint/utils's dependency? Because this is exactly what happened to https://github.com/orgs/pnpm/discussions/5535#discussioncomment-13060412
Reproduction: https://github.com/SukkaW/eslint-config-sukka
git clone https://github.com/SukkaW/eslint-config-sukka && cd eslint-config-sukka
pnpm i
npx tsc --noEmit
Oh, poor pnpm. un-ts/eslint-plugin-import-x#364
I'm showing why pnpm could be bad, I don't understand why it's marked as spam.
Actually there is at least a more invalid usage of typescript in this repo:
https://github.com/typescript-eslint/typescript-eslint/blob/e4933170f75b3a8a0c9bf3985fb4d2ddb6e4b4c6/packages/project-service/src/createProjectService.ts#L106
typescript-eslint on chore/import-x ❯ y eslint
/Users/JounQin/Workspaces/GitHub/typescript-eslint/packages/project-service/src/createProjectService.ts
106:20 error 'typescript' should be listed in the project's dependencies. Run 'npm i -S typescript' to add it import-x/no-extraneous-dependencies
@JounQin that is definitely a bug -- typescript is not listed as a peer dependency like it is in other packages
https://github.com/typescript-eslint/typescript-eslint/blob/e4933170f75b3a8a0c9bf3985fb4d2ddb6e4b4c6/packages/project-service/package.json
Feel free to file a new issue! (cc @JoshuaKGoldberg)
Here we go: #11264 and #11265
And it also means eslint is not running correctly with nx:
typescript-eslint on chore/import-x [⇕] ❯ y eslint
/Users/JounQin/Workspaces/GitHub/typescript-eslint/packages/project-service/src/createProjectService.ts
106:20 error 'typescript' should be listed in the project's dependencies. Run 'npm i -S typescript' to add it import-x/no-extraneous-dependencies
/Users/JounQin/Workspaces/GitHub/typescript-eslint/packages/project-service/tests/createProjectService.test.ts
2:1 error 'typescript' should be listed in the project's dependencies. Run 'npm i -S typescript' to add it import-x/no-extraneous-dependencies
49:32 error 'typescript' should be listed in the project's dependencies. Run 'npm i -S typescript' to add it import-x/no-extraneous-dependencies
127:14 error 'typescript' should be listed in the project's dependencies. Run 'npm i -S typescript' to add it import-x/no-extraneous-dependencies
/Users/JounQin/Workspaces/GitHub/typescript-eslint/packages/project-service/vitest.config.mts
2:1 error 'vitest' should be listed in the project's dependencies. Run 'npm i -S vitest' to add it import-x/no-extraneous-dependencies
/Users/JounQin/Workspaces/GitHub/typescript-eslint/packages/tsconfig-utils/vitest.config.mts
2:1 error 'vitest' should be listed in the project's dependencies. Run 'npm i -S vitest' to add it import-x/no-extraneous-dependencies
/Users/JounQin/Workspaces/GitHub/typescript-eslint/packages/website/docusaurus.config.mts
436:8 error Prefer named exports import-x/no-default-export
/Users/JounQin/Workspaces/GitHub/typescript-eslint/packages/website/src/theme/prism-include-languages.js
4:8 error Prefer named exports import-x/no-default-export
✖ 8 problems (8 errors, 0 warnings)
cc @JoshuaKGoldberg
@SukkaW Looking at your example -- it looks like there is something off.
For whatever reason it has not symlinked @typescript-eslint/types as a dependency of @typescript-eslint/utils, even though it is declared as a dependency.
Probably a bug in pnpm there -- would be worth a minimal repro for a clear bug report to the maintainers so they can investigate.
But in general when I've seen such problems occur it has been because there was a missing peer dependency somewhere.