Babel-loader compiler node_module error

< H1 > question < / H1 >

in the webpack template project of vue, I gave the node_module directory include to babel-loader for es6-> es5 translation of the referenced module. As a result, warnings and errors occurred when npm run build , errors and warnings were numerous and repeated. I will show several screenshots of different error areas below.

I opened a github project to solve this problem. The project is very small, and after installing the dependencies, you can build to reproduce the errors.
https://github.com/Yatoo2018/.

< H2 > error screenshot < / H2 >

clipboard.png

clipboard.png

clipboard.png

babelrc

 


first question:

exclude : /node_modules\/(?!(dom7|ssr-window|swiper)\/).*/

means that the three rules are not followed by dom7 | ssr-window | swiper , that is, if you import , all three will be processed by babel , because all three syntax supports esm .
second question:

exclude: /node_modules\/(?!(dom7|ssr-window|swiper)\/).*/,
include: [resolve('src'), resolve('test'),resolve('node_modules/webpack-dev-server/client')]

you don't have include (dom7 | ssr-window | swiper) in this way, so naturally you don't deal with babel , but exclude is mainly used for elimination.

third question:

include: [resolve('src'), resolve('test'),resolve('node_modules/webpack-dev-server/client'),resolve('node_modules')]

you put all the node_modules include in, so some modules may not have esm syntax, such as babel-runtime , lodash , etc., which may cause errors or warnings.

Menu