Provide explicit ESM and CommonJS exports.

Review Request #13556 — Created Feb. 19, 2024 and submitted

Information

Spina
master

Reviewers

Spina now provides exports for ESM modules and for CommonJS modules,
making it easier to consume in projects.

The ESM modules export all the Spina exports along with a "Spina"
default export that encompasses everything as a top-level namespace.

The CommonJS modules behave as normal, since one is expected to do
const Spina = require('@beanbag/spina');.

Notably, we are not setting "type": "module" in package.json, as our
main export is a UMD module and not a ESM module. This is important for
consumption in browsers, and also for compilation/unit testing in
general (setting it to "module" breaks all sorts of things).

There's also a fix that was found in the process where tsc wasn't
getting run correctly. Once fixed, it found a missing type import,
which has been addressed.

Successfully built and consumed Spina.

Summary ID
Provide explicit ESM and CommonJS exports.
Spina now provides exports for ESM modules and for CommonJS modules, making it easier to consume in projects. The ESM modules export all the Spina exports along with a "Spina" default export that encompasses everything as a top-level namespace. The CommonJS modules behave as normal, since one is expected to do `const Spina = require('@beanbag/spina');`. Notably, we are not setting `"type": "module"` in `package.json`, as our main export is a UMD module and not a ESM module. This is important for consumption in browsers, and also for compilation/unit testing in general (setting it to `"module"` breaks all sorts of things).
45d4eb38a83559a14bbd7584f4e60af715ee90a6
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to master (bdab863)
Loading...