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

fix(nextjs): Differentiate between webpack 4 and 5 in server builds #3878

Merged
merged 2 commits into from Aug 18, 2021

Conversation

lobsterkatie
Copy link
Member

In order to cut down on the number of unnecessary files which get uploaded by the Sentry webpack plugin during nextjs builds, we're quite specific about which filepaths to scan. The change which introduced that specificity missed the fact that under webpack 4, .next/server/chunks is not generated. This leads the Sentry webpack plugin to throw an error when it tries to upload it, even though nothing is actually amiss.

This PR fixes that, by checking the webpack version before deciding which files to upload with the plugin.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 6, 2021

size-limit report

Path Size
@sentry/browser - CDN Bundle (gzipped) 21.57 KB (0%)
@sentry/browser - Webpack 22.57 KB (0%)
@sentry/react - Webpack 22.6 KB (0%)
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 28.99 KB (+0.01% 🔺)

Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I should have noticed this in the last PRs review


const isWebpack5 = webpack.version.startsWith('5');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we an use the webpack 5 check to simplify the logic on how we add entry points with addFileToExistingEntryPoint (instead of having the various if else conditions)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a bad idea, but once I sat down to try to do it, I realized that though knowing it's webpack 4 would narrow down the possible formats, knowing it's webpack 5 wouldn't, because it can take all of the webpack 4 formats along with its own new formats. So just because of webpack 5 I think we need all the if/elses. Unless you're seeing something I'm not?

In any case, I'm going to merge this and we can handle that, if we do, in a later PR.

packages/nextjs/test/config.test.ts Outdated Show resolved Hide resolved
@lobsterkatie lobsterkatie merged commit 8092194 into master Aug 18, 2021
@lobsterkatie lobsterkatie deleted the kmclb-nextjs-no-server-chunks-under-webpack-4 branch August 18, 2021 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants