Skip to content

About

Repro: Sentry reactComponentAnnotation drops source-map names

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

reactComponentAnnotation drops names from source maps

With reactComponentAnnotation on, @sentry/nextjs production source maps have no name on the mappings of minified function bindings in annotated files. Sentry reads that name to restore the original function name, so stack frames keep the minified name (n, a, i). Grouping uses function names, so one error can also split into a new issue on each release.

This happens with webpack and with Turbopack. With the option off, the same build keeps the names.

Run

npm install
npm run repro       # builds 4 times: webpack and Turbopack, annotation off and on
node transform.mjs  # runs the annotation transform directly

Result (@sentry/nextjs 11.19.0, next 16.4.6)

== next build --webpack, reactComponentAnnotation off
LoginButton    minified as o, mapping name: LoginButton
handleClick    minified as o, mapping name: handleClick
handleLogin    minified as n, mapping name: handleLogin
== next build --webpack, reactComponentAnnotation on
LoginButton    no mapping at the declaration
handleClick    no mapping at the declaration
handleLogin    minified as n, mapping name: null
== next build --turbopack, reactComponentAnnotation off
LoginButton    no mapping at the declaration
handleClick    minified as n, mapping name: handleClick
handleLogin    minified as a, mapping name: handleLogin
== next build --turbopack, reactComponentAnnotation on
LoginButton    no mapping at the declaration
handleClick    minified as a, mapping name: null
handleLogin    minified as i, mapping name: null
$ node transform.mjs
annotated: true
map.names: []

check-names.mjs reads every client chunk's source map. For each const declaration in app/login-button.tsx, it finds the mapping that points at the declared identifier and prints the minified binding and the mapping's name.

transform.mjs calls createComponentNameAnnotateHooks from @sentry/bundler-plugins/loader-utils, the transform that the Turbopack loader and the webpack plugin run. The transform edits the code with magic-string and returns generateMap({ hires: true }). That map has an empty names array. When the bundler composes it with the later SWC and minifier maps, the names are probably lost at this step.

About

Repro: Sentry reactComponentAnnotation drops source-map names

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages