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

ref(nextjs): Extract isBuild into an exported function #5444

Merged
merged 2 commits into from Jul 26, 2022

Conversation

lobsterkatie
Copy link
Member

In nextjs hooks which run both during build- and runtime (like getStaticProps, which mostly is a build-time function, but will run at runtime if revalidation is turned on) it's sometimes helpful to know which you're in, and there's no official way to do that that I've been able to find. In our case, we need to know which phase we're in because by the time pages get loaded in order to be rendered during build, they already have a Sentry.init() call baked in, causing the SDK to run. Since certain operations can only happen at runtime, we have logic in index.server.ts to detect the current phase.

This pulls that logic into a utility function, so that it can be exported. (Ultimately this is a selfish change, as I'd like to be able to use isBuild in my test apps, but I figure it's a harmless addition which might help other developers, too.)

@lobsterkatie lobsterkatie requested a review from Lms24 July 21, 2022 18:50
@lobsterkatie lobsterkatie force-pushed the kmclb-nextjs-add-isBuild-function branch from ff2a4ee to 3c31f5b Compare July 25, 2022 21:20
@lobsterkatie lobsterkatie merged commit db9ab7c into master Jul 26, 2022
@lobsterkatie lobsterkatie deleted the kmclb-nextjs-add-isBuild-function branch July 26, 2022 01:13
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.

None yet

2 participants