question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

env presets in .babelrc seem to be ignored starting 6.3.1

See original GitHub issue

I’m submitting a bug report

Webpack Version: 1.14.0

Babel Core Version: 6.23.1

Babel Loader Version: 6.3.1

Please tell us about your environment: macOS Sierra 10.12.2

Current behavior: Even when I include the “react” as a presets, with .babelrc like

{
  "env": {
    "development": {
      "presets": ["es2015", "react"],
...

it doesn’t seem to be used, got errors like Module build failed: SyntaxError: Unexpected token (33:2) complaining about the JSX syntax.

I noticed this is a new behavior in version 6.3.1. With everything else being the same, if one simply npm install babel-loader 6.3.0, the error will be gone.

Also note that the non-environment specific settings are fine, for example, .babelrc like this works:

{
  "presets": ["es2015", "react"],
  "env": {
    "development": {      
...

Expected/desired behavior: The presets specified in the “env” section in .babelrc are used.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
danezcommented, Feb 16, 2017

I released 6.3.2 with the fix, I’m still not entirely sure why this happened.

1reaction
wkillerudcommented, Feb 16, 2017

Noticed this as well, where plugins defined in “env” would not have their settings applied, which broke our test setup.

Webpack version: 2.2.1

Babel core version: 6.23.0

Babel loader version: 6.3.1

Please tell us about your environment: Ubuntu 16.04.1 LTS 64-bit

Current behavior: A .babelrc file with different options for different NODE_ENV, for instance

{
  "presets": [
    "latest"
    "react"
  ],
  "env": {
    "coverage": {
      "plugins": [
        "rewire",
        ["istanbul", {
          "exclude": [
            "src/test"
          ]
        }],
        ["root-import", [{
          "rootPathSuffix": "src/main"
        }, {
          "rootPathPrefix": "@",
          "rootPathSuffix": "src/test"
        }]]
      ]
    },
    "test": {
      "plugins": [
        "rewire",
        ["root-import", [{
          "rootPathSuffix": "src/main"
        }, {
          "rootPathPrefix": "@",
          "rootPathSuffix": "src/test"
        }]]
      ]
    }
  }
}

Options for NODE_ENV=coverage and NODE_ENV=test are not applied, leading to errors when root-import and rewire plugins are not applied.

Expected/desired behavior: The presets specified in the “env” section in .babelrc are used.

Workaround: Use babel-loader 6.3.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

babel/preset-env
babel /preset-env` is a smart preset that allows you to use the latest JavaScript ... (ignoring browsers without security updates like IE 10...
Read more >
@babel/preset-env | Yarn - Package Manager
A Babel preset for each environment. readme. babel. The compiler for writing next generation JavaScript. Gitpod ready-to-code.
Read more >
testing - How do you configure babel to run with different ...
If you don't set BABEL_ENV , babel will use the NODE_ENV value. If you don't set either BABEL_ENV nor NODE_ENV , it will...
Read more >
@babel/preset-react: Versions | Openbase
babel -generator , babel-parser , babel-preset-env , babel-template ... #12678 fix: start TypePredicate node after returnToken (@JLHwung) ...
Read more >
Babel-loader NPM
npm install babel-loader babel-core babel-preset-env webpack. Documentation: Using loaders. Within your webpack configuration object, you'll need to add the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found