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

Build as ES Module #946

Open
elvis-pereira opened this issue Oct 31, 2024 · 0 comments
Open

Build as ES Module #946

elvis-pereira opened this issue Oct 31, 2024 · 0 comments

Comments

@elvis-pereira
Copy link

Summary

ES modules are widely supported: MDN, caniuse and offer some advantages, like the ability of bundlers to do tree-shaking.

Basic example

In the most basic setup, only a single line of code would have to change in rollup.config.js:

output: [
    {
      file: pkg.main,
-     format: 'cjs',
+     format: 'es',
      sourcemap: true,
    },
  ]

Motivation

In my code currently I only use the recurrent.LSTM() class, and with the change above I observed a 56% bundle size reduction after tree-shaking. That value will obviously vary from user to user, but there will probably be a reduction in bundle size. If legacy support is important then it's possible to ship both, cjs and esm code, but I personally don't think that this is necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant