-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Feature] "yarn workspaces focus" option --immutable
#1803
Comments
I don't understand this critical part. The focus command will remove the direct dependencies from the other workspaces. It won't downgrade or upgrade anything, so I don't see why you wouldn't be able to guarantee that. |
The
That's the same function used for any other install, so my assumption was that it could retrieve a newer version from the registry, (as long as it matches the relevant semver range). But maybe I am misunderstanding the install behavior. Is it correct to say that |
If a dependency is locked inside the lockfile and |
Great. Thanks for the explanation! |
But I have tried that focus changed package version. |
Any chance we can reopen this? There is still a need for an |
Your whole project must be checked for the immutability check to have any value. One this check is done (typically on CI, at PR time), the flag isn't necessary anymore (and thus has no value in production settings, ie what |
I think the problem here is that people want to install just a part of the whole workspace and still make sure that the packages are still the same that they have tested before. This is useful for example when building a docker container for deployment. Having one big workspace is helpful for development, but during deployment we don't want to drag all workspace folders along just to make sure that nothing changed in one workspace folder. #1223 seems to go into the same direction. |
Chiming in that we've also hit this issue as a blocker for us to migrate to Yarn 3. Being able to install only production dependencies in a docker image is important both for build speed, image size, and security, and that of course needs to be done as an immutable install. Tried working around it by adding I think perhaps it could be worth revisiting the decision to remove |
Chiming in here also requesting support for passing immutable to focus! In our case we don't want to install and build all packages for our react-native app when running our CI pipeline for our web deployments. |
I don't quite understand your use case. Do you also run your linting on build, and only on the workspaces you deploy? Because that's essentially what |
Doesn’t immutable stop the process if the lock file changes? Maybe I misunderstood, but that’s what i’m trying to achieve. |
Yes, and what I'm saying is that you should use it as a validation step before you even reach the deployment step. If you validate that the lockfile doesn't change at a PR CI level, there's no reason why it would change during deployment. |
Is the only way to “validate at a PR” level to use something like husky or is there a different yarn command that i’m not aware of that validates without installing? The latter would be ideal actually |
I would guess you run some CI on your PRs, to check they pass the linting / type check / tests? That's where Note however that Yarn automatically enable |
right but all of those things happen after the Unfortunately my current setup doesn't allow for zer-installs so we have to run the install step before linting & testing |
@arcanis in that case, would you consider adding a way to quickly validate the lockfile is in sync without installing all dependencies? Otherwise I would need to add the following checks in CI:
It seems like a lot of wasted work in 1) to install all dependencies just to verify a lockfile. |
Yes, I'm facing the same issue and by reading this issue I suspect we are far from finding a plausible solution. We have monorepo using workspaces with BackendApp (NestJS), FrontendApp (NextJS), and a SharedLib. Our end goal is to build slim independent docker images for both backend and frontend with only production dependencies without introducing a dependency version we didn't test locally At the moment trying to achieve that with a multi-stage Dockerfile looks like the following
That last step, although is not bringing FrontendApp dependencies, is terrible as it is bringing devDependencies 🤢 Ideally the
|
Stumble across this issue as well. |
workspace-tools
plugin in this repo.Describe the user story
Enable using
yarn workspaces focus
while also guaranteeing that all direct and indirect dependencies are the exact versions specified in theyarn.lock
file.Consider a monorepo, using yarn workspaces, with two applications that will be deployed independently and a shared library that both apps depend on. The deployed version of App A must:
For [reasons], I use the node-modules linker, not PnP, and do not commit dependencies in the repo.
I can achieve all of that on my CI server with a script that looks like this:
However, as noted in the comment, there is no way with
focus
for me to guarantee that yarn won't retrieve a different version of some dependency from the registry.Describe the solution you'd like
Add an
--immutable
option toyarn workspaces focus
that does the same thing as the--immutable
option onyarn install
-- guarantees that only the exact versions inyarn.lock
are installed. Example:Describe the drawbacks of your solution
Increased API surface area and additional logic to test/maintain in the future.
Describe alternatives you've considered
Modify the
--production
option to behave likeinstall --immutable
. The primary use case for--production
is to eliminate devDependencies when deploying an application. I would expect most people using--production
to also want the dependency versions to be guaranteed. But there may be other use cases, and making--immutable
explicit keeps thefocus
API closer toinstall
.Additional context
I initially raised this in the comments for #1789, since that issue is also related to using
focus
when deploying an app. My comment there mentioned that am doing the build inside a docker container. However, I don't think that's really relevant. The same concern about dependency versions applies whether using docker or not.A related nice-to-have would be to tell
focus
to behave like yarn v1'syarn --frozen-lockfile --production --offline
. That is: "Don't bother checking the registry, use what you already have in cache."The text was updated successfully, but these errors were encountered: