safe-global / safe-modules

A collection of modules that can be used with the Safe contract
GNU Lesser General Public License v3.0
140 stars 73 forks source link

Explore adding a ESM build to passkey/4337 packages #395

Closed mmv08 closed 2 weeks ago

mmv08 commented 4 months ago

Description

Currently, we're exporting all the builds as commonjs and a lot of tooling is expecting es module builds nowadays, and sometimes the interop mechanism has bugs (e.g., https://github.com/safe-global/safe-modules/pull/389#discussion_r1574665647)

Hardhat doesn't support ESM with TypeScript, so the only solution we can try is to add a second typescript config and use it for the build

mmv08 commented 2 weeks ago

I looked into the original error message and discovered the problem was in the cbor's package incompatibility with the browser environment. I fixed it by switching to a web-compatible version, and, therefore, I propose not to add an ESM build. We can postpone that to later and see if we get any requests from the users (we do not market the passkeys package as the SDK for Safe + Passkeys and have a dedicated SDK in the safe-core-sdk)