You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just went through the lengthy exercise of trying to migrate our somewhat large monorepo from yarn 1.x to pnpm 7.x and have run into some troubles that I'm not sure how to solve and hopefully someone can shed some light on. Essentially, I've got everything working, but am running into significantly larger bundle sizes when using pnpm and it seems to be from dependencies from sub-projects that are not used in the root project leaking into the root project's generated bundles when producing a production build with webpack 4.
It might help to explain how our projects were setup in the yarn world:
root
app <-- the main webapp, uses root package.json for deps
workspaces/* <-- there are a couple dozen or so actual yarn workspaces in here
sub-project1
sub-project2
sub-project1 and sub-project2 both have their own package.json, but also use dependencies from the root package.json. They also have tsconfig compilerOptions.paths set to import from app/ when an import could not be found local to the project. We run yarn commands to build those projects from within those folders and package them up for deployment.
Now, with pnpm, I was not able to figure out how to keep those subprojects separate, and so I tried making them workspaces, just like our other real workspaces, and while that ultimately worked, it had the effect described above, where deps are leaking into the root app, causing bundle sizes to increase significantly. A specific example is:
app has a dep on react-quill
sub-project1 has a dep on quill
quill.js from both quill and react-quill are ending up in the bundle used in the main app, whereas with yarn only the react-quill one did.
So, my questions are:
Am I correct in assuming the only way to get those subprojects to continue to work within the monorepo, is to make them workspaces?
Is the leakage from subproject to main project an issue with pnpm or webpack 4 not understanding pnpm's node_modules structure and thus not tree-shaking properly?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I just went through the lengthy exercise of trying to migrate our somewhat large monorepo from yarn 1.x to pnpm 7.x and have run into some troubles that I'm not sure how to solve and hopefully someone can shed some light on. Essentially, I've got everything working, but am running into significantly larger bundle sizes when using pnpm and it seems to be from dependencies from sub-projects that are not used in the root project leaking into the root project's generated bundles when producing a production build with webpack 4.
It might help to explain how our projects were setup in the yarn world:
sub-project1 and sub-project2 both have their own package.json, but also use dependencies from the root package.json. They also have tsconfig compilerOptions.paths set to import from
app/when an import could not be found local to the project. We run yarn commands to build those projects from within those folders and package them up for deployment.Now, with pnpm, I was not able to figure out how to keep those subprojects separate, and so I tried making them workspaces, just like our other real workspaces, and while that ultimately worked, it had the effect described above, where deps are leaking into the root app, causing bundle sizes to increase significantly. A specific example is:
So, my questions are:
If it helps at all, here's our .npmrc settings:
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions