Skip to content
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

Very long linking when doing 'yarn --production' (or how to get production clean yarn.lock quickly) #5986

Open
wclr opened this issue Jun 13, 2018 · 6 comments
Assignees
Labels

Comments

@wclr
Copy link
Contributor

wclr commented Jun 13, 2018

I'm using the following deploy strategy while building nodejs apps docker images:

  • My app's manifest has dependencies and some devDependencies.
  • I copy both package.json and yalc.lock files into new directorory.
  • Run yarn --production (after this yarn.lock is change to reflect only production deps, and node_modules have only production deps)
  • Then again I copy yalc.lock from dev project.
  • Run yarn --production
  • Linking dependencies.. takes very long.

I wonder if it is possible to make such scenario of more efficient? (This scenario is a part of preparing production files for docker image).

@ghost ghost assigned rally25rs Jun 13, 2018
@ghost ghost added the triaged label Jun 13, 2018
@wclr
Copy link
Contributor Author

wclr commented Jun 14, 2018

Well actually I could call this issue How to purge yalc.lock from dev devependencies quickly. Before placing package.json into docker container I purge it just removing devDependencies - I would like to have yarn.lock too production clean, so that if those files not changed on rebuild docker will take cached layer with installed deps. And If we leave yarn.lock as in dev version this strategy is influenced by dev stuff in it, which is not needed in production.

So executing yarn --production (or just yarn with the purged package.json) before placing files to container - is a way to get yarn.lock production clean. But it takes long as described in OP.

Probably yarn could do something like this without touching FS, just analyzing graph and removing dev related stuff, leaving production.

@wclr wclr changed the title Very long linking when doing 'yarn --production' with actual node_modules Very long linking when doing 'yarn --production' (or how to get production clean yarn.lock quickly) Jun 14, 2018
@wclr
Copy link
Contributor Author

wclr commented Jun 19, 2018

@bestander
Interesting to hear comment on this: is it possible to purge dev dependencies related stuff from yalc.lock without touching fs, quickly, in principle?

@wclr
Copy link
Contributor Author

wclr commented Jun 27, 2018

Any comment on this?

@bestander
Copy link
Member

Sorry, @whitecolor, I was deeply involved in another project.

@bestander
Copy link
Member

bestander commented Jul 16, 2018

Interesting to hear comment on this: is it possible to purge dev dependencies related stuff from yalc.lock without touching fs, quickly, in principle?

I think it is possible.
yarn.lock holds the dependency tree and root package.json lisholdss top level dependencies.
If we assume that yarn.lock is consistent with package.json then we can pass through yarn.lock and remove all top level dev dependencies' entries and then all orphaned entries.

@bestander
Copy link
Member

It's strange though that linking of yarn install --production takes longer with dev dependencies in yarn.lock file.
As I remember there may be still fetching done for --production installs but linking should only be done for the dependencies that are being installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants