-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update limits and remove sections about bug #15
Comments
Why Node.js behaviour with CJS to ESM converting for default exports (of module has only default export, export it as object without wrappers) do not work for webpack? It leads to inconsistency between Webpack and Node.js behaviour and it is the source of the problem. |
Using test.mjs import cjs from './foo.cjs';
import mjs from './foo.mjs';
console.log(cjs);
console.log(mjs); foo.cjs // For:
// module.exports = { default: 'cjs' };
//
// output node and webpack is same:
//
// { default: 'cjs' }
module.exports = 'cjs'; foo.mjs export default 'mjs'; Output:
Using Output:
|
CommonJS doesn't have |
Nope, I am talking about different problem. You have dual CJS/ESM package: // lib/index.mjs
export default 'lib' // lib/index.cjs
module.exports = 'lib' For Node.js both constructions will work: require('lib') //=> 'lib' import lib from 'lib' //=> 'lib' In Webpack you will have a different result: require('lib') //=> { default: 'lib' } It is a open issue and seems like it was fixed in webpack 5, so it is a bug for my understanding of this term. But we can replace this line with recommendations using webpack 5. |
https://github.com/ai/dual-publish#limits
It can be misleading because it is not a bug. Explanation - webpack/webpack#7973 (comment) Many other tools (for example babel) work similarly. Even rollup has https://rollupjs.org/guide/en/#outputinterop to control this, because this is a very controversial issue
The text was updated successfully, but these errors were encountered: