Repository navigation
Conversation
… CJS build of @sentry/server-utils
In a CommonJS instrumented module the injected snippet is
`require("@sentry/server-utils")`, which Vite resolved to the CJS build.
Vite 5 to 7 turned that build's `require("@sentry/core")` into a default
import of the external `@sentry/core`, which crashed the server at
startup. `resolveId` now maps the CJS entry to the ESM entry. On Vite 8
this also removes a second copy of `@sentry/core` from the bundle.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
JPeer264
marked this pull request as ready for review
October 14, 2026 12:04
JPeer264
requested review from
andreiborza,
isaacs,
mydea and
s1gr1d
and removed request for
a team,
isaacs and
mydea
October 14, 2026 12:04
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
closes #25339
closes JS-3931
Description
This makes the orchestrion Vite plugin bundle the ESM build of
@sentry/server-utils, also when an instrumented CommonJS module (for example Express'srouterormysql)require()s it. Vite 5 to 7 turned therequire("@sentry/core")of the CJS build into a default import of the external@sentry/core, which crashed the server at startup. This fixes it for every SDK that uses the plugin, not only React Router. On Vite 8, which did not crash, it also removes a second copy of@sentry/core.Reproduction: https://github.com/JPeer264/sentry-repros/tree/issue-25339
Resolution decisions
resolveIdmaps the resolvedbuild/cjs/index.jstobuild/esm/index.js. Resolving therequire()with import conditions also works, but then@rollup/plugin-commonjswarnsTHIS_RESOLVE_WITHOUT_OPTIONS.Test decisions
react-router-8-frameworknow depends on@sentry/coredirectly, so Vite keeps it external, as in a hoisted (npm) install. With pnpm's isolated layout, Vite bundled it and the crash did not happen. The alternative is a new e2e app with a hoisted install.