On-the-fly ESM babel transpilation #2760
-
I am experimenting with transforming a CommonJS module into an ECMAScript module. I use AVA to test this module. One thing I am struggling with is the following: when I set How should I configure AVA so that it strips debug statements when I run my tests outside of the debug environment? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 15 replies
-
ESM uses a different loading mechanism. Your on-the-fly transpiler needs to hook into this. It's nothing to do with AVA but is available as an experimental Node.js feature instead. You should be able to find out more by asking the transpiler project. |
Beta Was this translation helpful? Give feedback.
-
After some research I came up with the following solution:
Example diff edit-distance/myers-1986@8c1b1cb |
Beta Was this translation helpful? Give feedback.
-
AVA 4 targets Node.js versions that support ESM, so there's no more need for feature detection. |
Beta Was this translation helpful? Give feedback.
After some research I came up with the following solution:
@node-loader/babel
"--experimental-loader=@node-loader/babel"
to"nodeArguments"
key in AVA's configtest
,cover
, anddebug
environments.Example diff edit-distance/myers-1986@8c1b1cb