I'm using Next.js with Webpack 4 and when I add a fallback page to pages/_offline, terser-webpack-plugin gives the error below:
TypeError: Cannot read property 'javascript' of undefined
at /Users/xxxxxxxxx/node_modules/terser-webpack-plugin/dist/index.js:572:38
I searched for the issue and terser-webpack-plugin@5+ is for Webpack 5 and is not compatible with Webpack 4.
Steps to reproduce the behavior:
Unfortunately this is a unsolvable problem, if I don't add terser-webpack-plugin as dependency in next-pwa. Other folks will see another build error.
Can you try to use {future: webpack5: true} in your project or try install the lower version of terser-webpack-plugin by yarn install [email protected] to mitigate the issue you have encountered?
I upgraded to Webpack 5. It is working properly now. Thanks for the reply @shadowwalker.