fix(nextjs): Make SDK multiplexer more resilient #6905
Merged
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.
https://github.com/getsentry/sentry-javascript/pull/6817/files#diff-5598248a0f2280565998f93876df482b2040cb761cc510b3bd2c4dfa5824dca8L103 seems to have broken the Next.js SDK multiplexer which is responsible for injecting the right SDK depending on whether the SDK is imported on browser/server/edge. It broke because it started stripping away the comment that told our loader to multiplex.
I suspected the comment was a little fragile from the beginning so let's make it a little bit more resilient by exporting a dummy const which is more or less guaranteed to be in the file to some extent. Maybe still not the optimal solution but better than the current one. The dummy export should not show up in types since the typing file we export doesn't actually point to the multiplexer files.
Oh, and we really need tests for middleware and edge routes. It was quite surprising that nothing caught this.