typescript - 生产模式下的 webpack 4 无法编译打字稿
问题描述
按照自述文件从 webpack 3 迁移到 webpack 4 之后
将 webpack 设置为时,我的 typescript 应用程序出现复杂错误mode: production
错误:
Uncaught TypeError: Object(...) is not a function
at Object.822 (Tag.tsx:65)
映射到这一行:
withExpertFeed(({removeAttribute}) => ({removeAttribute})),
这个 webpack 配置有效:
module.exports = merge(common(), {
devtool: 'source-map',
mode: 'development', // Set to development
plugins: [
}),
new CopyWebpackPlugin([{
from: 'public',
}, ]),
new ForkTsCheckerWebpackPlugin({
checkSyntacticErrors: false,
tsconfig: '../web-tsconfig.json',
}),
new HtmlWebpackPlugin({
inject: true,
template: path.resolve(__dirname, 'public/index.html'),
filename: 'index.html',
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true,
},
}),
],
optimization: {
minimizer: [
new UglifyJSPlugin({
uglifyOptions: {
output: {
ascii_only: true,
},
},
parallel: true,
cache: true,
sourceMap: true
}),
]
}
});
我设置时相同的 webpack 配置mode: production
失败并出现上述错误
解决方案
推荐阅读
- swift - Xcode 10.1 上的“错误:不能 IRGen 表达式,没有其他错误”的解决方案是什么?
- apache-flink - Flink中的标点与周期性水印?
- php - PHP中的头函数运行顺序
- c++ - 背诵和提示输出对齐C++,输出格式
- typescript - 打字稿无法从导入的构造函数中找到名称
- python - 如何在 SQLAlchemy column_property 上创建索引?
- c# - ASP.NET 网站部署,但只有我能看到
- python - 将代理图例句柄添加到现有图例
- javascript - Vuex 计算属性不更新 v-show
- lightgbm - LightGBM 2.2.4、Boost 1.64.0 on Power9 w/GPU 的构建问题