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

Compile to ECMAScript Modules (ESM) instead of CommonJS #1004

Open
1 of 4 tasks
webmaster128 opened this issue Jan 23, 2022 · 0 comments
Open
1 of 4 tasks

Compile to ECMAScript Modules (ESM) instead of CommonJS #1004

webmaster128 opened this issue Jan 23, 2022 · 0 comments

Comments

@webmaster128
Copy link
Member

Right now, CosmJS produces CommonJS builds. This works well for all versions of Node.js as well as bundlers like Webpack in order to bundle for the web.

As mentioned in https://vuejsdevelopers.com/2019/02/04/vue-es-module-browser-build/ ("What benefit is there of using Vue as an ES module?"), there is little obvious benefit for switching from CommonJS to ESM since the consumers are either node.js apps or bundlers. However, there is hope that ESM helps optimizing bundle size through tree shaking because ESM can better do static analysis on what is used and what is not (https://webpack.js.org/guides/tree-shaking/). In #904 you see that right now web apps include a lot of unused code that is only needed for key storage.

Other libraries use bundlers to bundle ES modules for the web. This is not desired here as we don't have a single entry point and do not want to decide for that user what should be included in such a bundle.

Do we need CommonJS+ESM hybrid builds?

Does this reduce bundle size

Testing

@webmaster128 webmaster128 changed the title Compile to ES modules Compile to ECMAScript Modules (ESM) instead of CommonJS Jan 23, 2022
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