You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dynamic imports: only use .default when present (Uniswap#115)
* Dynamic imports: only use .default when present
This solves an issue where in some cases, the imported module returns
the default export directly, rather than being on the .default property.
In CJS, the import() calls get transformed into
Promise.resolve(require("dependency")) calls. Bundlers seem to stick to
CJS in this case, and pick the `main` field of the dependency, which is
usually CJS with a .default prop.
In ESM, the import() calls don’t get transformed. In this case, bundlers
seem to behave in different ways, by following one of the `main`,
`module` and `browser` fields. In these two last cases, the default
export is available directly and not on the .default property.
By checking if .default is defined and using the imported value
otherwise, we make these imports compatible with these different
scenarios.
* Prettier fix
0 commit comments