Babel does not transpile imported modules from 'node_modules'

后端 未结 2 1220
夕颜
夕颜 2021-02-14 10:54

I got a problem with transpiling imported modules from node_modules. Babel for some reason doesn\'t transpile imported module from node_modules, but tr

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-14 11:16

    The solution in this case is to transpile the module again, this can be done by modifying the exclude property in your webpack config:

    {
      test: /\.js$/,
      exclude: /node_modules\/(?!(es6-module|another-es6-module)\/).*/,
    },
    

    Modules es6-module and another-es6-module will no longer be ignored by webpack and will be transpiled with the rest of your source code.

    See the GitHub issue on the webpack project.

    Tested with webpack@3.12.0, babel-core@6.26.3 and babel-core@6.26.3

提交回复
热议问题