With this config:
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "16"
}
}
]
]
}
...Babel converts import
/export
syntax to CommonJS (require
).
How do I change this so Babel preserves import
and export
syntax, so I can run the resulting output as an ES module (e.g. running it with node
with an .mjs
extension)?
I've tried adding "esmodules": true
to the targets
, but this doesn't seem to make any difference when combined with "node": "16"
.