-
Notifications
You must be signed in to change notification settings - Fork 15
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
errored out during transformation TypeError: /PROJECT/pages/404.js: Cannot read property 'constant' of undefined #7
Comments
Hiya - try passing webpack: config => {
config.plugins.push(new OptimizePlugin({ modernize: false }));
return config;
}, That should perhaps be the default, since it's very much a thing that can break. FWIW Next.js has its own way of generating modern + legacy output, and I'm not sure this plugin will do a better job of it. I believe you can enable it by doing: module.exports = {
experimental: {
modern: true,
}
}; |
@developit I faced a similar issue in a normal webpack app. The errors I was getting were this plus many others like:
Then I used
|
@mohsinulhaq what version of Webpack are you using? |
@developit - Is this supposed to work on Webpack versions < 5 ? |
Yes - I haven't tested it on Webpack 5+. I'm thinking the issue here is related to Webpack output options folks have configured - |
Hey,
after applying
|
@Super-Fly unfortunately that error message only tells me that webpack failed to complete successfully (the stack trace is just from |
ah @developit I had to remove the changes that I made to test the plugin and now when I applied them again, it worked ... sorry for bothering you. btw the difference that we received in bundles are those: Bundles without the plugin - 3.8 mb total this is the plugin config
|
@Super-Fly hmm - those numbers mean something is misconfigured. Are you running babel-loader or transpiling typescript? Need to remove babel-loader to use this. |
Hi there 👋
I ran into this issue when adding optimize-plugin to my nextjs project.
babel.rc
package.json
next.config.js
Any idea?
The text was updated successfully, but these errors were encountered: