简体   繁体   中英

Webpack, babel and node_modules ignore

While using babel it's recommended to ignore node_modules folder. But then those libraries in node_modules are not passing through babel and as result you get code some of which complies with babel presets and some not. For example, if one wants to target ES5, that will not work if any of the libraries in node_modules are not ES5 compliant.

What is the recommended way?

It's correct not to run the node_modules folder through babel, because of two reasons:

  1. Compiling all the node modules can take a really long time
  2. Node modules are generally written in ES5 syntax and, if they're not, they're still compatible with the latest versions of node.

So unless you use specific modules, or you need compatibility with older browsers, you'll be fine with ignoring the node_modules folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM