Enable useBuiltIns option when compiling for modern JS environments.

Background:
https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-runtime#usebuiltins
242538dea1
855d5dda80
This commit is contained in:
Ben Newman
2017-12-05 13:34:50 -05:00
parent a67c0c7ac9
commit 18ab7e9b39

View File

@@ -71,13 +71,26 @@ BCp.processOneFileForTarget = function (inputFile, source) {
! excludedFileExtensionPattern.test(inputFilePath)) {
var extraFeatures = Object.assign({}, this.extraFeatures);
var arch = inputFile.getArch();
if (inputFile.getArch().startsWith("os.")) {
if (arch.startsWith("os.")) {
// Start with a much simpler set of Babel presets and plugins if
// we're compiling for Node 8.
extraFeatures.nodeMajorVersion = parseInt(process.versions.node);
}
if (arch !== "web.browser.legacy") {
extraFeatures.runtime = {
// Import Babel helpers from @babel/runtime/helpers/builtin/*
// instead of @babel/runtime/helpers/* to prevent those helper
// modules from importing anything from core-js. The polyfills and
// shims provided by core-js are not needed in modern JS
// environments (browsers and Node), and will be polyfilled by the
// ecmascript-runtime-{client,server} packages anyway.
useBuiltIns: true
};
}
if (! extraFeatures.hasOwnProperty("jscript")) {
// Perform some additional transformations to improve compatibility
// in older browsers (e.g. wrapping named function expressions, per