I have a problem with Webpack. It compiles and tree-shakes correctly, but gives me hundreds of errors, because it for some reason does something with type definitions in node_modules, even though it shouldn't, because no module is required/imported in my entry point.
My webpack.config.js:
const ForkCheckerPlugin = require("awesome-typescript-loader").ForkCheckerPlugin;
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const webpack = require("webpack");
module.exports = {
entry:
{
browser: __dirname + "/source/index.tsx"
},
module:
{
loaders:
[
{ test: /(\.ts|\.tsx)$/, loader: "awesome-typescript-loader" },
{ test: /\.css$/, loader: ExtractTextPlugin.extract({ loader: "css-loader?modules" }) },
{ test: /\.png$/, loader: "url-loader" },
{ test: /\.jpg$/, loader: "url-loader" },
{ test: /\.json$/, loader: "json-loader" },
]
},
plugins:
[
new webpack.DefinePlugin({ "process.env": { NODE_ENV: JSON.stringify("production") } }),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({ compressor: { warnings: false } }),
new webpack.optimize.CommonsChunkPlugin({ name: "vendor", minChunks: module => /node_modules/.test(module.resource) }),
new ExtractTextPlugin("browser.css"),
],
output:
{
filename: "[name].js",
chunkFilename: "[name].js",
path: __dirname + "/build/browser/"
}
};
My entrypoint (source/index.tsx) - basically nothing:
console.log("Test");
Errors it gives me (shortened, they're all similar):
ERROR in [default] C:\Users\Tom\VSCodeProjects\personal\webpack-test\node_modules\@types\react-router\lib\match.d.ts:12:15
Module '"C:/Users/Tom/VSCodeProjects/personal/webpack-test/node_modules/history/lib/index"' has no exported member 'History'.
ERROR in [default] C:\Users\Tom\VSCodeProjects\personal\webpack-test\node_modules\@types\react-router\lib\match.d.ts:16:80
Module '"C:/Users/Tom/VSCodeProjects/personal/webpack-test/node_modules/history/lib/index"' has no exported member 'Location'.
ERROR in [default] C:\Users\Tom\VSCodeProjects\personal\webpack-test\node_modules\@types\react-router\lib\useRouterHistory.d.ts:1:9
Module '"C:/Users/Tom/VSCodeProjects/personal/webpack-test/node_modules/history/lib/index"' has no exported member 'History'.
ERROR in [default] C:\Users\Tom\VSCodeProjects\personal\webpack-test\node_modules\@types\react-router\lib\useRouterHistory.d.ts:1:18
Module '"C:/Users/Tom/VSCodeProjects/personal/webpack-test/node_modules/history/lib/index"' has no exported member 'HistoryOptions'.
ERROR in [default] C:\Users\Tom\VSCodeProjects\personal\webpack-test\node_modules\@types\react-router\lib\useRouterHistory.d.ts:1:34
Module '"C:/Users/Tom/VSCodeProjects/personal/webpack-test/node_modules/history/lib/index"' has no exported member 'HistoryQueries'.
ERROR in [default] C:\Users\Tom\VSCodeProjects\personal\webpack-test\node_modules\@types\react-router\lib\useRouterHistory.d.ts:1:50
Module '"C:/Users/Tom/VSCodeProjects/personal/webpack-test/node_modules/history/lib/index"' has no exported member 'CreateHistory'.
ERROR in [default] C:\Users\Tom\VSCodeProjects\personal\webpack-test\node_modules\@types\react-router\lib\useRoutes.d.ts:4:47
Module '"C:/Users/Tom/VSCodeProjects/personal/webpack-test/node_modules/history/lib/index"' has no exported member 'CreateHistory'.
ERROR in [default] C:\Users\Tom\VSCodeProjects\personal\webpack-test\node_modules\@types\react-router\lib\useRoutes.d.ts:4:68
Module '"C:/Users/Tom/VSCodeProjects/personal/webpack-test/node_modules/history/lib/index"' has no exported member 'CreateHistory'.