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

Ignore unused patterns to avoid dev dependencies download when installing with --production flag (#3312) #3546

Closed
wants to merge 2 commits into from

Conversation

pichouk
Copy link
Contributor

@pichouk pichouk commented May 31, 2017

Summary
As described on #3312, yarn do not consider the --production flag when installing packages (with yarn install --production) and try to download dev dependencies too. It can be really annoying since, sometimes, production environment does not have access to private packages used in development.
I try to set a boolean to true which, I guess, will disable this behavior and only download real dependencies.

Test plan
I build my modified version of yarn and test some install to verify it have the correct behavior.

On an empty folder with the following package.json (notice the not existing package in devDependencies) :

{
  "name": "testproject",
  "version": "0.5.6",
  "license": "UNLICENSED",
  "description": "Fake project to test yarn install --production",
  "dependencies": {
    "lodash": "^4.17.4"
  },
  "devDependencies": {
    "notExistingProjeCt": "^1.17.65"
  }
}

Install with version 0.24.5 :

kyane@kyane-pc:/tmp/test-yarn$ yarn --version
0.24.5
kyane@kyane-pc:/tmp/test-yarn$ yarn install --production
yarn install v0.24.5
[1/4] Resolving packages...
error Couldn't find package "notExistingProjeCt" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Install with my modified version :

kyane@kyane-pc:/tmp/test-yarn$ ~/code/yarn/dist/bin/yarn --version
0.26.0-0
kyane@kyane-pc:/tmp/test-yarn$ ~/code/yarn/dist/bin/yarn install --production
yarn install v0.26.0-0
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 0.42s.

Can see that yarn does not try to resolve dev dependencies anymore :)

@pichouk
Copy link
Contributor Author

pichouk commented May 31, 2017

Ok CI tests failed, seems more complicated that I was thinking...

@bestander
Copy link
Member

Yeah, it is more complex.
We still need to resolve all dev dependencies but we need to not fetch them in package-fetcher.

Copy link
Member

@bestander bestander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As commented

@bestander
Copy link
Member

Thanks for giving it a try, @pichouk!
Much appreciated.

@pichouk
Copy link
Contributor Author

pichouk commented Jun 1, 2017

@bestander I searched a little tonight and I cannot found how to solve this.
It seem that the markIgnored function in src/cli/commands/install.js need to resolve package to mark it as ignored. And the resolving step raise an error when the dependency is not accessible (eg. a private dev dependency). I don't know how to do it, I'll see later but maybe it is too difficult for a "Yarn newbie" :p

@pichouk
Copy link
Contributor Author

pichouk commented Jun 9, 2017

Closing since I have not real solution for this issue.
I guess Yarn assume that all dependencies (even dev dependencies) should be resolved even when using --production flag. I think it is really annoying since you cannot install a project using only public dependencies on production if there is some private dev dependencies...

@pichouk pichouk closed this Jun 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants