Skip to content

@babel/preset-env not always polyfilling Promise #9250

@robinloeffel

Description

@robinloeffel

Bug Report

Current Behavior
When working with async/await and setting IE11 as a target, it does not always include es6.promise.

Input Code

async getLocale() {
    const req = await fetch(this.sources[this.language]);
    const res = await req.json();

    this.locales[this.language] = res;
}
[/Users/robin/Sites/mehrsprachig/src/mehrsprachig.js] Added following polyfills:
  regenerator-runtime { "android":"4.4.3", "chrome":"69", "edge":"17", "firefox":"62", "ie":"11", "ios":"11.3", "opera":"56", "safari":"11.1" }
  web.dom.iterable { "android":"4.4.3", "chrome":"69", "edge":"17", "firefox":"62", "ie":"11", "ios":"11.3", "opera":"56", "safari":"11.1" }
  es6.array.iterator { "android":"4.4.3", "ie":"11" }
  es6.symbol { "android":"4.4.3", "edge":"17", "ie":"11" }
  es7.symbol.async-iterator { "android":"4.4.3", "edge":"17", "ie":"11", "ios":"11.3", "safari":"11.1" }
  es6.regexp.split { "android":"4.4.3", "edge":"17", "ie":"11" }
  es6.regexp.replace { "android":"4.4.3", "edge":"17", "ie":"11" }
  es6.string.includes { "android":"4.4.3", "ie":"11" }
  es7.array.includes { "android":"4.4.3", "ie":"11" }

Expected behavior/code
I expect a polyfill for IE11 for Promises to be included.

Babel Configuration (babel.config.js)

module.exports = {
    sourceMaps: true,
    presets: [
        ['@babel/preset-env', {
            targets: {
                ie: 11,
                browsers: 'last 2 versions'
            },
            useBuiltIns: 'usage',
            debug: true
        }]
    ],
    ignore: [ 'node_modules' ]
};

Environment

  • Babel version(s): 7.2.2
  • Node/npm version: 10.14.2/6.4.1
  • OS: macOS 10.14.2
  • Monorepo: no
  • How you are using Babel: rollup-plugin-babel

Additional context/Screenshots
I can fix the issue for now by importing whatwg-fetch and promise-polyfill/src/polyfill manually. However, this is not really elegant, as I'm working with a polyfilling package, anyway, and this always includes these polyfills, even when not transforming anything with babel.

Another thing to mention: fetch does not get polyfilled, either. I've read somewhere that you guys think about including it in the future—is this true? If yes, is there any planned eta?

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: preset-env

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions