Title: orchestrion deps are partially tree-shaken · Issue #23664 · getsentry/sentry-javascript · GitHub
Open Graph Title: orchestrion deps are partially tree-shaken · Issue #23664 · getsentry/sentry-javascript
X Title: orchestrion deps are partially tree-shaken · Issue #23664 · getsentry/sentry-javascript
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 ...
Open Graph 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 a...
X 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 a...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/23664
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"orchestrion deps are partially tree-shaken","articleBody":"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.\n\nIt 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.\n\nThe 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.\n\nIn `develop`'s bundled output, `_virtual/meriyah.js` looks like this\n\n```js\nvar meriyah = {};\n```\n\nthen you can see this in the output bundles:\n\n`code-transformer/lib/transformer.js` uses both in the same code path:\n\n```js\nconst { parse } = meriyah; // meriyah is {} -> parse is undefined\n// ...\nesquery.traverse(ast, esquery.parse(query), ...) // esquery is present\n```\n\nI took a look at the chain and it is reachable from `init()`:\n\n```\n@sentry/node/index.js\n -> sdk/index.js\n -> @sentry/server-utils/orchestrion/register (registerDiagnosticsChannelInjection)\n -> @apm-js-collab/tracing-hooks\n -> @apm-js-collab/code-transformer\n -> meriyah, esquery, astring, source-map\n```\n\n### is this intended?\n\nI 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.\n\nAFAIK orchestrion works in two modes, bundled or runtime, so current state feels weird for both:\n\n- deps the bundler inlined -> transformed at build time -> the runtime transformer is dead weight for those\n- deps left external -> only the runtime hook can reach them -> the transformer must be present in the app but it is half shaken out\n\nI 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.\n\nhttps://github.com/logaretm/orchestrion-treeshake-repro","author":{"url":"https://github.com/logaretm","@type":"Person","name":"logaretm"},"datePublished":"2026-08-26T18:39:38Z","url":"https://github.com/getsentry/sentry-javascript/issues/23664"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9805ea44-c969-33a6-0a60-23c7c11f55fd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E1B0:2FF40E:83CC64:B909BF:6B0480ED |
| html-safe-nonce | a1c55acddb6c61dbb502e314c7676e2af06169c1947f90a184663950387f076c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMUIwOjJGRjQwRTo4M0NDNjQ6QjkwOUJGOjZCMDQ4MEVEIiwidmlzaXRvcl9pZCI6IjEyNjI2Mjk5MTMzMzMzNjcwMjEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 50a1aef47d57dba36ec94b3d2d45ad324fe3fb62aca1c65ae82da4330366f1f5 |
| hovercard-subject-tag | issue:5260321802 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/23664/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6fdba915011dc13ef0cf073cebe7ba51a492774425deb98d42ea7b9f07bfbd62/getsentry/sentry-javascript/issues/23664 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6fdba915011dc13ef0cf073cebe7ba51a492774425deb98d42ea7b9f07bfbd62/getsentry/sentry-javascript/issues/23664 |
| og:image:alt | 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 a... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | logaretm |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0366ddfb372682a32e92a5d86155cb08fa83e5bbe79953a968789f2f7e24c511 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ed3f2e01f6b7672780c586c8af0e72726374d7b6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width