qiulang / ArrowFunc

To demonstrate babel failed to transpile debugjs arrow function for IE

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The reason babel failed to transpile arrow function for IE

findings

With the help from Failed to transpile arrow functions even I saw "transform-arrow-functions { ie } " from log and I have not exclude /node_modules/ I was able to reproduce this problem and the following are what I found:

  1. debugjs causes the problem.
  2. I first used .babelrc then babel failed to transpile debugjs after I changed it to babel.config.json babel can transpile debugjs but why ?

reproduce procedure

  1. use .bablerc instead of babel.config.json, run npm run bundle
  2. run ag --js -c "=>{" ./dist/ or grep -c "=>{" ./dist/main.js to check

conclusion

  1. use babel.config.json for babel 7, refer to https://babeljs.io/docs/config-files#6x-vs-7x-babelrc-loading
  2. exclude setting in webpack.config.js:
    1. Without it, can transpile the code but browsers fail to run
    2. with it, IE fails to run
    3. So to make IE and all other evergreen browsers to run, use exclude: /node_modules\/(?!(debug)\/).*/,

想不到最后居然还是因为debugjs , 从 2019开始我就被它搞,都4年了 😂

  1. @babel/preset-env fails to polyfill IE11 for debug module, version 4 qiulang opened this issue on Nov 14, 2019
  2. Failing to load the file in IE qiulang commented on Jun 22, 2021 give up then !
  3. 现在 。。。

About

To demonstrate babel failed to transpile debugjs arrow function for IE


Languages

Language:JavaScript 78.0%Language:HTML 22.0%