#Should -core packages be explicit dependencies for Yarn/pnpm users?

18 messages · Page 1 of 1 (latest)

jolly mist
#

I just created a fresh TanStack Start project using:

yarn create @tanstack/start --package-manager yarn --no-git

When running yarn dev, I ran into errors that were resolved by manually adding @tanstack/router-core and @tanstack/query-core to my dependencies.

I believe this happens because Yarn Berry (and pnpm) don't auto-install peer dependencies like npm does. Since @tanstack/react-router and @tanstack/react-query have these -core packages as peer dependencies, they need to be explicitly declared.
@tanstack/router-ssr-query-core (used internally by @tanstack/react-router-ssr-query) has peer dependencies on the -core packages and they aren't propagated upwards and declared as dependencies in the starter template project.
My question: For users using Yarn Berry or pnpm, should these -core packages be listed as explicit dependencies in the starter template? Or is there a recommended workaround/configuration that I'm missing?

For reference:

Yarn 4.12.0 (Berry)
Node linker: pnpm (NOT PnP)

Would love to know if this is something that should be addressed in the template or if there's a better approach for strict package managers. Thanks!

hollow crystal
#

i havent heard any complaints from pnpm users

#

does this happen with pnpm as well?

dawn eagle
#

i think later versions of pnpm install peer deps now

#

it's kinda odd for core packages to be peer dependencies rather than normal ones though

jolly mist
#

It's working with pnpm so it seems pnpm does install peer dependencies now.

It's also working with nodeLinker: node-modules for yarn so it seems that the issue is only when using pnpm nodeLinker with yarn.

dawn eagle
#

are there any explicit imports from the core packages in the template project?

#

what specific errors are you getting

jolly mist
#

`X [ERROR] Could not resolve "@tanstack/router-core"

../../node_modules/.store/@tanstack-router-ssr-query-core-virtual-1ef0c73bba/package/dist/esm/index.js:2:27:
  2 │ import { isRedirect } from "@tanstack/router-core";`

I presume it only works with nodeLinker: node-modules due to hoisting

hollow crystal
#

we are definitely open to PRs fixing this. is there a way we could properly track this in the future? given that we dont use yarn in our repo, how would this be analyzable? a custom script?

jolly mist
#

I think the issue is that @tanstack/router-ssr-query-core (used internally by @tanstack/react-router-ssr-query) has peer dependencies on the -core packages. With Yarn pnpm linker, (and I believe with PnP as well, which should be even stricter - but I will check with it as well) these peer dependencies aren't hoisted/accessible, so the internal package can't resolve them.

I will do some more tests (outside of monorepo/yarn workspaces it does seem to work) and open an issue and hopefully a PR.

In regards to how, I think a custom script + CI step to test is the most straightforward way.

#

I replicated it with pnpm as well, using auto-install-peers=false

WARN  Issues with peer dependencies found
.
├─┬ @tanstack/react-devtools 0.7.0
│ └─┬ @tanstack/devtools 0.6.14
│ └─┬ goober 2.1.18
│ └── ✕ missing peer csstype@^3.0.10
├─┬ @tanstack/react-router-devtools 1.132.0
│ └─┬ @tanstack/router-devtools-core 1.132.0
│ ├── ✕ missing peer csstype@^3.0.10
│ ├── ✕ missing peer tiny-invariant@^1.3.3
│ └── ✕ missing peer @tanstack/router-core@^1.132.0
├─┬ @tanstack/react-router-ssr-query 1.131.7
│ ├── ✕ missing peer @tanstack/query-core@>=5.66.0
│ ├── ✕ missing peer @tanstack/react-query@>=5.66.2
│ └─┬ @tanstack/router-ssr-query-core 1.131.7
│ ├── ✕ missing peer @tanstack/router-core@>=1.127.0
│ └── ✕ missing peer @tanstack/query-core@>=5.66.0
├─┬ vite 7.1.7
│ └── ✕ unmet peer @types/node@"^20.19.0 || >=22.12.0": found 22.10.2
└─┬ @tailwindcss/vite 4.0.6
└── ✕ unmet peer vite@"^5.2.0 || ^6": found 7.1.7
Peer dependencies that should be installed:
@tanstack/query-core@>=5.66.0 csstype@">=3.0.10 <4.0.0-0"
@tanstack/react-query@>=5.66.2 tiny-invariant@^1.3.3
@tanstack/router-core@">=1.132.0 <2.0.0"

jolly mist
jolly mist
#

@hollow crystal I presume there is a reason for the -core packages to be peerDepdendencies (singleton, no multiple copies for the query cache and router state?). If there is no reason, we can just add them as dependencies (as oposed to peer dependencies) to router-ssr-query-core.

If there is any specific reason for them to be peerDependencies in router-ssr-query-core, I think the most elegant way for solving this would be to propagate / re-declare the peerDepdendencies upwards, in the public-facing wrapper packages. We would then add them as dependencies in the starter template.

fervent forum
#

The only peerDependency is react.

#

And it's the same for router and start as far as I can see

jolly mist
# fervent forum The claim about react-query isn't correct. The core package is a `dependency`, n...

Yes, it's not a direct peer dependency of react-query or react-router, it's an issue with them being peer dependencies for router-ssr-query-core and not being propagated upwards as a peer dependency (and dependency in the starter template itself).

@my-app/web@workspace:packages/web
└─ @tanstack/react-router-ssr-query@npm:1.147.0 [d8879] (via >=5.90.0)
   └─ @tanstack/router-ssr-query-core@npm:1.146.2 [8b6e8] (via >=5.90.0)
✘ Package @my-app/web@workspace:packages/web does not provide @tanstack/query-core.

Package @my-app/web@workspace:packages/web is requested to provide @tanstack/router-core by its descendants
@my-app/web@workspace:packages/web
└─ @tanstack/react-router-devtools@npm:1.147.0 [d8879] (via ^1.146.2)
   └─ @tanstack/router-devtools-core@npm:1.146.2 [90cc2] (via ^1.146.2)
✘ Package @my-app/web@workspace:packages/web does not provide @tanstack/router-core.```