-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[Next] My webpack config is ignored since 7.22 #6339
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
Comments
Version 7.22.0 has lot of issues, my project can not finish build process. |
Hi, thanks for reporting this. Can you guys share your complete next configs? I have a suspicion that there are some compatibilities with other wrappers. |
// @ts-check
const withOptimizedImages = require('next-optimized-images');
const { withSentryConfig } = require('@sentry/nextjs');
const plugins = [
nextConfig =>
withOptimizedImages({
...nextConfig,
...{
handleImages: ['jpeg', 'png', 'webp', 'gif', 'ico'],
optimizeImagesInDev: true,
},
}),
withSentryConfig,
];
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
experimental: {
transpilePackages: ['react-syntax-highlighter', 'swagger-client', 'swagger-ui-react'],
},
// Disable sentry plugin
// https://github.com/getsentry/sentry-javascript/blob/115b0f3c07efa755c8f90d32cfd1783a35451eba/packages/nextjs/src/config/webpack.ts#L82-84
sentry: {
disableClientWebpackPlugin: true,
disableServerWebpackPlugin: true,
},
webpack(config, { dev }) {
console.log('hi');
return config;
},
};
module.exports = (phase, { defaultConfig }) => {
// Next complains about unsupported options from defaultConfig https://github.com/vercel/next.js/issues/39161
// Next complains about next-optimized-images options https://github.com/cyrilwanner/next-optimized-images/issues/285
return plugins.reduce((acc, plugin) => plugin(acc), { ...defaultConfig, ...nextConfig });
}; |
Quickly rewriting your config for you: // @ts-check
const withOptimizedImages = require('next-optimized-images');
const { withSentryConfig } = require('@sentry/nextjs');
const plugins = [
nextConfig =>
withOptimizedImages({
...nextConfig,
...{
handleImages: ['jpeg', 'png', 'webp', 'gif', 'ico'],
optimizeImagesInDev: true,
},
})
];
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
experimental: {
transpilePackages: ['react-syntax-highlighter', 'swagger-client', 'swagger-ui-react'],
},
// Disable sentry plugin
// https://github.com/getsentry/sentry-javascript/blob/115b0f3c07efa755c8f90d32cfd1783a35451eba/packages/nextjs/src/config/webpack.ts#L82-84
sentry: {
disableClientWebpackPlugin: true,
disableServerWebpackPlugin: true,
},
webpack(config, { dev }) {
console.log('hi');
return config;
},
};
module.exports = (phase, { defaultConfig }) => {
const sentrifiedConfig = withSentryConfig(nextConfig)(phase, { defaultConfig });
// Next complains about unsupported options from defaultConfig https://github.com/vercel/next.js/issues/39161
// Next complains about next-optimized-images options https://github.com/cyrilwanner/next-optimized-images/issues/285
return plugins.reduce((acc, plugin) => plugin(acc), { ...defaultConfig, ...sentrifiedConfig });
}; |
I'm experiencing a similar problem. I'm using svgr/webpack in my app, so the Next config I'm passing to
I believe that
|
That is unlikely since we're pretty careful about user-provided webpack functions here: https://github.com/getsentry/sentry-javascript/blob/master/packages/nextjs/src/config/webpack.ts#LL74 Can you share your nextjs config? If anything changed, it's what is returned by |
this works for me, thanks |
I handled the case where module.exports = (phase, { defaultConfig }) => {
// Next complains about unsupported options from defaultConfig https://github.com/vercel/next.js/issues/39161
// Next complains about next-optimized-images options https://github.com/cyrilwanner/next-optimized-images/issues/285
return plugins.reduce(
(config, plugin) => {
const appliedPlugin = plugin(config);
return typeof appliedPlugin === 'function'
? appliedPlugin(phase, { defaultConfig })
: appliedPlugin;
},
{ ...defaultConfig, ...nextConfig },
);
}; |
It still seems to be what's happening for us too, blocking us from upgrading the Sentry SDK to 7.22 or newer. The Next.js build outputs a lot of this:
followed by a lot of this:
The workaround that @simPod said worked for them (“Quickly rewriting your config for you”) might well work, but it makes the configuration quite different from the documented way to configure Sentry into So I think this breaking change still needs some attention. |
@gthb Can you share your entire
While I agree that this change still needs some attention, since we get a lot of similar issues at the moment, I disagree that this is breaking. Ideally we either adjust the docs, print some error in case the returned function is used as an object config or both. |
Sure — I have just emailed it to you privately (to the email address in your Github profile), just redacting a few constants with credentials in them.
Oh, by “breaking” I just mean that there exist apparently legitimate Sentry-Next.js setups which work with 7.21.0 but break when upgrading to 7.22.0, so they need to adapt in some way other than just bumping the version. I don't mean to imply anything about severity or importance. :) |
As a library maintainer, I am well aware of what breaking means. :) The change we did wasn't breaking in any of the word's meanings. All configurations that broke with the update weren't valid configurations in the first place. The docs instruct to put the Sentry plugin last - if this is not the case, it is not a problem with the library but rather misconfiguration. I am aware that you can't always put a plugin last (for example if two plugins tell you to do that) - actually the Sentry plugin doesn't even have to come last, we just tell you to do that to avoid running into the exact same issue we're facing here - libraries not respecting contractual boundaries. In the case of your config, you could have either put the Sentry plugin last, or used libraries that respect the fact that Next.js configs may export functions. (in your config for example, |
Haha, sorry about that :-) — it seemed like we were applying different meanings, because the change was clearly breaking under the assumption that my existing config was valid. But it was that assumption of mine which didn't hold. Thanks for that, and for the explanatory comments on Next.js config composition, that's exactly the understanding I was missing. |
Follow-up question: the |
Your assumption is correct. I deliberately left this return type broad so that we can go back to returning an object in future versions without requiring a major bump if we deem it necessary. |
Uh oh!
There was an error while loading. Please reload this page.
Is there an existing issue for this?
How do you use Sentry?
Self-hosted/on-premise
Which package are you using?
@sentry/nextjs
SDK Version
7.22.0
Framework Version
No response
Link to Sentry event
No response
Steps to Reproduce
I believe it has something to do with
#6291
Have a custom webpack config:
Expected Result
Echoes "hi" since it's picked up by Next
Actual Result
My webpack config is ignored
The text was updated successfully, but these errors were encountered: