support env in babelrc #8963
Merged
support env in babelrc #8963
Conversation
@hexsprite: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/ |
@@ -300,6 +300,16 @@ BCp._inferHelper = function ( | |||
merge(babelOptions, babelrc, "presets"); | |||
merge(babelOptions, babelrc, "plugins"); | |||
|
|||
const babelEnv = (process.env.BABEL_ENV || | |||
process.env_NODE_ENV || |
benjamn
Aug 2, 2017
Member
Should this be process.env.NODE_ENV
?
Should this be process.env.NODE_ENV
?
hexsprite
Aug 2, 2017
Author
Contributor
I believe so. From the babel docs:
The env key will be taken from process.env.BABEL_ENV, when this is not available then it uses process.env.NODE_ENV if even that is not available then it defaults to "development".
I believe so. From the babel docs:
The env key will be taken from process.env.BABEL_ENV, when this is not available then it uses process.env.NODE_ENV if even that is not available then it defaults to "development".
hexsprite
Aug 2, 2017
Author
Contributor
Oh, woops. Got it.
Oh, woops. Got it.
I would recommend adding |
benjamn
added a commit
that referenced
this pull request
Aug 7, 2017
The modules test app appears to be running with process.env.NODE_ENV equal to "production" on Circle CI: https://circleci.com/gh/meteor/meteor/5030. Enabling this transform in production as well as development is fine because we primarily want to test that plugins from the "env" section of .babelrc are respected, regardless of the value of process.env.NODE_ENV. Using different plugins in production might be worth testing, too, but that's less critical. Follow-up to #8963.
benjamn
added a commit
that referenced
this pull request
Sep 26, 2017
When the ecmascript package version was last bumped in 18e4c17, it appears that babel-compiler@6.20.0 had not yet been published, so ecmascript was published with a copy of that compiler plugin that did not support the "env" property of .babelrc files (#8963). Bumping again and republishing in hopes of fixing that problem.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
This PR implements support for the env key in
.babelrc
files.It looks first for
BABEL_ENV
thenNODE_ENV
then finally defaults todevelopment
per the Babel documented behavior.Rationale: be able to add additional babel plugins/presets for testing environment for example (eg.
babel-plugin-istanbul
)I wasn't sure where to add tests as I did not see any existing tests for the functionality. Please let me know your feedback.