New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

babel/preset-env useBuiltIns: "entry" does not include "es6.string.iterator" for ie11 #8691

Closed
OCJvanDijk opened this Issue Sep 12, 2018 · 2 comments

Comments

Projects
None yet
4 participants
@OCJvanDijk

OCJvanDijk commented Sep 12, 2018

Bug Report

Current Behavior
When using the useBuiltIns: "entry" options while targeting ie11, the "es6.string.iterator" builtin is not included in the generated imports, even though ie11 does not support it.

Input Code

  • REPL or Repo link if applicable:
const babel = require('@babel/core')
const preset = require('@babel/preset-env')

let {code} = babel.transformSync(`
  import '@babel/polyfill'

  for (let c of 'abcdefg') {
    console.log(c)
  }
`.trim(), {
    presets: [[preset, {
        targets: [
            "ie 11"
        ],
        useBuiltIns: "entry",
        // include: ["es6.string.iterator"], // include this and the result will work on ie11
        modules: false,
        debug: true
    }]]
})

console.log(code)

Expected behavior/code
import "core-js/modules/es6.string.iterator"; should appear in the output.

Environment

  • Babel version(s): v7.0.0
  • Node/npm version: Node 8.11.3/npm 5.10
  • OS: OSX 10.13.6
  • How you are using Babel: loader

Additional context/Screenshots
Looking at babel/packages/babel-preset-env/data/built-ins.json, it seems that preset-env assumes a lot of old browsers fully support String.prototype[@@iterator]() even though MDN says otherwise. Also, I personally tried running the generated code in ie11 and get the error:

Object doesn't support property or method 'Symbol(Symbol.iterator)

But when I include the include: ["es6.string.iterator"] option the result runs fine.

@babel-bot

This comment has been minimized.

Show comment
Hide comment
@babel-bot

babel-bot Sep 12, 2018

Collaborator

Hey @OCJvanDijk! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

Collaborator

babel-bot commented Sep 12, 2018

Hey @OCJvanDijk! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

huston007 added a commit to JetBrains/ring-ui that referenced this issue Sep 12, 2018

RG-1873 workaround for destructing string
Destructing doesn't work because of babel/babel#8691
@huston007

This comment has been minimized.

Show comment
Hide comment
@huston007

huston007 Sep 12, 2018

I have the same issue but with this kind of syntax:

const str = 'abc';
const letters = [...str];

Will the PR also cover this case?

huston007 commented Sep 12, 2018

I have the same issue but with this kind of syntax:

const str = 'abc';
const letters = [...str];

Will the PR also cover this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment