Parcel: Is babelrc being ignored?

Created on 8 Jan 2018  路  6Comments  路  Source: parcel-bundler/parcel

Choose one: is this a 馃悰 bug report or 馃檵 feature request?

This is possibly a bug.

馃帥 Configuration (.babelrc, package.json, cli command)

.babelrc

{
  "presets": ["env"]
}

.browserslistrc

last 1 Firefox versions

馃 Expected Behavior

regeneratorRuntime shouldn't be used since I'm targeting only the most recent Firefox version, which natively supports async/await.

馃槸 Current Behavior

ReferenceError: regeneratorRuntime is not defined

馃敠 Context

Using babel-polyfill works, but since I'm creating a Firefox extension targeting the most recent version of Firefox, I don't want to transform async/await.

Most helpful comment

I encountered a similar problem. It looks like that Parcel (or Babel?) ignores .browserslistrc
It should work when you add the query directly into .babelrc

{
    "presets": [
      [ "env", {
        "targets": {
          "browsers": "last 1 Firefox versions"
        }
      }]
    ]
  }

But why do you use Babel at all when you target a modern browser?

All 6 comments

Here is a link to my Firefox extension this happened with. I've removed async/await rather than use the polyfill, but I haven't changed babelrc or browserslistrc from what it was when the issue happened.

https://github.com/lucaseverett/Firefox-Toolbar-Dial

Am I doing something incorrect in my setup? Am I wrong that async/await shouldn't be transformed into regeneratorRuntime when targeting "last 1 Firefox versions"?

I encountered a similar problem. It looks like that Parcel (or Babel?) ignores .browserslistrc
It should work when you add the query directly into .babelrc

{
    "presets": [
      [ "env", {
        "targets": {
          "browsers": "last 1 Firefox versions"
        }
      }]
    ]
  }

But why do you use Babel at all when you target a modern browser?

Mystery solved. It's not implemented in the current version of babel-preset-env (1.6.1).
Support for browserslist comes with version 2
https://github.com/babel/babel-preset-env/pull/161

I also tried adding it directly in babelrc and that didn't make a difference, in my case.

I'm using Parcel for bundling. I don't know of any way to disable Babel and still be able to do that. I tried removing all references to Babel -- including deleting the babelrc file and removing preset-env from package.json -- but that didn't make a difference for my issue.

To disable Babel you remove the .babelrc file

Do you use the --no-cache option when you build the project?
parcel build --no-cache ....

With the cache Parcel does not pick up configuration changes when the code did not change.

Perfect, --no-cache solves the issue. Also, I tried using the babelrc you provided and that worked as well. So, I must have had a typo when I tried it earlier.

Thanks for your help! This issue is now resolved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

termhn picture termhn  路  3Comments

algebraic-brain picture algebraic-brain  路  3Comments

jzimmek picture jzimmek  路  3Comments

will-stone picture will-stone  路  3Comments

Niggler picture Niggler  路  3Comments