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

@babel/preset-env conflicts with @babel/plugin-transform-runtime when using core-js@3 #10271

Open
awthwathje opened this issue Jul 26, 2019 · 2 comments

Comments

@awthwathje
Copy link

commented Jul 26, 2019

Bug Report

Current Behavior
@babel/preset-env can't be used alongside @babel/plugin-transform-runtime for polyfilling. Or maybe it can, but no idea how.

Expected behavior/code
@babel/preset-env and @babel/plugin-transform-runtime work nicely together. Or the opposite should be documented.

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

{
  "plugins": [
    "babel-plugin-styled-components",
    "@babel/plugin-transform-flow-strip-types",
    "inline-react-svg",
    "babel-plugin-react-require",
    "@babel/plugin-syntax-dynamic-import",
    "./node_modules/next/dist/build/babel/plugins/react-loadable-plugin",
    "@babel/plugin-proposal-class-properties",
    [
      "@babel/plugin-proposal-object-rest-spread",
      {
        "useBuiltIns": true
      }
    ],
    [
      "@babel/plugin-transform-runtime",
      {
        "corejs": false
      }
    ]
  ],
  "presets": [
    [
      "@babel/preset-env",
      {
        "debug": true,
        "modules": false,
        "exclude": [
          "transform-typeof-symbol"
        ],
        "useBuiltIns": "usage",
        "corejs": "3.1"
      }
    ],
    "@babel/preset-react"
  ]
}

.browserslistrc

node 10.16
last 4 chrome versions
last 4 firefox versions
last 4 edge versions
last 2 safari versions
ie 11
not dead

Environment

  • Babel version(s): 7.1.0
  • Node/npm version: 10.16
  • OS: Debian 10
  • Monorepo: no
  • How you are using Babel: loader

Possible Solution
Make it clear how @babel/plugin-transform-runtime and @babel/preset-env interfere with each other when using core-js@3.

Additional context/Screenshots
Hello. This is a follow-up of a zeit/next.js#8104 issue suggested by @Timer.

I've struggled to make my Next.js project to work nicely in IE 11. I wanted to use @babel/preset-env and core-js@3 for polyfilling the missing ES features, but seems like @babel/plugin-transform-runtime also does perform some polyfilling/transformation, even when provided with corejs: false option.

One problematic feature is es.object.assign. If @babel/plugin-transform-runtime is enabled,
@babel/preset-env will never try to polyfill it, even if it's directly imported from core-js in the code.

Can you please explain if both @babel/preset-env and @babel/plugin-transform-runtime could/should be used together? The documentation is scarce and it's all very confusing at this moment.

@babel-bot

This comment has been minimized.

Copy link
Collaborator

commented Jul 26, 2019

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

@awthwathje

This comment has been minimized.

Copy link
Author

commented Aug 16, 2019

I'm pretty sure clarification of this shouldn't take much time, but will help community tremendously. @JLHwung, @nicolo-ribaudo, can you guys maybe check this quickly and respond please?

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