ref(nextjs): Move config code to SDK and fix next
version bug
#3418
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.
Two changes here:
Cramer reported running into trouble because he hadn't specified the
next
version in his project'spackage.json
exactly, and as a result, the version we copy over to our plugin didn't match whatnext
was expecting. ('^10.1.3' didn't match ''10.1.3'
, and neither did10.x
.) To avoid such problems, the version number we copy over is now drawn from theversion
value innext
'spackage.json
rather than thedependencies.next
value in the project'spackage.json
.He also mentioned it would be nice to abstract away as much of the boilerplate config code as we could, and since this was something we as a team had already identified as something we'd like to do, I went ahead and did it. Also, in order for it to be possible to use SDK code in
next.config.js
(which is vanilla JS), it was necessary to add an ES5 build and amain
entry inpackage.json
.A word of caution when testing this - if you pull the branch and use your linked packages in a test app, it will fail, because the relative paths will anchor themselves in your repo rather than your test app. My solution has been to leave everything linked, and then
mv node_modules/@sentry node_modules/@sentry-linked && cp -r node_modules/@sentry-linked node_modules/@sentry
, which will create non-sym-linked versions of all of the packages. (Fun fact, usingDuplicate
in the Finder - I know, I know, it's sacrilege, but I got lazy - just gives you another set of sym-links, not a copy of those links' targets.)This PR is in coordination with this PR in the wizard and this commit in docs.