How can I test if a JS library is packaged correctly (in different environments)?

31 views Asked by At

I know normal software testing like unit test. This question is not about that.

Assume I am new to JS (and indeed) and am developing a JS library project, and intend to publish it to, e.g., npm. Because the ecosystem is complex, I will likely not be able to configure my project correctly for its packaging. For example, I may have pointed require in package.json to an ES-Module file, while in fact it expects a CommonJS-Module file; however, I may have generated them correctly, but just misconfigured my package.json. This has nothing to do with my actual (functional) source code, but just the packaging configuration and packaging tools.

As there is not just package.json, but also lots of packaging and supporting tools (e.g. Vite, Rollup, etc), each involving their own configuration files, it is very likely I will make mistakes in their configurations, and resulting in the library unusable simply because of the packaging configuration.

How can I test that my packaging is correct, for different environments, without having to manually creating multiple test projects? Alternatively, how can I get suggestions on what might be the correct configuration or expected outcomes? What tools are available out there?

In particular, I'm thinking of something like a compatibility / coverage report. But other forms are also fine.

0

There are 0 answers