Closed DeRain closed 1 year ago
We only export ESM packages now. You could either go back to version 9 and use that, it's perfectly usable, but you'll just have compatibility issues with other packages that use it. Alternatively you could compile it down using tool that takes ESM and converts to CJS for you; that's not an unreasonable approach if you're really stuck in a CJS environment.
Thanks you for clarification!
Another option should work, though may not be convenient in your codebase, using await import
to import the library:
const { CID, hasher, digest, varint, bytes } = await import('multiformats')
Thanks all for help! I've decided to go with fork and added CommonJS build: https://github.com/unstoppabledomains/js-multiformats
Hi, I've been trying to use a package in commonjs environment and got the following error (I assume it's because exports doesn't have require section).
Is it a bug or you don't allow to use this package in commonjs envs? Thank you!