Repository navigation
feat(nextjs): Support sourcemaps.upload, injectDebugIds and delete - #26337
Conversation
size-limit report 📦Compared: 1ea02f0 (PR test merge using develop at 33ae1de) Against: 33ae1de (develop) · base run #67697 ✅ Baseline matches: this diff contains only this PR's changes.
|
Optional E2E testsSome optional checks were not successful. They do not block the merge. 2 not successful, 67 successful. See the run.
Successful checks
|
2de614c to
b5b1f4d
Compare
b5b1f4d to
7af6213
Compare
deleteSourcemapsAfterUpload…leteSourcemapsAfterUpload` The webpack client compiler no longer gets the `static/**/*.map` globs. It passes the SDK's `deleteSourcemapsAfterUpload` to the plugin instead, with `true` as the default. A user's own `filesToDeleteAfterUpload` is passed through and replaces this deletion, as before, so the plugin then gets `false`. Whenever the client deletes, it also passes `sdkEnabledSourceMaps`, so the plugin removes every JS and CSS map of the client build: those the SDK turned on and those the user turned on with `productionBrowserSourceMaps` or `devtool`, also of chunks outside the upload globs and also when no upload runs. Server and edge compilers get `false`, so their maps stay as before. Turbopack and `useRunAfterProductionCompileHook` builds keep the globs. The E2E apps now import a CSS file and also check `.next/static` for `sourceMappingURL` comments in JS and CSS.
7af6213 to
0cd6ffa
Compare
…etry An unset option sent the text "undefined" as its tag value. The telemetry snapshots of the integration tests now hold the three new tags.
…urcemaps-after-upload
sourcemaps.upload, injectDebugIds and delete
a3aed62 to
36f613c
Compare
…urcemaps-after-upload
…-sourcemaps-after-upload
| sourcemaps: { | ||
| disable: skipSourcemapsUpload ? true : (sentryBuildOptions.sourcemaps?.disable ?? false), | ||
| ...getSourceMapFeatureOptions(userSourcemaps, skipSourcemapsUpload), | ||
| // `sourcemaps.delete` does not reach the plugin, which would also remove the server source maps. |
There was a problem hiding this comment.
Since delete isn't forwarded, the plugin's conflict warnings never fire here: delete: false + filesToDeleteAfterUpload still deletes, and deleteSourcemapsAfterUpload is silently ignored when delete is set. Should we warn from the SDK, like we do for disable?
There was a problem hiding this comment.
Yes. #26626 moves those warnings into @sentry/core, and a follow-up PR calls them from the SDKs that don't forward delete once both land.
…emselves (#26787) #26626 added `warnOnConflictingSourceMapOptions`, but only the bundler plugin calls it, so it only warns about options that reach the plugin. React Router passes none of the user's source map options to the plugin, and SvelteKit, Nuxt and Nitro do not pass `sourcemaps.delete`. In these SDKs, `delete: false` with a user `filesToDeleteAfterUpload` still deletes the matched files, and nothing warns. These SDKs now call the warner with the user's options. Gatsby reads the flat `deleteSourcemapsAfterUpload`, so it logs its own warning when `sourcemaps.delete` is set next to it. The warner now logs each message once per process. Each plugin instance runs it, so Nuxt already printed some warnings twice (from the Vite plugin and the Nitro plugin), and the new SDK calls would add one more. Next.js has the same gap. I'll add it to #26337 so the two PRs don't conflict. No E2E changes. Unit tests cover the other call sites.
On webpack, the SDK no longer deletes client maps with its own
static/**/*.mapglobs. The client compiler passesdeleteSourcemapsAfterUploadandsdkEnabledSourceMapsto the bundler plugin. The plugin then removes every JS and CSS map of the client build, also when no upload runs. Server and edge maps stay. Turbopack anduseRunAfterProductionCompileHookkeep their globs.The SDK also supports
sourcemaps.upload,injectDebugIdsanddelete.deleteapplies to client maps only and keeps the Next.js default: client maps are removed on webpack, and on Turbopack when the SDK turned them on. Withupload: falseorinjectDebugIds: false, onlydelete: trueremoves maps. The plugin does not getdelete, because it would also remove the server maps. With the source map setting unset, Sentry turns on maps only when it uploads them or whendelete: falsekeeps them.Fixes:
sourceMappingURLcomments that point at missing files. The plugin switches them to hidden maps.Other behaviour changes:
afterEmit, so a plugin that reads them from disk after emit finds none.delete: true, a user'sfilesToDeleteAfterUploadruns next to the SDK's deletion. Withoutdelete, it still replaces it.withSentryConfigwarns about conflicting source map options, because the plugin does not getdeleteor the user'sdeleteSourcemapsAfterUpload.Still open:
useRunAfterProductionCompileHook: false, the SDK turns onproductionBrowserSourceMapsand nothing uploads or deletes them.devtool, because it cannot tell a user'sfalsefrom the Next.js default.rewriteSourcesandmoduleMetadataare never applied.E2E: the apps now include CSS and check for
sourceMappingURLcomments.nextjs-sourcemapsgets "delete option" and "manual upload" variants for Turbopack and webpack.