Skip _extends helper for {…x} with modern targets (#12899)
This commit is contained in:
parent
9a1b59f1f9
commit
962d81483e
@ -17,6 +17,8 @@
|
||||
"babel-plugin"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/compat-data": "workspace:^7.13.6",
|
||||
"@babel/helper-compilation-targets": "workspace:^7.13.0",
|
||||
"@babel/helper-plugin-utils": "workspace:^7.13.0",
|
||||
"@babel/plugin-syntax-object-rest-spread": "^7.8.3",
|
||||
"@babel/plugin-transform-parameters": "workspace:^7.13.0"
|
||||
|
||||
@ -2,6 +2,8 @@ import { declare } from "@babel/helper-plugin-utils";
|
||||
import syntaxObjectRestSpread from "@babel/plugin-syntax-object-rest-spread";
|
||||
import { types as t } from "@babel/core";
|
||||
import { convertFunctionParams } from "@babel/plugin-transform-parameters";
|
||||
import { isRequired } from "@babel/helper-compilation-targets";
|
||||
import compatData from "@babel/compat-data/corejs2-built-ins";
|
||||
|
||||
// TODO: Remove in Babel 8
|
||||
// @babel/types <=7.3.3 counts FOO as referenced in var { x: FOO }.
|
||||
@ -17,7 +19,12 @@ const ZERO_REFS = (() => {
|
||||
export default declare((api, opts) => {
|
||||
api.assertVersion(7);
|
||||
|
||||
const { useBuiltIns = false, loose = false } = opts;
|
||||
const targets = api.targets();
|
||||
const supportsObjectAssign = !isRequired("es6.object.assign", targets, {
|
||||
compatData,
|
||||
});
|
||||
|
||||
const { useBuiltIns = supportsObjectAssign, loose = false } = opts;
|
||||
|
||||
if (typeof loose !== "boolean") {
|
||||
throw new Error(".loose must be a boolean, or undefined");
|
||||
|
||||
@ -0,0 +1 @@
|
||||
let a = { x: 1, ...b };
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"targets": "firefox 70"
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
let a = Object.assign({
|
||||
x: 1
|
||||
}, b);
|
||||
@ -0,0 +1 @@
|
||||
let a = { x: 1, ...b };
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"targets": "firefox 70"
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
let a = Object.assign({
|
||||
x: 1
|
||||
}, b);
|
||||
@ -139,7 +139,7 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@babel/compat-data@workspace:^7.13.0, @babel/compat-data@workspace:^7.13.5, @babel/compat-data@workspace:packages/babel-compat-data":
|
||||
"@babel/compat-data@workspace:^7.13.0, @babel/compat-data@workspace:^7.13.5, @babel/compat-data@workspace:^7.13.6, @babel/compat-data@workspace:packages/babel-compat-data":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@babel/compat-data@workspace:packages/babel-compat-data"
|
||||
dependencies:
|
||||
@ -1287,7 +1287,9 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@babel/plugin-proposal-object-rest-spread@workspace:packages/babel-plugin-proposal-object-rest-spread"
|
||||
dependencies:
|
||||
"@babel/compat-data": "workspace:^7.13.6"
|
||||
"@babel/core": "workspace:*"
|
||||
"@babel/helper-compilation-targets": "workspace:^7.13.0"
|
||||
"@babel/helper-plugin-test-runner": "workspace:*"
|
||||
"@babel/helper-plugin-utils": "workspace:^7.13.0"
|
||||
"@babel/plugin-syntax-object-rest-spread": ^7.8.3
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user