The typescript+react load module using import () is not valid in production mode

using import () syntax to load the module asynchronously in the typescript+react project built by create-react-app, it is found that everything is normal in the development environment. The module can be loaded in NODE_ENV = production , but the code cannot be executed. I tried different asynchronous loading tools and found that the import () method is actually encapsulated under the analysis, so it is guessed that it is the problem of import ()? It"s not long since I started typescript. I don"t know what"s going on.

below is a screenshot. After build, only loading components or Error components are displayed. The actual components see that the network has been loaded but not executed.

clipboard.png

clipboard.png

clipboard.png


configuration information had better be completed. This does not see the problem at all. And why do you use two kinds of asynchronously loaded plug-ins


to solve it yourself? after configuration reconstruction, it is found that there is a problem with webpack3's webpack.optimize.CommonsChunkPlugin plug-in configuration.

Menu