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): Make Next.js types isomorphic #6707

Merged
merged 24 commits into from Jan 10, 2023

Conversation

lforst
Copy link
Member

@lforst lforst commented Jan 10, 2023

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.

Base automatically changed from lforst-refactor-proxy-loader to master January 10, 2023 15:14
@lforst lforst changed the title fix(nextjs): Make types isomorphic fix(nextjs): Make Next.js types isomorphic Jan 10, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jan 10, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.84 KB (-0.02% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 61.46 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.62 KB (+0.01% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 55 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 20.38 KB (0%)
@sentry/browser - Webpack (minified) 66.55 KB (0%)
@sentry/react - Webpack (gzipped + minified) 20.4 KB (-0.01% 🔽)
@sentry/nextjs Client - Webpack (gzipped + minified) 47.63 KB (-0.01% 🔽)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.82 KB (+0.02% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.25 KB (-0.02% 🔽)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 43.05 KB (-0.01% 🔽)
@sentry/replay - Webpack (gzipped + minified) 38.3 KB (0%)

@lforst lforst marked this pull request as ready for review January 10, 2023 15:46
import * as serverSdk from './server';

/** Initializes Sentry Next.js SDK */
export declare function init(options: Options | BrowserOptions | NodeOptions): void;
Copy link
Member

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?

Copy link
Member Author

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.

packages/nextjs/src/index.types.ts Show resolved Hide resolved
packages/nextjs/src/index.types.ts Show resolved Hide resolved
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.

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.

@@ -146,21 +140,16 @@ function addServerIntegrations(options: NextjsOptions): void {

// TODO (v8): Remove this
/**
* @deprecated Use the constant `IS_BUILD` instead.
* @deprecated
Copy link
Member

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

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 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.

@lforst lforst merged commit 59b0bf6 into master Jan 10, 2023
@lforst lforst deleted the lforst-refactor-nextjs-structure branch January 10, 2023 17:03
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.

Module '"@sentry/nextjs"' has no exported member 'BrowserTracing'.
3 participants