-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strip in-workspace devDependencies when pruning #1100
Comments
This not always just a question of optimizing file size. I have a situation with a backend project that is strictly node, but uses some browser-based utilities when testing. In order to build those browser dependencies that get pulled in I also have to manually pull in the resources required to build those dependencies (for example I have separate base tsconfig.json files for node and for browser at the root of the monorepo). It's not the end of the world but you start to quickly lose the point of pruning if you're pulling in half your monorepo and littering your docker images with resources that are only used to workaround this issue. P.S. - I'm realizing my tone probably comes off as more stern than I mean to. I agree it's not a huge deal but it would make Turborepo even more awesome if it wasn't the case :) |
@joemckenney care to share your |
@azertyalex Here's a gist https://gist.github.com/joemckenney/fd55f02ab0bf905283423aadeeca80ca The script uses a package we built called @dopt/wutils - which assumes you use pnpm. It's open source but not published to any registry - you can find it here https://github.com/dopt/odopt/tree/main/packages/%40dopt/wutils and take inspiration from it or copy pieces to recreate the functionality. Some additional context - this problem was solved by our shift from yarn to pnpm and pnpm's deploy command. |
okay, thanks! I stumbled upon |
Tagging core team member to make sure this gets seen since it is a pretty major issue @gsoltis Annoyingly, pnpm v8 introduced a regression where it broke Related pnpm issues: |
A cc @chris-olszewski, how hard would this be to do? I got a little lost reading the |
This is something we do want to add, but a few things need to happen first:
|
Faced this today where one of our packages required some devDependencies for building it but |
Just came across this problem when dockerizing my app today. The only decent workaround I could think of is to extract packages that are |
- This required a lot of changes and some configs/plugins still haven't updated yet, so will have to wait until they do (e.g. eslint-plugin-jsx-a11y). - Removed airbnb configs in favor of using default recommended rules. - Updated prettier config to use more of the defaults rather than deviating. - Fixed an issue with the `update-package-lock` npm script where using `rm` didn't actually delete the files for some reason. Switched to `rimraf` and it works. - Added more `tsconfig.eslint.json` files to packages/apps so files that shouldn't be part of the bundle don't get transpiled to the build/dist directory. - Fixed issues with the Docker build where the full node_modules were not being pulled in. I wonder if there was a caching issue that masked the bug because apps should not have been able to run. We can either extract packages and publish them to npm or live with massive Docker images until Turbo fixes the issue. See vercel/turborepo#1100
I spent some time struggling with the same issue. I am using pnpm and I tried Till there is a fix, here is a possible workaround - |
Describe the feature you'd like to request
Hi,
First of all, thanks for this awesome project, it's really powerful!
We're currently using the great
turbo prune
feature, and we noticed a potential optimization.Imagine a project
app
having two "in-workspace" dependencies:lib-config
as adependency
tooling
as adevDependency
Currently, running
turbo prune --scope=app
will generate a directoryout/
withapp
,lib-config
andtooling
.In our case, we run
turbo prune
in our CI after all packages have been built. Therefore, we don't need thedevDependencies
in ourout/
directory.Ideally, our pruned
out/
directory would contain onlyapp
andlib-config
, which are the only packages needed at runtime.Describe the solution you'd like
Having an optional
--production
flag that would ignore thedevDependencies
would be great.Describe alternatives you've considered
I don't think there are any alternatives, except keeping the
devDependencies
, which is frankly not a big deal. It's just less optimal... But, isn't Turborepo all about optimization? 😉The text was updated successfully, but these errors were encountered: