Hem*_*ari 8 javascript reactjs react-native webpack-4
我在生产中遇到错误.看起来它与uglisify Webpack插件有关我找不到解决方案来解决它.
Webpack配置:
const UglifyJSPlugin = require("uglifyjs-webpack-plugin");
module.exports = {
mode: "production",
entry: "./index.tsx",
resolve: {
extensions: [".js", ".tsx"]
},
module: {
rules: [
{
test: /\.tsx?$/,
use: {
loader: "ts-loader",
options: {
transpileOnly: true
}
}
}
]
},
optimization: {
minimizer: [new UglifyJSPlugin()]
}
};
Run Code Online (Sandbox Code Playgroud)
index.tsx
import * as React from 'react';
import * as ReactDOM from 'react-dom';
const TestComponent = () => {
React.useEffect(() => {});
return null;
};
ReactDOM.render(<TestComponent />, document.getElementById('app'));
Run Code Online (Sandbox Code Playgroud)
版本:
"react": "^16.7.0-alpha.0",
"react-dom": "^16.7.0-alpha.0",
"uglifyjs-webpack-plugin": "^2.0.1",
"webpack": "4.19.0",
"webpack-cli": "^3.1.2"
Run Code Online (Sandbox Code Playgroud)
错误:
React: Cannot set property 'lastEffect' of null
Run Code Online (Sandbox Code Playgroud)
Roh*_*har 10
这是由React 16.7.0-alpha中的uglifyjs-webpack-plugin版本2.0.1引起的,因为它打破了React的新钩子功能.
您可以尝试使用terser插件.这是链接:https: //github.com/webpack-contrib/terser-webpack-plugin
| 归档时间: |
|
| 查看次数: |
1193 次 |
| 最近记录: |