Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mmv08 opened this issue Apr 22, 2024 · 1 comment
Closed

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

mmv08 opened this issue Apr 22, 2024 · 1 comment
Assignees

Comments

@mmv08
Copy link
Member

mmv08 commented Apr 22, 2024

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., #389 (comment))

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
Copy link
Member Author

mmv08 commented Aug 28, 2024

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)

mmv08 added a commit that referenced this issue Aug 29, 2024
…bal/safe-passkey` and update imports in the example app (#488)

When trying to solve
#395, I looked at the
original error that triggered the discussion of adding an ESM build to
the packages. I thought that the error was due to a bug in the bundler's
ESM interoperability mechanism, but I realised that actually the issue
was in the `cbor` package and compatibility with the browser
environment.

When you import a js module, the code will get evaluated regardless of
it use:
https://www.perplexity.ai/search/does-javascript-evaluate-an-im-y4Zv1HKiQNmqxnHd1HJ1SA#0
(we may not use any of the functionality that's actually incompatible
but because the code gets evaluated and it may imported a package that's
unavailable in browser)

This PR:
- Fixes compatibility of the `@safe-global/safe-passkey` with the
browser environment by switching from `cbor` to `cbor-web` package as
recommended in the package [readme](https://github.com/hildjj/node-cbor)
- Use the `@safe-global/safe-passkey` code in the example app
- Updates the upstream bundler image TAG because it seems like they
switched branch names
@mmv08 mmv08 closed this as completed Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant