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): Pull transpileClientSDK option from correct location #5516

Merged

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Aug 3, 2022

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.

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

LGTM once tests pass


// Next 12.2.3+ warns about non-canonical properties on `userNextConfig`, so grab and then remove the `sentry`
// property there. Where we actually need it is in the webpack config function we're going to create, so pass it
// to `constructWebpackConfigFunction` so that it will be in the created function's closure.
const { sentry: userSentryOptions } = userNextConfigObject;
delete userNextConfigObject.sentry;
// Remind TS that there's now no `sentry` property
userNextConfigObject = userNextConfigObject as NextConfigObject;
Copy link
Member

Choose a reason for hiding this comment

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

can't we just do ...(userNextConfigObject as NextConfigObject)? I'd rather not change from const -> let

we can also just declare a new var - modifiedUserNextConfigObject?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd rather not change from const -> let

Why?

(FYI: I'm going to merge this regardless, because I'd like to get this bugfix out, but we can always revisit it later.)

@lobsterkatie lobsterkatie force-pushed the kmclb-nextjs-fix-missed-sentry-options-closure-conversion branch from 990361f to 4481089 Compare August 3, 2022 22:52
@lobsterkatie lobsterkatie merged commit 78395c6 into master Aug 4, 2022
@lobsterkatie lobsterkatie deleted the kmclb-nextjs-fix-missed-sentry-options-closure-conversion branch August 4, 2022 05:51
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.

No fetch calls on Edge 16/17/18 or iOS10 after transpiling to esmodules
3 participants