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

Env preset includes more polyfills when using "core-js": 3 instead of "core-js" 2 #10406

Closed
rtsao opened this issue Sep 6, 2019 · 4 comments

Comments

@rtsao
Copy link
Contributor

commented Sep 6, 2019

Bug Report

@babel/preset-env includes many more polyfills when using "core-js": 3 as opposed to "core-js": 2. The bundle size difference is quite dramatic.

Example with core-js@2 (working as expected)

Using "core-js": 2 works as expected.

Entry

import "core-js";

Config

{
  "presets": [
    [
      "@babel/env",
      {
        "modules": false,
        "targets": {"esmodules": true},
        "useBuiltIns": "entry",
        "corejs": 2
      }
    ]
  ]
}

Output

import "core-js/modules/es7.array.flat-map";
import "core-js/modules/es6.array.sort";
import "core-js/modules/es6.number.is-finite";
import "core-js/modules/es6.number.is-nan";
import "core-js/modules/es7.object.define-getter";
import "core-js/modules/es7.object.define-setter";
import "core-js/modules/es7.object.lookup-getter";
import "core-js/modules/es7.object.lookup-setter";
import "core-js/modules/es6.object.is";
import "core-js/modules/es7.promise.finally";
import "core-js/modules/es6.regexp.constructor";
import "core-js/modules/es6.regexp.flags";
import "core-js/modules/es6.regexp.match";
import "core-js/modules/es6.regexp.replace";
import "core-js/modules/es6.regexp.split";
import "core-js/modules/es6.regexp.search";
import "core-js/modules/es6.regexp.to-string";
import "core-js/modules/es6.symbol";
import "core-js/modules/es7.symbol.async-iterator";
import "core-js/modules/es6.string.anchor";
import "core-js/modules/es6.string.big";
import "core-js/modules/es6.string.blink";
import "core-js/modules/es6.string.bold";
import "core-js/modules/es6.string.fixed";
import "core-js/modules/es6.string.fontcolor";
import "core-js/modules/es6.string.fontsize";
import "core-js/modules/es6.string.italics";
import "core-js/modules/es6.string.link";
import "core-js/modules/es6.string.small";
import "core-js/modules/es6.string.strike";
import "core-js/modules/es6.string.sub";
import "core-js/modules/es6.string.sup";
import "core-js/modules/es7.string.trim-left";
import "core-js/modules/es7.string.trim-right";
import "core-js/modules/web.timers";
import "core-js/modules/web.immediate";
import "core-js/modules/web.dom.iterable";

Example with core-js@3 (regression)

Using "core-js": 3 results in extra polyfills (including Promise, typed arrays, etc.)

Entry

import "core-js/stable";

Config

{
  "presets": [
    [
      "@babel/env",
      {
        "modules": false,
        "targets": {"esmodules": true},
        "useBuiltIns": "entry",
        "corejs": 3
      }
    ]
  ]
}

Output

import "core-js/modules/es.symbol.description";
import "core-js/modules/es.symbol.async-iterator";
import "core-js/modules/es.symbol.match";
import "core-js/modules/es.symbol.replace";
import "core-js/modules/es.symbol.search";
import "core-js/modules/es.symbol.split";
import "core-js/modules/es.array.flat";
import "core-js/modules/es.array.flat-map";
import "core-js/modules/es.array.iterator";
import "core-js/modules/es.array.reverse";
import "core-js/modules/es.array.sort";
import "core-js/modules/es.array.unscopables.flat";
import "core-js/modules/es.array.unscopables.flat-map";
import "core-js/modules/es.array-buffer.constructor";
import "core-js/modules/es.array-buffer.slice";
import "core-js/modules/es.number.parse-float";
import "core-js/modules/es.number.to-fixed";
import "core-js/modules/es.object.define-getter";
import "core-js/modules/es.object.define-setter";
import "core-js/modules/es.object.from-entries";
import "core-js/modules/es.object.lookup-getter";
import "core-js/modules/es.object.lookup-setter";
import "core-js/modules/es.promise";
import "core-js/modules/es.promise.finally";
import "core-js/modules/es.regexp.constructor";
import "core-js/modules/es.regexp.flags";
import "core-js/modules/es.regexp.to-string";
import "core-js/modules/es.string.ends-with";
import "core-js/modules/es.string.includes";
import "core-js/modules/es.string.match";
import "core-js/modules/es.string.pad-end";
import "core-js/modules/es.string.pad-start";
import "core-js/modules/es.string.replace";
import "core-js/modules/es.string.search";
import "core-js/modules/es.string.split";
import "core-js/modules/es.string.starts-with";
import "core-js/modules/es.string.trim";
import "core-js/modules/es.string.trim-end";
import "core-js/modules/es.string.trim-start";
import "core-js/modules/es.typed-array.float32-array";
import "core-js/modules/es.typed-array.float64-array";
import "core-js/modules/es.typed-array.int8-array";
import "core-js/modules/es.typed-array.int16-array";
import "core-js/modules/es.typed-array.int32-array";
import "core-js/modules/es.typed-array.uint8-array";
import "core-js/modules/es.typed-array.uint8-clamped-array";
import "core-js/modules/es.typed-array.uint16-array";
import "core-js/modules/es.typed-array.uint32-array";
import "core-js/modules/es.typed-array.from";
import "core-js/modules/es.typed-array.of";
import "core-js/modules/es.typed-array.to-locale-string";
import "core-js/modules/web.dom-collections.iterator";
import "core-js/modules/web.immediate";
import "core-js/modules/web.queue-microtask";
import "core-js/modules/web.url";
import "core-js/modules/web.url.to-json";
import "core-js/modules/web.url-search-params";

Environment

  • Babel version(s): 7.6.0 (@babel/preset-env@7.6.0, @babel/core@7.6.0)
  • Node/npm version: Node 10
  • OS: Mac OS X
  • Monorepo: no
  • How you are using Babel: @babel/cli
@babel-bot

This comment has been minimized.

Copy link
Collaborator

commented Sep 6, 2019

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

@zloirock

This comment has been minimized.

Copy link
Member

commented Sep 7, 2019

Because it's more correct? -)

@rtsao

This comment has been minimized.

Copy link
Contributor Author

commented Sep 9, 2019

Because it's more correct? -)

I see, so the corejs: 2 option should be updated to include the same polyfills as corejs: 3?

@zloirock

This comment has been minimized.

Copy link
Member

commented Sep 10, 2019

They have different data sources and it's too complex and costly to update it for obsolete core-js version.

@rtsao rtsao closed this Sep 13, 2019

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