What issues could occur from a default export? #735
-
Taken from the Builder Bob docs:
What issues could arise from using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It's primarily an issue with dual module packages (ESM & require), by default, the template produces a library with dual module package. You can read more at https://satya164.page/posts/publishing-dual-module-esm-libraries#default-exports Also, the syntax to use default exports in CommonJS is not elegant as you have to do In addition, multiple exports instead of a single object in default export may help with smaller bundle sizes in bundlers that support tree-shaking (currently most web bundlers as well as expo flavored metro). |
Beta Was this translation helpful? Give feedback.
It's primarily an issue with dual module packages (ESM & require), by default, the template produces a library with dual module package.
You can read more at https://satya164.page/posts/publishing-dual-module-esm-libraries#default-exports
Also, the syntax to use default exports in CommonJS is not elegant as you have to do
require('./module.js').default
.In addition, multiple exports instead of a single object in default export may help with smaller bundle sizes in bundlers that support tree-shaking (currently most web bundlers as well as expo flavored metro).