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

feat(nextjs): Inject user sentry config files at app startup via webpack #3463

Merged
merged 4 commits into from
Apr 27, 2021

Conversation

lobsterkatie
Copy link
Member

NB: Currently this branch is coming off of another branch (the one removing the plugin). Once that's merged, this can get rebased.

This PR replaces the functionality of the old on-init-server.js and on-init-client.js, which lived in the now-defunct plugin and served purely as an automatic way to call sentry.server.config.js and sentry.client.config.js (in which the SDK user puts their Sentry startup code (Sentry.init(), Sentry.configureScope(), etc)).

Instead of using the plugin hooks, it modifies the webpack config's entry entry, to inject sentry.server.config.js into pages/_document (which serves as the base of all SSR pages) and sentry.client.config.js into main, which is the base for all client-side JS. Hat tip to @kamilogorek for the implementation on which this is based.

TODO:

  • The current version of this code contains a hack (manually deleting the main.js entry of webpack.entry) because that was the only thing I could get to work to deal with all of the async/await/promise stuff happening. There are a number of lines of code commented out, alternate versions of various async lines, but no combination seemed to work. Very open to suggested fixes.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 27, 2021

size-limit report

Path Size
@sentry/browser - CDN Bundle (gzipped) 20.63 KB (-0.01% 🔽)
@sentry/browser - Webpack 21.5 KB (0%)
@sentry/react - Webpack 21.53 KB (0%)
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 27.92 KB (0%)

@HazAT HazAT marked this pull request as ready for review April 27, 2021 09:54
@HazAT HazAT requested a review from kamilogorek as a code owner April 27, 2021 09:54
@HazAT HazAT merged commit a5131a4 into kmclb-remove-nextjs-plugin Apr 27, 2021
@HazAT HazAT deleted the kmclb-next-js-inject-via-webpack branch April 27, 2021 09:59
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.

2 participants