Skip to content
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

iterableToArray transitive usages not polyfilled #10625

Open
RobHannay opened this issue Nov 1, 2019 · 3 comments

Comments

@RobHannay
Copy link

@RobHannay RobHannay commented Nov 1, 2019

Bug Report

Current Behavior
When spreading a new Set with core-js 'usage', transitive dependencies are not polyfilled which breaks IE11.

We saw this live when it was not polyfilling 'Array.from', but on this repro it fails earlier because Symbol is also not polyfilled.

If Symbol is added manually it then fails saying it's not an iterable instance, but works fine on Chrome/FF.

Also if you use Array.from(new Set([])); it works fine.

Input Code
Access the Webpack dev server on Internet Explorer and see console errors.
https://babel-corejs-reproduce-set-spread.robhannay.repl.co

Code
https://repl.it/@robhannay/babel-corejs-reproduce-set-spread

Expected behavior/code
Expected the Symbol (or Array.from) 'usage' to be detected from within the iterableToArray method and itself be polyfilled

Babel Configuration (.babelrc, package.json, cli command)

{
  presets: [
    ['@babel/preset-env', {
      modules: false, // Module transpilation is handled by Webpack
      corejs: 3,
      useBuiltIns: 'usage',
    }],
    '@babel/preset-react',
  ],
  plugins: [
    '@babel/plugin-transform-strict-mode',
    '@babel/plugin-proposal-object-rest-spread',
    '@babel/plugin-transform-object-assign',
    '@babel/plugin-syntax-dynamic-import',
    '@babel/plugin-transform-modules-commonjs',
    '@babel/plugin-transform-runtime',
    '@babel/plugin-proposal-class-properties',
  ],
}

Environment

  • Babel version(s): v7.6.4
  • Node/npm version: Node 12 / npm 6 (the repl.it runs on Node 10 but can see the same issue)
  • OS: OSX local / Linux build producted same result
  • Monorepo: no
  • How you are using Babel: loader

Additional context/Screenshots

Screenshot 2019-11-01 at 12 34 12

@babel-bot

This comment has been minimized.

Copy link
Collaborator

@babel-bot babel-bot commented Nov 1, 2019

Hey @RobHannay! 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."

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Nov 1, 2019

If you aren't passing a file to Babel (you are excluding it in your webpack config with exclude: /node_modules/), Babel can't transform that code.

I usually suggest transforming the specific node_module with Babel, but since @babel/runtime is a Babel module itself it's really risky.

I suggest aliasing @babel/runtime to @babel/runtime-corejs3 in your webpack config.

@zloirock

This comment has been minimized.

Copy link
Member

@zloirock zloirock commented Nov 1, 2019

I suggest aliasing @babel/runtime to @babel/runtime-corejs3 in your webpack config.

For load both dependencies - core-js and core-js-pure? -) For proper work, in this case, required a version of runtime, compiled with injecting global core-js version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.