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:
as mentioned here though (https://github.com/avajs/ava/issues/2593#issue-714117054), 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:
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:
https://github.com/node-fetch/node-fetch/issues/1279#issuecomment-915062146
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-supportas mentioned here though (https://github.com/avajs/ava/issues/2593#issue-714117054), 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: