Concordium / concordium-dapp-libraries

A coherent set of building blocks for making it as easy as possible for developers to build web-based dApps.
Apache License 2.0
7 stars 5 forks source link

Add ESM as additional build target to support tree shaking #49

Closed soerenbf closed 9 months ago

soerenbf commented 9 months ago

In preparation of releasing https://github.com/Concordium/concordium-node-sdk-js/pull/266, we need to also update the libraries included in this repo to be tree-shakable.

Changes

Checklist

bisgardo commented 9 months ago

@soerenbf sorry I didn't have time to look at this before it got merged. Do you have some references on tree shaking/ESM that explain why these changes are necessary? Do we need to change anything about how we build/publish/use this project?

soerenbf commented 9 months ago

Webpack has documentation on tree-shaking here, which I think is the standard implementation for bundlers in general.

To sum up, ES modules facilitate tree shaking (or dead code elimination) for bundlers, commonJS modules do not. As the SDK is only published with ES modules from version 10 and onwards, all libraries using the SDK need to follow suit in preparation of upgrading their reference to the SDK to the latest version.

Does that make sense?