Skip to content

What issues could occur from a default export? #735

Answered by satya164
KiwiKilian asked this question in Q&A
Discussion options

You must be logged in to vote

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).

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@KiwiKilian
Comment options

Answer selected by KiwiKilian
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants