I am getting below error in production. Looks like it’s related to uglisify Webpack plugin I can’t find solution to resolve it.
Webpack config:
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()]
}
};
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'));
Versions:
"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"
Error:
React: Cannot set property 'lastEffect' of null
If you update to uglifyjs-webpack-plugin version 2.2.0 the problem is fixed.
This is caused by uglifyjs-webpack-plugin version 2.0.1 in React 16.7.0-alpha as it breaks the new hook feature of React.
You can try using the terser plugin. Here is the link: https://github.com/webpack-contrib/terser-webpack-plugin
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With