Skip to content

Modern build gets unneeded polyfills detected by Babel #1727

Closed
@cristianl

Description

@cristianl

Version

3.0.0-rc.3

Reproduction link

https://github.com/cristianl/repro-vue-cli-usebuiltins

Steps to reproduce

In the repro directory, run node_modules/.bin/vue-cli-service build --modern.

The reproduction repo is a vue-cli generated project with the default settings, and only this function definition added to main.js, so Babel detects usage of Promise:

function fakePromise() {
  return Promise.all()
}

What is expected?

The vendors bundle generated for modern mode should not get polyfills of ES2015 features already supported by the browsers it targets.

What is actually happening?

Babel is automatically applying polyfills even for the modern build (in this case, polyfills for Promise, detected in main.js).


It's fixed by setting useBuiltIns: false when process.env.VUE_CLI_MODERN_BUILD is true.

It may also be a bug in babel-preset-env (when the target is esmodules, should it apply ES2015 polyfills?)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions