Skip to content

fix(server-utils): Stop the orchestrion Vite plugin from bundling the CJS build of @sentry/server-utils - #25359

Merged
JPeer264 merged 1 commit into
developfrom
jp/react-router-orchestrion-core-default-import
Oct 19, 2026
Merged

JPeer264 merged 1 commit into
developfrom
jp/react-router-orchestrion-core-default-import

Conversation

@JPeer264

Copy link
Copy Markdown
Member

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's router or mysql) require()s it. Vite 5 to 7 turned the require("@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

resolveId maps the resolved build/cjs/index.js to build/esm/index.js. Resolving the require() with import conditions also works, but then @rollup/plugin-commonjs warns THIS_RESOLVE_WITHOUT_OPTIONS.

Test decisions

react-router-8-framework now depends on @sentry/core directly, 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.

… 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>
@linear-code

linear-code Bot commented Oct 14, 2026

Copy link
Copy Markdown

JS-3931

@JPeer264 JPeer264 self-assigned this Oct 14, 2026
@JPeer264
JPeer264 marked this pull request as ready for review October 14, 2026 12:04
@JPeer264
JPeer264 requested a review from a team as a code owner October 14, 2026 12:04
@JPeer264
JPeer264 requested review from andreiborza, isaacs, mydea and s1gr1d and removed request for a team, isaacs and mydea October 14, 2026 12:04
@s1gr1d
s1gr1d added this pull request to stack #25525 October 19, 2026 13:34
@JPeer264
JPeer264 merged commit e1d4c42 into develop Oct 19, 2026
294 checks passed
@JPeer264
JPeer264 deleted the jp/react-router-orchestrion-core-default-import branch October 19, 2026 16:07
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.

@sentry/react-router 11: build-time instrumentation inlines CommonJS that default-imports @sentry/core; server crashes at startup

2 participants