fix(nextjs): Move userNextConfig.sentry to closure#5473
Merged
Conversation
2 tasks
Lms24
approved these changes
Jul 27, 2022
9add59c to
b41e3cd
Compare
3 tasks
This was referenced Aug 2, 2022
lobsterkatie
added a commit
that referenced
this pull request
Aug 4, 2022
…5516) In the process of working simultaneously on both #5472 (which adds the `sentry.transpileClientSDK` option to `next.config.js`) and #5473 (which moves the `sentry` options object from `next.config.js` to a new location halfway through the build process, in order to prevent nextjs from throwing warnings), I missed their overlap. As a result, the `transpileClientSDK` option is still currently being retrieved from the old, pre-move location, even though said retrieval happens in the second half of the build, after the move. (Unsurprisingly, it's therefore always undefined, rendering it useless). This fixes that by pulling it from the new, correct location instead. It also adjusts our types so that future mistakes like this will show up as errors, by creating separate pre-move and post-move `userNextConfig` types and using them as appropriate. Fixes #5452.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
h/t to @mitchheddles for the research and initial idea - thanks!
As of vercel/next.js#38498, nextjs now warns (voluminously) if the config exported from
next.config.jscontains properties it doesn't recognize, including thesentryproperty we've been having people use to do things like disable the webpack plugin. In order to prevent these warnings, the final config returned fromwithSentryConfigmust not have such a property, so this deletes the property from theuserNextConfigobject before returning it.If we were to stop there, the warning would be gone, but so would the data
userNextConfig.sentrycontains. (This is true even if we runconstructWebpackConfigFunctionbefore doing the deletion, because the place we need theuserNextConfig.sentrydata is not inconstructWebpackConfigFunctionitself but in the function it returns. By the time that function is called by nextjs, the deletion will already have gone through and the data will be gone unless we keep a reference to it elsewhere.) Therefore, in order to allow the returned function to retain access theuserNextConfig.sentrydata, this captures it before it's deleted and passes it toconstructWebpackConfigFunction, where it lives in a closure around the returned function.fixes #5449