developit / microbundle

📦 Zero-configuration bundler for tiny modules.
https://npm.im/microbundle
MIT License
8.05k stars 362 forks source link

打包后的产物 x.moduel.mjs 存在箭头函数,导致IE 无法兼容 #1065

Closed hduhdc closed 10 months ago

hduhdc commented 10 months ago

打包后的产物 x.moduel.mjs 存在箭头函数,导致IE 无法兼容 Object.keys({name:1}).forEach(key => { console.log(key) }); 打包后结果 Object.keys({name:1}).forEach(e=>{console.log(e)}); //# sourceMappingURL=test-microbundle.modern.mjs.map

rschristian commented 10 months ago

This is correct behavior. The modern output is ES2017: https://github.com/developit/microbundle#-modern-mode-

If you really need IE support, use CJS, ESM, or UMD outputs. Modern is specifically for dropping the baggage those formats ship with.

rschristian commented 10 months ago

Please use English, I don't understand what you're trying to say.

hduhdc commented 10 months ago

Please use English, I don't understand what you're trying to say. I know my mistake,if my packge is foo,when i use import foo from 'foo '
If the configuration of my package. json is as follows "exports": {

"default": "./lib/foo.js" 

}, Is it possible to avoid using it by default ./lib/modern.mjs