Description
-
I'm submitting a ...
[ ] bug report
[ x ] feature request
[ ] question about the decisions made in the repository
[ ] question about how to use this project -
Summary
Currently, if you add a dependency like node-fetch, it breaks the build/run/test because module is set to commonjs. There is a non trivial amount of configuration to actually reconfigure the project for ESM.First you have to setup the project to build esm, which is easy enough because node-fetch gives you the steps:
Loading node-fetch@3 in CJS and ESM node-fetch/node-fetch#1279 (comment)
However ava requires additional reconfiguration. For ava, you need to:
-
bump the ava dependency to ^4.1.0 - https://github.com/avajs/ava/blob/main/docs/recipes/es-modules.md
-
bump the ava typescript dependency to ^3.0.1 and add the
"compile": false
property- https://github.com/avajs/typescript/blob/v3.0.1/README.md#enabling-typescript-support -
as mentioned here though (Update TypeScript recipe for ESM support avajs/ava#2593 (comment)), by default ava will still be looking for files with the .js extension, which isn't what you get from tsc. To finally have the tests pass again, you need to enable --experimental-specifier-resolution=node in the ava config:
"ava": { .... "nodeArguments": [ "--experimental-specifier-resolution=node" ], }