hildjj / node-cbor

Encode and decode CBOR documents, with both easy mode, streaming mode, and SAX-style evented mode.
MIT License
356 stars 73 forks source link

Move to ESM #179

Open hildjj opened 1 year ago

hildjj commented 1 year ago

I'm going to do a release of the current version of the cbor package, then start the migration to ESM.

This is going to be a big breaking change, so if you want to complain about it, now is the time.

hildjj commented 1 year ago

I think #180 is getting pretty close. I'd love to have someone else take a look at it before I merge it. I'm going to want to do a release of 10.0 pretty quickly after it merges, to ensure that the docs stay in sync.

ottokruse commented 1 year ago

Would love ESM support, have to jump through a hoop now while using this package in ESM code, bundling with esbuild: https://github.com/evanw/esbuild/issues/1921

Have you considered / are you planning dual support: you can support CommonJS and ESM at the same time.

hildjj commented 1 year ago

For ESM support, I'd rather direct you to cbor2 starting today. It has a much simpler Uint8Array + synchronous API, and works in ESM environments (node, deno, and browser) out of the box without any runtime dependencies. It shouldn't have issues with large input messages, as long as you have the entire message in memory. It doesn't have support for commented mode yet, but that's coming soon.

Dual support was likely to cause issues with people loading the library both ways, so I wasn't excited about that. The amount of headache I would cause for everyone with #180 was big enough that it was easier to just rewrite the library.

ottokruse commented 1 year ago

Okay got it, cool