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

feat: ESM Modules #514

Open
yagopv opened this issue Aug 29, 2023 · 1 comment
Open

feat: ESM Modules #514

yagopv opened this issue Aug 29, 2023 · 1 comment

Comments

@yagopv
Copy link
Member

yagopv commented Aug 29, 2023

Context / issue

Using current node engines with esm modules is difficult and require some hacks as we are compiling safe-core-sdk using commonjs

Proposed solution

The proposed solution would compile safe-core-sdk with a dual output with both commonjs and esm modules being distributed inside the package

Additional context

First issue
Similar solution in safe-apps-sdk
Issue with Safe.create

@mattcasey
Copy link

I think I ran into a related bug: when using dynamic imports with this lib, we get a nested 'default' prop. To illustrate:

export async function getSafeApiClient({ chainId }: { chainId: number }): Promise<ISafeApiKit> {

  const imported = await import('@safe-global/api-kit');
  const SafeApiKit = imported.default.default || imported.default;
}

And it depends on how we're running it, so it could be our configuration. If I run the code with ts-node or Next.js, the issue does not happen. If I use esbuild or tsx, then it is nested inside an extra default prop

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

2 participants