Skip to content

Commit

Permalink
Skip _extends helper for {鈥} with modern targets (#12899)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Feb 25, 2021
1 parent 9a1b59f commit 962d814
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 2 deletions.
Expand Up @@ -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"
Expand Down
Expand Up @@ -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 }.
Expand All @@ -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");
Expand Down
@@ -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);
4 changes: 3 additions & 1 deletion yarn.lock
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 962d814

Please sign in to comment.