Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terser-webpack-plugin with Next.js + Webpack 4 #198

Closed
fatihtelis opened this issue Apr 10, 2021 · 3 comments
Closed

terser-webpack-plugin with Next.js + Webpack 4 #198

fatihtelis opened this issue Apr 10, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@fatihtelis
Copy link

Summary

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.

How To Reproduce

Steps to reproduce the behavior:

  1. Use next-pwa@5.2.9 which has a dependency for terser-webpack-plugin: "^5.1.1" (Only compatible with Webpack 5)
  2. Use next.js with Webpack 4
  3. Add a fallback page to pages/_offline.js
  4. Get error while building the app.
@fatihtelis fatihtelis added the bug Something isn't working label Apr 10, 2021
@shadowwalker
Copy link
Owner

shadowwalker commented Apr 10, 2021

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 terser-webpack-plugin@4.2.3 to mitigate the issue you have encountered?

@fatihtelis
Copy link
Author

I upgraded to Webpack 5. It is working properly now. Thanks for the reply @shadowwalker.

@quick007
Copy link

You now just use webpack5: true, in the nextjs config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants