ESM modules not recognised as ESM by Node
Thanks for the very promising library. When running a Node server (20.3.1 and other versions), it seems like the ESM modules aren't recognised as ESM by Node:
import { CborEncoderFast } from 'json-joy/esm/json-pack/cbor/CborEncoderFast';
^^^^^^^^^^^^^^^
SyntaxError: Named export 'CborEncoderFast' not found.
The requested module 'json-joy/esm/json-pack/cbor/CborEncoderFast' is a
CommonJS module, which may not support all module.exports as named exports.
~~I assume CborEncoderFast.js is indeed a valid ESM module (could someone verify?), which means Node is identifying it wrongly for some reason.~~ This seems to be because Node requires the nearest package.json to contain "type": "module" for it to interpret .js files as modules. Since json-joy contains multiple module formats, it seems like specifying a single module type for the whole repo isn't going to work.
edit: I added a package.json containing { "type": "module" } to the esm folder, and it works now.
(An alternative is to name the ESM files with .mjs to indicate they're ESM, if that's possibly better for other scenarios.)
Thanks, the build output will be improved in the future, but currently it is best just to use it CommonJS-way.