我正在使用webpack捆绑我的所有代码。
const path = require('path');
module.exports = {
entry: './index.ts',
mode: 'production',
target: 'node',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
}
]
},//https://github.com/webpack/webpack/issues/5703#issuecomment-357512412
resolve: {
extensions: ['.tsx', '.ts', '.js'],
alias: {
// from https://github.com/NodeRedis/node_redis/issues/790
'hiredis': path.join(__dirname, 'hack/hiredis.js')
}
},
output: {
filename: './bundle.js',
path: path.resolve(__dirname)
}
};
您可以在
中找到两个代码代码很简单。
https://gist.github.com/iamwwc/84c5836036ded93728542883b9650877
我的问题是
当我运行第一个代码时。
它可以正常工作
但是如果我运行第二个uglify js代码。它将抛出Class constructor cannot be invoked without 'new'
异常
为什么会有不同的结果。唯一的区别是第一个代码已格式化