Skip to content

Do I need to import @babel/polyfill? #1963

Closed
@airblade

Description

@airblade

Hello!

I'm using Webpacker 3.5.5. I write ES6 JavaScript code and I want it to work on evergreen browsers and IE11.

In my .babelrc I am targetting browsers which include IE11:

{
  "presets": [
    ["env", {
      "modules": false,
      "targets": {
        "browsers": "> 1% in GB, last 2 Firefox versions",
        "uglify": true
      },
      "useBuiltIns": true
    }]
  ],

  "plugins": [
    "syntax-dynamic-import",
    "transform-object-rest-spread",
    ["transform-class-properties", { "spec": true }]
  ]
}

However on IE11 I get the error: ReferenceError: 'Symbol' is undefined.

On the ES6 wiki page, it says:

We have also included babel polyfill that includes a custom regenerator runtime and core-js.
Don't forget to import @babel/polyfill in your main entry point like so: [...]

However when I switch on webpacker's debug output, it seems to be generating lots of polyfills. Do I need to import "@babel/polyfill" in addition to my browser list setting in .babelrc?

Also, the wiki page mentions:

The Webpacker installer sets up a standard babel.config.js file in your app root...

I don't have babel.config.js. Does that matter?

Many thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions