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): Make Next.js types isomorphic #6707
Conversation
size-limit report 📦
|
import * as serverSdk from './server'; | ||
|
||
/** Initializes Sentry Next.js SDK */ | ||
export declare function init(options: Options | BrowserOptions | NodeOptions): void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: Can this just be BrowserOptions | NodeOptions
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I would also do it that way but we defined it as such up until now and didn't want this PR to turn into a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the change! (Way cleaner than e.g. exporting Replay in the server index file) However, my only concern here is that this technically breaks people who (for whatever reason) use explicit path imports: import {...} from '@sentry/nextjs/index.client'
. We don't tell people to do this anywhere, so I'm fine with merging this anyway. Fwiw, this is the reason why we e.g. merged #4641 only in v7.
Let's chat about this with the team tomorrow and move forward with the decision.
packages/nextjs/src/server/index.ts
Outdated
@@ -146,21 +140,16 @@ function addServerIntegrations(options: NextjsOptions): void { | |||
|
|||
// TODO (v8): Remove this | |||
/** | |||
* @deprecated Use the constant `IS_BUILD` instead. | |||
* @deprecated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: Why remove the explanation here? This would show users instructions what to use instead in their IDE iirc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why or how this API got to the point that it was exported but IMO we shouldn't export this. It is completely unrelated to what Sentry is doing so I wouldn't tell users to use either isBuild
or IS_BUILD
.
I will move this change into a separate PR so that it appears in the changelog.
Fixes #4569
This PR moves around a bunch of code and files to better separate the runtime concern (browser, node, webpack config code, and in the future edge runtime code) in the Next.js SDK.
Additionally, we define a separate type-only entrypoint that makes the Next.js typings isomorphic, meaning users can (at least typing-wise) use all exports anywhere without getting typescript errors.