Repository navigation
Description
When a downstream bundler bundles @sentry/node (Next.js server build, serverless bundling, nitro/vite) and honours sideEffects: false, part of the orchestrion runtime transformer chain is deleted and part is kept. The kept parts seem to have no connection to whether the SDK needs it or not as the remaining code wouldn't execute safely.
It seems to be decided by whether each vendored CommonJS dependency writes exports.foo = ... or module.exports = ..., and this behavior was indicated by some experiments I was doing in rolldown which prompted me to check rollup behavior there as well. So seems like the UMD footer in esquery changes the tree-shaking decision taken in either bundlers, with rolldown being worse than rollup.
The result on develop today is that the parser parts (meriyah, source-map, and astring) are deleted while the selector matcher (esquery) is kept, even though the transformer calls both in the same function, so that could would actually throw if executed but it doesn't get executed.
In develop's bundled output, _virtual/meriyah.js looks like this
var meriyah = {};then you can see this in the output bundles:
code-transformer/lib/transformer.js uses both in the same code path:
const { parse } = meriyah; // meriyah is {} -> parse is undefined
// ...
esquery.traverse(ast, esquery.parse(query), ...) // esquery is presentI took a look at the chain and it is reachable from init():
@sentry/node/index.js
-> sdk/index.js
-> @sentry/server-utils/orchestrion/register (registerDiagnosticsChannelInjection)
-> @apm-js-collab/tracing-hooks
-> @apm-js-collab/code-transformer
-> meriyah, esquery, astring, source-map
is this intended?
I initially thought this might be intended as it could be needed for runtime import hooks but then the half shaken code wouldn't work from what I could tell.
AFAIK orchestrion works in two modes, bundled or runtime, so current state feels weird for both:
- deps the bundler inlined -> transformed at build time -> the runtime transformer is dead weight for those
- deps left external -> only the runtime hook can reach them -> the transformer must be present in the app but it is half shaken out
I created this repo to test this, it could be I'm missing something fundamental but as far as I can tell we have no tests covering bundled instrumentation emitting the telemetry expected.
Activity
linear-code commentedon Aug 26, 2026
JS-3449
feat(server-utils): Warn when the orchestrion runtime hook was bundled
feat(server-utils): Keep @sentry/node external in the vite orchestrio…
docs(node): Document keeping @sentry/server-utils external when bundling
feat(server-utils): Stay quiet when build-time instrumentation covers…
feat(server-utils): Warn when the orchestrion runtime hook was bundled
feat(server-utils): Keep @sentry/node external in the vite orchestrio…
docs(node): Document keeping @sentry/server-utils external when bundling
feat(server-utils): Stay quiet when build-time instrumentation covers…
feat(server-utils): Warn when the orchestrion runtime hook was bundled
feat(server-utils): Keep @sentry/node external in the vite orchestrio…
docs(node): Document keeping @sentry/server-utils external when bundling
feat(server-utils): Stay quiet when build-time instrumentation covers…
fix(node): Detect + warn when the orchestrion runtime hook is bundled (…
feat(server-utils): Warn when the orchestrion runtime hook was bundled
github-actions commentedon Sep 23, 2026
A PR closing this issue has just been released 🚀
This issue was referenced by PR #23675, which was included in the 11.0.0 release.