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

Convert Library to support ES Modules #1107

Open
JohanBjoerklund opened this issue Mar 2, 2023 · 9 comments
Open

Convert Library to support ES Modules #1107

JohanBjoerklund opened this issue Mar 2, 2023 · 9 comments
Labels
do not stale Feature New feature or request

Comments

@JohanBjoerklund
Copy link

Is your feature request related to a problem? Please describe.
Support for esm modules, since it has been supported in node for a while now.

Describe the solution you'd like
Expose esm modulus.

Describe alternatives you've considered
Impossible to use alternative if you want access to top level await etc

@JohanBjoerklund JohanBjoerklund added the Feature New feature or request label Mar 2, 2023
@wboereboom
Copy link
Contributor

Hi @JohanBjoerklund ,

Thanks for requesting this feature.
Could you maybe elaborate why you need this feature, and which problems it would solve for you?

Kind Regards,
Wouter
Adyen

@JohanBjoerklund
Copy link
Author

It would enable the use of advanced features like top level await. That is not possible for anyone using this package at the moment.

@wboereboom
Copy link
Contributor

Understood. I will add this feature to our Backlog.
We'll investigate whether we can make this change without breaking current merchant implementations, and we shall address it when we can.

Kind Regards,
Wouter
Adyen

@wboereboom wboereboom changed the title [FEATURE] [FEATURE] Convert Library to support ES Module Jul 4, 2023
@wboereboom wboereboom changed the title [FEATURE] Convert Library to support ES Module [FEATURE] Convert Library to support ES Modules Jul 4, 2023
@tpater
Copy link

tpater commented Dec 7, 2023

I'd vote for this as well. When using esbuild as a bundler it is impossible to do a proper tree-shaking with commonjs modules. At least for now. ES modules convertion would be really helpfull. When you use library e.g. as a dependency in AWS lambda - even though ES imports work - the whole library is being bundled into final minified chunk.

@alfaproject
Copy link

I'm having the exact same issue as @tpater. Due to the use of classes the library is massive and can't be tree shaken )':

@paul-vd
Copy link

paul-vd commented Apr 25, 2024

We have a project using vite, we had to polyfill the library so that it works, as vite converts esm, but due to they weird bundled code, it not longer allows the named exports.

Here is the solution we implemented, but yea, this means no treashaking, but it's fine as we only use it server side.

// lib/adyen/api-library.ts
import * as AdyenLib from "@adyen/api-library";
export type * from "@adyen/api-library";

const Adyen =
  (AdyenLib as any as { default: typeof AdyenLib })?.default ?? AdyenLib;

export default Adyen;

it would be great if the package could implement hybrid usage for the bundles: https://www.sensedeep.com/blog/posts/2021/how-to-create-single-source-npm-module.html

@ptlls
Copy link

ptlls commented May 17, 2024

@wboereboom Do you have an update on this?

When using the lib in AWS Lambda and esbuild, we are getting a huge bundle size of 1.9MB where 1.4MB is from this library.

image

Checkout, Terminal and other things are bundled even if we don't use it at all in our implementation.

@ptlls
Copy link

ptlls commented Jun 5, 2024

@DjoykeAbyah would you be able to help providing an update on this matter? Sorry to bother, I see you have been active in this repo and it would be great to get this improvement.

@DjoykeAbyah
Copy link
Contributor

Hi @ptlls!

No problem at all! It wasn't in our initial roadmap at the time, but we will investigate this further. Currently, I don't have any updates on this matter, but I will get back to you as soon as I know more.

Regards,

Djoyke
Adyen

@DjoykeAbyah DjoykeAbyah changed the title [FEATURE] Convert Library to support ES Modules ECP-9262: [FEATURE] Convert Library to support ES Modules Jun 6, 2024
@DjoykeAbyah DjoykeAbyah changed the title ECP-9262: [FEATURE] Convert Library to support ES Modules ECP-9262: Convert Library to support ES Modules Jun 6, 2024
@DjoykeAbyah DjoykeAbyah changed the title ECP-9262: Convert Library to support ES Modules Convert Library to support ES Modules Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not stale Feature New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants