Skip to content

Commit

Permalink
Update for Babel 8
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Jun 9, 2021
1 parent f604e84 commit 443bc8d
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 3 deletions.
6 changes: 5 additions & 1 deletion packages/babel-plugin-transform-spread/src/index.js
Expand Up @@ -50,7 +50,11 @@ export default declare((api, options) => {

if (t.isArrayExpression(spreadLiteral) && hasHole(spreadLiteral)) {
spreadLiteral = t.callExpression(
file.addHelper("arrayWithoutHoles"),
file.addHelper(
process.env.BABEL_8_BREAKING
? "arrayWithoutHoles"
: "arrayLikeToArray",
),
[spreadLiteral],
);
}
Expand Down
@@ -0,0 +1,2 @@
let arr = ['a', ...['b',,'c']];
expect(2 in arr).toBe(true);
@@ -0,0 +1,2 @@
var a = [...['a',, 'b']];
var b = ['a', ...['b',, 'c']];
@@ -0,0 +1,3 @@
{
"BABEL_8_BREAKING": false
}
@@ -0,0 +1,2 @@
var a = babelHelpers.arrayWithoutHoles(['a',, 'b']);
var b = ['a'].concat(babelHelpers.arrayWithoutHoles(['b',, 'c']));
@@ -0,0 +1,3 @@
{
"BABEL_8_BREAKING": true
}
@@ -1,2 +1,2 @@
var a = babelHelpers.arrayWithoutHoles(['a',, 'b']);
var b = ['a'].concat(babelHelpers.arrayWithoutHoles(['b',, 'c']));
var a = babelHelpers.arrayLikeToArray(['a',, 'b']);
var b = ['a'].concat(babelHelpers.arrayLikeToArray(['b',, 'c']));

0 comments on commit 443bc8d

Please sign in to comment.