Skip to content

[7.0] Deprecate env option in .babelrc #5276

@hzoo

Description

@hzoo

## EDIT: We're just going to deprecate now

Fixing merge behavior instead

Original issue details:

Details http://babeljs.io/docs/usage/babelrc/#env-option

some env issues: #5275, #4539, #4013, #4817

{
  "env": {
    "production": {
      "plugins": ["transform-react-constant-elements"]
    }
  }
}

Options specific to a certain environment are merged into and overwrite non-env specific options.

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".

true that allowing .js may lead to crazy configs but think it's better than confusing with babelrc/env

Because it's JS you could do this in a lot of ways

var env = process.env.BABEL_ENV || process.env.NODE_ENV;
// inline plugin
module.exports = {
  plugins: [
    env === 'development' && "transform-react-constant-elements"
  ].filter(Boolean)
};

https://github.com/facebookincubator/create-react-app/blob/65e63403952f4f3c7e872f707fb3736e339254d9/packages/babel-preset-react-app/index.js#L42-L51

var plugins = [];
if (env === 'development') {
  plugins.push.apply(plugins, ["transform-react-constant-elements"]);
}
module.exports = { plugins };

Metadata

Metadata

Assignees

Labels

Has PRi: discussionoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions