Node and ESM module resolution
- Include a
"type": "module"in the
package.jsonfor the imported module.
- Set the file extension of the imported module to
I was a bit confused about this, so created a repo to shore up my understanding: github.com/m-allanson/node-esm-resolution.
If you’re writing a package and want to export CommonJS and ESM versions, here’s a good overview by Dr. Axel Rauschmayer.