kit
kit copied to clipboard
svelte-package and PNPM workspace Catalogs: Invalid comparator: catalog:
Describe the bug
Using this pnpm workspace catalog feature in turborepo and svelte-package
https://pnpm.io/catalogs
Error: > Invalid comparator: catalog:
pnpm-workspace.yaml
catalog:
eslint: ^9.7.0
prettier: ^3.3.3
typescript: ^5.5.3
zod: ^3.23.8
svelte: ^5.0.0-next.184
tailwindcss: ^3.4.7
package.json
"devDependencies": {
"tailwindcss": "catalog:",
},
Reproduction
Run svelte-package on svelte project that is using pnpm workspace catalog feature.
Logs
No response
System Info
System:
OS: macOS 14.5
CPU: (10) arm64 Apple M1 Max
Memory: 625.48 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.15.1 - ~/.nvm/versions/node/v20.15.1/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 10.7.0 - ~/.nvm/versions/node/v20.15.1/bin/npm
pnpm: 9.6.0 - /opt/homebrew/bin/pnpm
bun: 1.1.21 - /opt/homebrew/bin/bun
Browsers:
Chrome: 127.0.6533.72
Safari: 17.5
Severity
blocking all usage of SvelteKit
Additional Information
No response
Relevant?: https://github.com/sveltejs/kit/pull/12120
Not sure how to use override feature.
Any update?
please provide a link to a repository with a complete and minimal reproduction.
minimal in this case means not using turborepo but just a pnpm workspace with catalogs.
Ok, had time to do more digging: The issue is coming from semver which @sveltejs/package uses.
pnpm-workspace.yaml
catalog:
svelte: ^5.0.0-next.257
"@sveltejs/kit": ^2.6.1
catalogs:
sveltetooling:
"@sveltejs/adapter-auto": ^3.2.2
"@sveltejs/adapter-node": ^5.2.4
"@sveltejs/package": ^2.0.0
"@sveltejs/vite-plugin-svelte": ^3.1.1
vite-plugin-kit-routes: 0.6.11
publint: 0.2.9
svelte-check: ^3.8.4
tslib: ^2.6.3
vite: ^5.4.7
Its specifically catalog: that doesn't work. but catalog:sveltetooling works.
package.json
{
"name": "@company/ui",
"version": "0.0.1",
"private": true,
"type": "module",
"exports": {
},
"files": [
"dist",
"!dist/**/*.test.*",
"!dist/**/*.spec.*"
],
"scripts": {
"dev": "vite dev --open",
"build": "vite build && pnpm package",
"clean": "rm -rf .turbo dist node_modules",
"preview": "vite preview",
"package": "svelte-kit sync && svelte-package && publint",
"prepublishOnly": "npm run package",
"format": "prettier --check . --ignore-path ../../.gitignore",
"lint": "eslint",
"test": "npm run test:integration && npm run test:unit",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"test:integration": "playwright test",
"test:unit": "vitest",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"dependencies": {
},
"devDependencies": {
"@sveltejs/kit": "catalog:",
"@sveltejs/package": "catalog:sveltetooling"
},
}
I ended up solving the issue: not sure why but it was essentially using "svelte": "catalog:" in peerDependencies doesn't work.
It is only svelte in peerDependencies that causes the issue. I have to actually have an actual value in peerDependencies: "svelte": "5.0.0-next.260". Although any other package in peerDependencies with catalog: works...
Deleted node_modules and did pnpm store prune and its only the svelte package.
Based on pnpm docs apparently you can't use catalog: in peerDependencies...but its work for other packages.
Only these are ok based on docs dependencies devDependencies optionalDependencies pnpm.overrides
It does appear that you can now use catalog: for peerDependencies:
Is this something that svelte-package could support? It looks as though this is the part that doesn't work at the moment:
https://github.com/sveltejs/kit/blob/09296d0f19c8d1ff57d699e637bd1beabb69d438/packages/package/src/typescript.js#L30-L31
I guess in the case of a catalog: dependency it would need to go and resolve the svelte version from the pnpm-workspace.yml file.
Seems like this could be fixed by https://github.com/sveltejs/kit/pull/13850 already?