Webpack に問題があります。正しくコンパイルしてツリーシェイクしますが、何百ものエラーが発生します。これは、エントリーポイントでモジュールが必要/インポートされていないため、そうすべきではないにもかかわらず、何らかの理由で node_modules の型定義で何かを行うためです。
私の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/"
}
};
私のエントリポイント (source/index.tsx) - 基本的に何もありません:
console.log("Test");
それが私に与えるエラー(短縮、それらはすべて似ています):
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'.