typescript-eslint icon indicating copy to clipboard operation
typescript-eslint copied to clipboard

Repo: Migrate from yarn to pnpm

Open JamesHenry opened this issue 1 year ago • 15 comments

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, because nx release can delegate to pnpm publish behind the scenes and dynamically swap these references at publish time

JamesHenry avatar Feb 26 '25 09:02 JamesHenry

Is it still actual?

xaos7991 avatar May 07 '25 08:05 xaos7991

I've started working on this. Please let me know if there are any recent updates or considerations I should keep in mind.

xaos7991 avatar May 18 '25 19:05 xaos7991

Why? I love yarn over pnpm: https://x.com/JounQin/status/1920014194629369941.

JounQin avatar May 18 '25 23:05 JounQin

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.

JoshuaKGoldberg avatar May 19 '25 13:05 JoshuaKGoldberg

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

JounQin avatar May 19 '25 13:05 JounQin

https://x.com/JounQin/status/1924721715701321764 :(

JounQin avatar May 20 '25 07:05 JounQin

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.

bradzacher avatar May 21 '25 11:05 bradzacher

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.

JounQin avatar May 21 '25 12:05 JounQin

Oh, poor pnpm. https://github.com/un-ts/eslint-plugin-import-x/issues/364

JounQin avatar May 31 '25 14:05 JounQin

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

SukkaW avatar Jun 01 '25 09:06 SukkaW

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.

JounQin avatar Jun 01 '25 09:06 JounQin

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 avatar Jun 01 '25 09:06 JounQin

@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)

bradzacher avatar Jun 01 '25 10:06 bradzacher

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

JounQin avatar Jun 01 '25 11:06 JounQin

@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.

bradzacher avatar Jun 01 '25 11:06 bradzacher