jerryscript icon indicating copy to clipboard operation
jerryscript copied to clipboard

Using keyword default in imports and exports throws parser error

Open dananderson opened this issue 3 years ago • 0 comments

From my reading of the spec, it sounds like keywords are not allowed as export names. However, modules can export default and the spec is not explicit on whether this is allowed.

Node/V8 allows using default in imports and exports. And, tools like sucrase, babel, terser, etc will collapse import statements using "as default". As a result, almost any ESM code that runs through transpilers and minifiers will not work in jerryscript.

It is a small bug on the jerryscript side, but a real pain on the tooling side.

JerryScript revision

2.4.0

Build platform

all

Build steps

n/a

Build log

n/a

Test case

export { default as something } from 'package'

Note: There are a couple other ways V8 allows default to be used in import and export statements.

Execution platform

all

Execution steps

n/a

Output

Parser error

Backtrace

n/a

Expected behavior

No parse or runtime Error.

dananderson avatar Jul 30 '22 17:07 dananderson