There is own module with not translated code which lies in node_modules. The following is written in the webpack config:
{ test: /\.js$/, loaders: ['babel'], exclude: /node_modules/ } I would like to exclude transpiling everything in node_modules except for my module. For this, I wrote the following:
exclude: /node_modules(?!\/my_module)/ But I did not get the desired result. When you start the application, an error pops up
Uncaught SyntaxError: Unexpected token import (...)
Swears on index.js, in which the necessary components are connected via import.
I tried to bring my module out of the node_modules folder and set the direct path to it in the application.
Instead of import { someComponent } from 'my_module' I wrote the following import { someComponent } from '../my_module' . Naturally, 'my_module' rendered from node_modules to the correct directory.
In theory, now the restriction on transpilation, which is written in the webpack should not apply to my module. But, for some reason, the error does not disappear. As before, the code is not transpiled and the compiler swears at an import unknown to it. What to do?