jerryscript-project / jerryscript

Ultra-lightweight JavaScript engine for the Internet of Things.
https://jerryscript.net
Apache License 2.0
6.89k stars 669 forks source link

Using keyword default in imports and exports throws parser error #5016

Open dananderson opened 2 years ago

dananderson commented 2 years ago

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.