Deduping ESM and CJS versions of the same package #18082
-
Feature requestWhat is the expected behavior? When part of the codebase {
"exports": {
".": {
"browser": {
"require": "./dist/browser-cjs/index.js",
"import": "./dist/esm2017/index.js"
},
"default": "./dist/esm2017/index.js"
}
} As it's the case with most In this situation, it would be nice to have a way to force using the same dist file to minimize bundle size. What is motivation or use case for adding/changing the behavior? Minimizing bundle size. How should this be implemented in your opinion? Not sure, and not even sure if it's fixable, I just want to start the conversation about this issue |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
OH just found out about I was able to solve this by using
|
Beta Was this translation helpful? Give feedback.
-
Actually I'm realizing this break some packages... I think I would need more of a cherry picking approach, e.g. applying a custom I'm thinking maybe there's a way to write a Webpack plugin for this? Would love a few pointers on how to achieve that, I can't figure how to hook to dynamically transform any dependency's |
Beta Was this translation helpful? Give feedback.
-
Why? Do you use traspilation? If you will have |
Beta Was this translation helpful? Give feedback.
-
Related: #15967 |
Beta Was this translation helpful? Give feedback.
Everywhere I use
import ... from '@firebase/...'
it does use the esm2017 build, but I do use other dependencies (in particular next-firebase-auth) that itself usesrequire('@firebase/...')
and that results in the browser-cjs build to be included as wellFWIW next-firebase-auth's source code uses TypeScript with
import
, but then they also use Webpack on their side to produce the dist file which is CJS only. I tried forking it to make Webpack outputimport
statements but it seems quite involved as it implies turning the whole package into a ESM moduleSo far I've come up with a solution using
config.reslove.alias