While working on
I realized I am not as knowledgable in nodejs' support
for ECMAScript Modules (esm).
I think it's very simple in the browser. There is
import and there is
which nicely gradually falls back to before ESM times. But what about nodejs?
There is a
package.json with properties such as
and any combination of them. For a long time I am using
to allow me to use ESM on nodejs, but when publishing a package such as
pico-tester, I must be compatible with as many ways as possible, in which nodejs can be used.
So first there is terminology to get right (esm, cjs, ...) and than provide the right type of package or packaging
so it can be used there. I might update this over time with more learnings.
I started a repo understand-npm-packaging where I try to investigate and provide tests for the nodejs package setups and configurations to understand how to build a packages.json, the files inside, etc. using npm. The changes over the last years, like
- ECMAScript modules (esm)
- and other options
that one can use with a nodejs package to build and use a package has made it quite hard to understand what works and how. At least that was the case for me while building pico-tester.
So I started this project which uses the excellent smoke "an integration test framework for practically anything" to test and describe the different setups and ensure the learnings I make are validated and don't just evaporate after trying it out.
Eventually this might be useful for testing against different nodejs versions too. And maybe there is also a suite of tests for nodejs for that already, I didn't search for it. If so, this is double work and was just a learning for me, then I would suggest to go look at the other tests, not those here.