Issue 1:
💻

Would you like to work on a fix?

How are you using Babel?

@babel/cli

Input code

I'm using the Babel CLI on the .js file generated by https://github.com/vuejs/devtools/blob/main/packages/shell-electron/src/backend.js once Webpack have been run. The resulting source file contains this :

async notifyComponentUpdate(instance = null) {
if (!this.enabled || !this.hasPermission(shared_utils_1.PluginPermission.COMPONENTS)) return;

if (instance) {
this.ctx.hook.emit(shared_utils_1.HookEvents.COMPONENT_UPDATED, ...(await this.backendApi.transformCall(shared_utils_1.HookEvents.COMPONENT_UPDATED, instance)));
} else {
this.ctx.hook.emit(shared_utils_1.HookEvents.COMPONENT_UPDATED);
}
}

Which crashes Babel with the following error :

Error: D:\git\devtools\packages\shell-electron\build\backend.js: Expected type "Expression" with option undefined, but instead got "SpreadElement".
at assert (D:\git\devtools\node_modules\@babel\types\lib\asserts\generated\index.js:311:11)
at Object.assertExpression (D:\git\devtools\node_modules\@babel\types\lib\asserts\generated\index.js:1308:3)
at Emitter.Ep.explodeExpression (D:\git\devtools\node_modules\regenerator-transform\lib\emit.js:700:7)
at explodeViaTempVar (D:\git\devtools\node_modules\regenerator-transform\lib\emit.js:743:23)
at D:\git\devtools\node_modules\regenerator-transform\lib\emit.js:815:18
at Array.map (<anonymous>)
at Emitter.Ep.explodeExpression (D:\git\devtools\node_modules\regenerator-transform\lib\emit.js:814:28)
at Emitter.Ep.explodeStatement (D:\git\devtools\node_modules\regenerator-transform\lib\emit.js:340:12)
at D:\git\devtools\node_modules\regenerator-transform\lib\emit.js:323:12
at Array.forEach (<anonymous>) {
code: 'BABEL_TRANSFORM_ERROR'
}

When I modify emit.js to log the expr variable, I have :

Node {
type: 'SpreadElement',
start: 12927,
end: 13022,
loc: SourceLocation {
start: Position { line: 526, column: 70, index: 12927 },
end: Position { line: 526, column: 165, index: 13022 },
filename: undefined,
identifierName: undefined
},
argument: {
type: 'YieldExpression',
argument: Node {
type: 'CallExpression',
start: 12937,
end: 13021,
loc: [SourceLocation],
callee: [Node],
arguments: [Array],
leadingComments: undefined,
innerComments: undefined,
trailingComments: undefined
},
delegate: false,
trailingComments: [],
leadingComments: [],
innerComments: []
},
leadingComments: undefined,
innerComments: undefined,
trailingComments: undefined
}

Configuration file name

No response

Configuration

The commang I run is simply :

npx babel ./shell-electron/build/backend.js -o ./shell-electron/build/backend-babel.js --presets=@babel/preset-env

Current and expected behavior

Babel CLI crashes and don't output the new file. But when I change the js to :

async notifyComponentUpdate(instance = null) {
if (!this.enabled || !this.hasPermission(shared_utils_1.PluginPermission.COMPONENTS)) return;

if (instance) {
let t = await this.backendApi.transformCall(shared_utils_1.HookEvents.COMPONENT_UPDATED, instance);
this.ctx.hook.emit(shared_utils_1.HookEvents.COMPONENT_UPDATED, ...t);
} else {
this.ctx.hook.emit(shared_utils_1.HookEvents.COMPONENT_UPDATED);
}
}

It don't crash anymore. Modifying the outputted file by hand is not a production-proof workflow though, and it'd be better if Babel could be run on it naturally.

Environment

npx envinfo --preset babel

System:
OS: Windows 10 10.0.19044
Binaries:
Node: 16.13.2 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD

Possible solution

No response

Additional context

No response

Issue 2:
Bug Report

Current behavior

REPL

import Component from '@glimmer/component';
import intersection from 'lodash/intersection';

export default class FooComponent extends Component {
async foo() {
intersection(...(await Promise.all([])));
}
}

Expected behavior

Code to be transpiled correctly.

Currently Babel blows up with:

Expected type "Expression" with option undefined, but instead got "SpreadElement".

Using firefox 35 for targets works. As does firefox 53 and above.