pnpm + solid-start causes multiple versions of vite to be installed due to inconsistent installation of peerDependencies
vite has peerDependencies. https://github.com/vitejs/vite/blob/main/packages/vite/package.json#L123-L128
"peerDependencies": {
"less": "*",
"sass": "*",
"stylus": "*",
"terser": "^5.4.0"
},
pnpm will install multiple instances of a package with the same version depending on which peers are installed. https://www.pnpm.cn/how-peers-are-resolved
In this snippet of pnpm-lock.yaml there are two installs of vite. Some of the packages that import vite have terser & some do not.
/vite/3.0.9:
resolution: {integrity: sha512-waYABTM+G6DBTCpYAxvevpG50UOlZuynR0ckTK5PawNVt7ebX6X7wNXHaGIO6wYYFXSM7/WcuFuO2QzhBB6aMw==}
engines: {node: ^14.18.0 || >=16.0.0}
hasBin: true
peerDependencies:
less: '*'
sass: '*'
stylus: '*'
terser: ^5.4.0
peerDependenciesMeta:
less:
optional: true
sass:
optional: true
stylus:
optional: true
terser:
optional: true
dependencies:
esbuild: 0.14.54
postcss: 8.4.16
resolve: 1.22.1
rollup: 2.77.3
optionalDependencies:
fsevents: 2.3.2
/vite/[email protected]:
esolution: {integrity: sha512-waYABTM+G6DBTCpYAxvevpG50UOlZuynR0ckTK5PawNVt7ebX6X7wNXHaGIO6wYYFXSM7/WcuFuO2QzhBB6aMw==}
engines: {node: ^14.18.0 || >=16.0.0}
hasBin: true
peerDependencies:
less: '*'
sass: '*'
stylus: '*'
terser: ^5.4.0
peerDependenciesMeta:
less:
optional: true
sass:
optional: true
stylus:
optional: true
terser:
optional: true
dependencies:
esbuild: 0.14.54
postcss: 8.4.16
resolve: 1.22.1
rollup: 2.77.3
terser: 5.15.0
optionalDependencies:
fsevents: 2.3.2
I have a component, Singleton_, which is not transpiled presumably due to two different instances of vite being installed. When pnpm run dev is called & the page is loaded, the following error occurs:
ERROR TypeError: __vite_ssr_import_6__.Singleton_ is not a function
I'm not sure what the best solution is. Perhaps any solid-start packages that import vite should mirror vite's peerDependencies? or install all of the peerDependencies?
I was able to solve this by using pnpm overrides in package.json.
"pnpm": {
"overrides": {
"babel-preset-solid": "latest",
"chalk": "2.4.2",
"solid-js": "latest",
"solid-start": "next",
"solid-start-cloudflare-workers": "next",
"solid-start-node": "next",
"solid-start-vercel": "next",
"terser": "5.15.0",
"vite": "latest"
},
"packageExtensions": {
"solid-start": {
"dependencies": {
"solid-js": "latest"
},
"peerDependencies": {
"solid-js": "latest"
}
},
"vite-plugin-solid": {
"dependencies": {
"terser": "5.15.0"
}
}
}
}
Hey thanks for investigating this! Could you make PR with the fix you are suggesting.. I don't have great amount of knowledge about this peerDependencies mechanism?
The issue is essentially the gate to dependency hell & project specific. It seems the most effective solution is to simplify the dependency tree to bare essentials & to stay up to date with the latest versions.
Now that we are off next I'm hoping this won't be an issue. Everything is now able to leverage semver ranges.
@btakita is this still an issue?
It looks like
It looks like the dependency issues are resolved. Thank you!