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

Allow 'production' ENV to take precedence over NODE_ENV #2057

Merged
merged 1 commit into from
Dec 8, 2016

Conversation

joeyespo
Copy link
Contributor

This fixes #1975.

The motivation is to fix the compatibility issue so that Yarn can be used in place of npm on Heroku (related buildpack issue). In this case, when you need to install devDependencies, as documented here.

Test plan

A test is included.

(I also tested locally on my setup and observed that the devDependencies were indeed installed to node_modules when both NODE_ENV=production and NPM_CONFIG_PRODUCTION=false were set.)

@joeyespo joeyespo force-pushed the fix-1975 branch 2 times, most recently from a5295df to e2d8c62 Compare November 28, 2016 22:21
@joeyespo
Copy link
Contributor Author

Huh. The test is passing locally. Digging in to see why it isn't working on CI.

@joeyespo joeyespo force-pushed the fix-1975 branch 9 times, most recently from ce2ba3d to 8d1b78b Compare November 29, 2016 03:28
@joeyespo
Copy link
Contributor Author

I'm not sure why my first approach wasn't working. It worked locally for some reason. (Anyone have any ideas?) But using the same method as #1455 worked.

This is all good to go.

@bestander
Copy link
Member

@joeyespo, do we have a support for --no-production?
Should it override ENV vars?

  • needs a rebase

@joeyespo
Copy link
Contributor Author

joeyespo commented Dec 6, 2016

@bestander Rebased.

One test is failing due to Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. Any ideas?

There's no --no-production to my knowledge, but this does work exactly like npm where you can set NPM_CONFIG_PRODUCTION=false in your config.

@bestander
Copy link
Member

@joeyespo, this is a known problem, we'll sort it out separately

@@ -210,7 +210,10 @@ export default class Config {
await fs.mkdirp(this.cacheFolder);
await fs.mkdirp(this.tempFolder);

if (this.getOption('production') || process.env.NODE_ENV === 'production') {
if (this.getOption('production') || (
Copy link
Member

Choose a reason for hiding this comment

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

There's no --no-production to my knowledge, but this does work exactly like npm where you can set NPM_CONFIG_PRODUCTION=false in your config.

My concern is that if NODE_ENV is set to production overriding it can only be done with another env variable, e.g. YARN_PRODUCTION.
Sometimes people don't have full control over environment variables in the system and overriding with an arg can be a more obvious API.

In npm you can do --production=false and it will override env variables.
Can you do similar thing for Yarn?

Copy link

@adamreisnz adamreisnz Dec 17, 2016

Choose a reason for hiding this comment

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

What if the opposite is true, where people only have control over env variables rather than CLI arguments? E.g. when running on Heroku under the constraints as described in #2283

@joeyespo
Copy link
Contributor Author

joeyespo commented Dec 7, 2016

@bestander

and overriding with an arg can be a more obvious API

I agree with you on the usefulness of that. Yarn currently doesn't support it. (It appears npm does.)

This PR fixes real production compatibility issue though (heroku/heroku-buildpack-nodejs#337). As of #1455, you can already set NODE_ENV to production without any way to override it. Heroku sets this, and documents that the way to override it is with another ENV. This PR fixes that specific case.

The --production=false case is another backwards incompatibility. It's independent of this fix though and may require some upfront discussion, so I think it might be better to address that in a new issue/PR instead of ultimately delaying this one.

@chadly
Copy link

chadly commented Dec 7, 2016

related #2167

@joeyespo
Copy link
Contributor Author

joeyespo commented Dec 7, 2016

@chadly Perfect 👍

@bestander Given that the test timeout is a known thing to be sorted out separately, this should be ready to go. Need anything else from me?

@bestander bestander merged commit c2a84a1 into yarnpkg:master Dec 8, 2016
@bestander
Copy link
Member

Sounds reasonable, @joeyespo, thanks for the contribution!

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.

devDependencies are not installed when both NODE_ENV=production and NPM_CONFIG_PRODUCTION=false are set
4 participants