Skip to content

feat(bundler-plugins): Inject installed module versions into server bundles - #26645

Open
sentry-junior[bot] wants to merge 4 commits into
developfrom
feat/bundler-plugins-inject-modules
Open

sentry-junior[bot] wants to merge 4 commits into
developfrom
feat/bundler-plugins-inject-modules

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

What

In server builds, the Sentry bundler plugins now replace the __SENTRY_SERVER_MODULES__ placeholder that modulesIntegration reads with the app's installed module versions. That way the integration can report exact versions when node_modules is missing or trimmed at runtime. A new injectModuleVersions option forces this with true or opts out with false.

  • Replacement is done the way each bundler already replaces values:
    • Vite and Rollup: the transform hook, only in modules that contain the placeholder.
    • webpack: DefinePlugin.
    • esbuild and Bun: define.
  • By default only server builds get the versions:
    • Vite environments with the server consumer, and SSR builds.
    • webpack node/async-node targets.
    • esbuild platform: 'node'.
    • Bun bun/node targets.
    • Plain Rollup cannot tell where its output runs, so it replaces the placeholder only with injectModuleVersions: true. Nuxt sets that for its Nitro build.
  • Next.js webpack builds drop their own DefinePlugin and rely on the plugin. Turbopack builds replace the placeholder through compiler.defineServer with the same resolver, instead of setting a global from instrumentation.ts. Next.js only accepts strings there, so Turbopack passes JSON, which modulesIntegration parses. The Node SDK no longer reads the global.
  • SvelteKit, Nuxt, SolidStart and Astro now add the plugin in production builds even when source maps are off. In that case they pass getDisabledSourcemapsOptions(), which turns off everything else: no source map upload or deletion, no debug IDs, no release creation or injection, and no telemetry.

Why

This computes the versions once, in one place, for every bundler instead of per framework.

Replacing the placeholder, instead of injecting a global, keeps the list in one spot: the bundled copy of the SDK's modules.js. That avoids putting a copy into every entry and needs no chunk placement logic. When the SDK stays external, which is the default for Vite SSR, SvelteKit and Astro on Node, nothing is replaced and the SDK resolves versions from node_modules at runtime as in #26637. node_modules is present in that setup anyway. Browser bundles never get the list unless someone forces it.

Notes:

  • The injected versions are authoritative at runtime. Since feat(node): Improve module detection in modulesIntegration #26637, modulesIntegration uses a non-empty __SENTRY_SERVER_MODULES__ as is and skips runtime resolution. Bundled apps therefore report the app's declared dependencies at their installed versions, without transitive packages from require.cache.
  • The modules-only mode for apps with source maps off is a stopgap. We need to revisit which plugin features should run there.
  • Dev builds still skip the plugin, in Next.js webpack and in the four frameworks above. Runtime resolution covers dev, since node_modules is present. Turbopack dev builds still get the versions through compiler.defineServer.
  • Vite before 6 has no environments, so the plugin falls back to the build.ssr flag there.

via @mydea.

--

View Session [Sentry]

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

size-limit report 📦

Compared: 5f4919a (PR test merge using develop at 5b76329)

Against: 2e525b2 (develop) · base run #67972

⚠️ Baseline mismatch: 2 develop commit(s) in the baseline are missing from the PR build. Their size changes also affect this comparison. Compare commits. Rebase your PR onto the latest develop to compare against an up-to-date baseline.

Path Size % Change Change
@sentry/browser 30.54 kB - -
@sentry/browser - with treeshaking flags 28.73 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 28.6 kB - -
@sentry/browser (incl. Tracing) 53.66 kB - -
@sentry/browser (incl. Tracing Core) 40.58 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 53.66 kB - -
@sentry/browser (incl. Tracing, Profiling) 56.56 kB - -
@sentry/browser (incl. Tracing, Replay) 93.59 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 82.38 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 98.42 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 111.39 kB - -
@sentry/browser (incl. Feedback) 48.4 kB - -
@sentry/browser (incl. sendFeedback) 31.11 kB - -
@sentry/browser (incl. FeedbackAsync) 36.16 kB - -
@sentry/browser (incl. Metrics) 31.86 kB - -
@sentry/browser (incl. Logs) 32.13 kB - -
@sentry/browser (incl. Metrics & Logs) 32.8 kB - -
@sentry/react 32.56 kB - -
@sentry/react (incl. Tracing) 56.37 kB - -
@sentry/vue 38.74 kB - -
@sentry/vue (incl. Tracing) 56.67 kB - -
@sentry/svelte 30.57 kB - -
@sentry/effect (client) 42.21 kB - -
@sentry/effect (client, incl. Tracing) 54.96 kB - -
@sentry/effect (client, incl. Tracing, Logs, Metrics) 66.31 kB - -
@sentry/remix (Remix 3 client bundle) 59.39 kB - -
CDN Bundle 32.38 kB - -
CDN Bundle (incl. Tracing) 54.04 kB - -
CDN Bundle (incl. Logs, Metrics) 35.13 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 56.5 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 76.08 kB - -
CDN Bundle (incl. Tracing, Replay) 91.84 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 94.37 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 97.31 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 99.78 kB - -
CDN Bundle - uncompressed 94.56 kB - -
CDN Bundle (incl. Tracing) - uncompressed 159.84 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 102.9 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 167.47 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 233.29 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 280.28 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 287.9 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 292.21 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 299.83 kB - -
@sentry/nextjs (client) 60.08 kB - -
@sentry/sveltekit (client) 55.02 kB - -
@sentry/core/server 46.39 kB +1.24% +566 B 🔺
@sentry/core/browser 14.46 kB - -
@sentry/node 156.94 kB -0.29% -441 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 83.45 kB - -
@sentry/node - without tracing 89.8 kB +0.02% +11 B 🔺
@sentry/node - without channel injection 145.9 kB -0.32% -459 B 🔽
@sentry/aws-serverless 100.44 kB +0.02% +16 B 🔺
@sentry/cloudflare (withSentry) - minified 211.91 kB - -
@sentry/cloudflare (withSentry) 491.68 kB - -
@sentry/cloudflare (withSentry, instrumented CommonJS package) - minified 214.86 kB - -
@sentry/nextjs/cloudflare (withSentry) - minified 237.15 kB - -

View base workflow run

@github-actions

Copy link
Copy Markdown
Contributor

One or more gzipped bundles increased by more than 500 bytes. If this increase is intentional, add the Accept Bundlesize Increase label to this PR to rerun and accept the check.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Optional E2E tests

Some optional checks were not successful. They do not block the merge. 23 not successful, 42 successful. See the run.

Check Status
❌ CI: Optional E2E Tests / E2E deno (latest) Test (optional) Failing after 42s Details
❌ CI: Optional E2E Tests / E2E gen-ai-libraries (latest) Test (optional) Failing after 4m Details
❌ CI: Optional E2E Tests / E2E nextjs-14-supabase Test (optional) Failing after 1m Details
❌ CI: Optional E2E Tests / E2E hono-5 (bun) Test (optional) Failing after 52s Details
❌ CI: Optional E2E Tests / E2E hono-5 Test (optional) Failing after 42s Details
❌ CI: Optional E2E Tests / E2E astro-7 (static trace lifecycle) Test (optional) Failing after 54s Details
❌ CI: Optional E2E Tests / E2E astro-7 Test (optional) Failing after 51s Details
❌ CI: Optional E2E Tests / E2E hapi-21 (bun) Test (optional) Failing after 1m Details
❌ CI: Optional E2E Tests / E2E hapi-21 (deno) Test (optional) Failing after 41s Details
❌ CI: Optional E2E Tests / E2E nextjs-15 (latest) Test (optional) Failing after 55s Details
❌ CI: Optional E2E Tests / E2E hono-5 (deno) Test (optional) Failing after 49s Details
❌ CI: Optional E2E Tests / E2E vinext-cf-workers (workers cache) Test (optional) Failing after 1m Details
❌ CI: Optional E2E Tests / E2E nextjs-16 (vinext) Test (optional) Failing after 57s Details
❌ CI: Optional E2E Tests / E2E nuxt-5 (kv-cache) Test (optional) Failing after 59s Details
❌ CI: Optional E2E Tests / E2E hono-5 (cloudflare) Test (optional) Failing after 43s Details
❌ CI: Optional E2E Tests / E2E nextjs-16 (vinext, bun) Test (optional) Failing after 45s Details
❌ CI: Optional E2E Tests / E2E nuxt-5 (cloudflare) Test (optional) Failing after 57s Details
❌ CI: Optional E2E Tests / E2E nextjs-16-tunnel (cloudflare) Test (optional) Failing after 49s Details
❌ CI: Optional E2E Tests / E2E nuxt-5 (bun) Test (optional) Failing after 50s Details
❌ CI: Optional E2E Tests / E2E nextjs-15 (turbo) Test (optional) Failing after 52s Details
❌ CI: Optional E2E Tests / E2E nuxt-5 (development) Test (optional) Failing after 54s Details
❌ CI: Optional E2E Tests / E2E nuxt-5 (deno) Test (optional) Failing after 47s Details
❌ CI: Optional E2E Tests / E2E nuxt-5 Test (optional) Failing after 46s Details
Successful checks
Check Status
✅ CI: Optional E2E Tests / E2E cloudflare-agent Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-pi-durable (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-tunnel Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 (manual upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-flue-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E solidstart-2-tunnel Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E react-router-7-framework-instrumentation Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 (no upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-without-tracing-send-to-sentry Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E react-send-to-sentry Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (static / nuxt generate) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E cloudflare-workers-send-to-sentry Test (optional) Successful in 3m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps (delete all) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve (orchestrion) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-tunnel (cloudflare) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-cloudflare Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps (manual upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E debug-id-sourcemaps Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E cloudflare-think (ai v6) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve (0.x) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-eve (content off) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-fastify-6 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry (static trace lifecycle) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v1 Test (optional) Successful in 57s Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-mcp-v2 (MCP SDK OpenTelemetry) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-pi-durable (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps kept) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-express-send-to-sentry Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E tanstackstart-react-sourcemaps (no upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E solidstart-2 (delete all) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (no upload) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-mastra (latest) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E node-openai-decisions (latest) Test (optional) Successful in 57s Details
✅ CI: Optional E2E Tests / E2E node-flue (latest) Test (optional) Successful in 2m Details
✅ CI: Optional E2E Tests / E2E nuxt-4-sourcemaps (Vite server) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E nuxt-5-sourcemaps (client source maps enabled by Sentry) Test (optional) Successful in 1m Details
✅ CI: Optional E2E Tests / E2E vue-3 (no Options API) Test (optional) Successful in 1m Details

@mydea

mydea commented Nov 20, 2026

Copy link
Copy Markdown
Member

The snippet goes into every initial chunk, so a Next server build with many entries repeats the JSON once per entry. That is server-only, but it adds size.

can we avoid this somehow?

Next.js webpack dev builds no longer get a build-time map, because the plugin doesn't run in dev. Runtime resolution covers dev, since node_modules is present.

seems fine to not have this in dev, as long as the fallback generally works there.

SvelteKit, Nuxt, SolidStart and Astro add the plugin only when source maps aren't disabled. With source maps off, those apps get no build-time versions. This PR doesn't change that wiring.

would it be hard to change that? seems like this should not be tied to sourcemaps, ideally.

Vite before 6 has no environments, so the plugin falls back to the build.ssr flag there.

makes sense.

@sentry-junior

sentry-junior Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

can we avoid this somehow?

Yes. Fixed in 88696af: entries that share a chunk now share one copy.

  • Webpack: the snippet goes only into chunks that hold a runtime. Next server pages all use the webpack-runtime / webpack-api-runtime runtime chunks, so a Next server build gets at most 2 copies instead of one per page.
  • Rollup/Vite: the plugin walks the chunk graph and greedily picks the chunks that the most entries load statically, until every entry loads one of them. With two entries that import a shared chunk, the only copy goes into the shared chunk. I checked this on Rollup and on Vite 8 (Rolldown).
  • esbuild: already used one inject stub, so with splitting the entries share it.
  • Bun: still a banner per output file. I noted that in the PR body.

would it be hard to change that? seems like this should not be tied to sourcemaps, ideally.

Not hard, but it's a wiring change in 4 frameworks, so I want to agree on the shape first. Today SvelteKit (autoUploadSourceMaps), Nuxt, SolidStart and Astro (sourcemaps.disable) skip the Sentry Vite plugin entirely when source maps are off. Two options:

  1. Small injection-only plugin. Export a lightweight plugin from @sentry/bundler-plugins/vite that only injects module versions: no release, no source maps, no telemetry. Each framework adds it when it skips the full plugin. My pick: it doesn't change what the full plugin does for people who turned source maps off.
  2. Always add the full plugin. With source maps off, frameworks add it with sourcemaps: { disable: true } and release: { create: false }. That's less new API, but release injection, telemetry and the other plugin features then run for apps that never had the plugin.

Should I go with 1 and add it to this PR, or do it in a follow-up?

The dev build and Vite < 6 fallbacks stay as they are; I moved them under "Notes" in the PR body.

@sentry-junior
sentry-junior Bot force-pushed the feat/bundler-plugins-inject-modules branch 2 times, most recently from 1985c72 to 7acb301 Compare November 20, 2026 09:02
@sentry-junior
sentry-junior Bot force-pushed the feat/modules-integration-installed-versions branch from 08bb207 to b4bcaf1 Compare November 20, 2026 09:06
@sentry-junior
sentry-junior Bot force-pushed the feat/bundler-plugins-inject-modules branch from 7acb301 to b006c9f Compare November 20, 2026 09:13
Comment thread packages/astro/src/integration/index.ts Resolved
@sentry-junior
sentry-junior Bot force-pushed the feat/bundler-plugins-inject-modules branch from b006c9f to d0b5bf9 Compare November 20, 2026 09:26
@sentry-junior
sentry-junior Bot force-pushed the feat/bundler-plugins-inject-modules branch 2 times, most recently from e9f9ee8 to dc440a7 Compare November 20, 2026 09:35
@sentry-junior
sentry-junior Bot force-pushed the feat/bundler-plugins-inject-modules branch from 1e067b7 to 489e0aa Compare November 20, 2026 10:36
@sentry-junior
sentry-junior Bot force-pushed the feat/modules-integration-installed-versions branch from abb9e9d to df50522 Compare November 23, 2026 09:13
@sentry-junior
sentry-junior Bot force-pushed the feat/bundler-plugins-inject-modules branch from 1d82887 to ada67ed Compare November 23, 2026 09:20
@sentry-junior
sentry-junior Bot force-pushed the feat/bundler-plugins-inject-modules branch from 9972bcc to 19de852 Compare November 23, 2026 09:35
@mydea

mydea commented Nov 23, 2026

Copy link
Copy Markdown
Member

why does this increase bundle size of node sdk so much? shouldn't be the case IMHO

@sentry-junior

sentry-junior Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

@mydea Almost all of it comes from #26637, not this PR. Size Check compares each PR against develop, not against its stack base, so #26645 shows the growth of the whole stack.

  • feat(node): Improve module detection in modulesIntegration #26637's own Size Check comment shows @sentry/node at +526 B (+568 B without tracing, +529 B for aws-serverless) against the same base run. That PR has the Accept Bundlesize Increase label, so it passes there.
  • This PR shows +543 B, so its own share is about +17 B. It comes from the only runtime change here: the typeof === 'string' / JSON.parse branch in getServerModules for Turbopack. Next.js runs every compiler.defineServer value through JSON.stringify (serializeDefineEnv in next/dist/build/define-env.js), so the value arrives as a JSON string. Everything else in this PR is bundler-plugins and framework build config, which doesn't end up in the Node SDK bundle.

Where #26637's ~500 B goes, measured minified + gzipped per file with esbuild:

gzip
old modules.ts on develop 858 B
new modules.ts (#26637) 436 B
new server-utils/src/utils/installedModules.ts (collectInstalledModules) 771 B

So the resolver that #26637 adds (find the app root, read package.json, resolve versions through node_modules, handle loadedFiles and collisions) is bigger than the code it replaces. Shrinking it would have to happen in installedModules.ts on #26637.

If you want this PR at +0, I can check whether Turbopack accepts the parsed object, by passing the object itself so Next.js's JSON.stringify turns it into an object literal. Then the JSON.parse branch can go. I haven't verified that Turbopack inlines object-valued defines, though, and that's why the global existed before (#19147).

Base automatically changed from feat/modules-integration-installed-versions to develop November 25, 2026 07:34
@sentry-junior
sentry-junior Bot force-pushed the feat/bundler-plugins-inject-modules branch from 19de852 to 785802e Compare November 25, 2026 07:43
@sentry-junior
sentry-junior Bot removed this pull request from stack #26646 November 25, 2026 07:44
console.log('Packing @sentry/core...');
execSync('pnpm run build:tarball', { cwd: coreDir, stdio: 'inherit' });

const serverUtilsDir = join(repoRoot, 'packages', 'server-utils');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we collapse the build steps into a single pnpm run build:dev:filter call?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in d239e5710c: one pnpm run build:dev:filter @sentry/core @sentry/server-utils @sentry/bundler-plugins call, then a loop packs the three packages.

describe('replaceBooleanFlagsInCode with server modules', () => {
const modules = { installed: '1.2.3' };

it('replaces the `__SENTRY_SERVER_MODULES__` placeholder', () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it feels kind of weird that this is part of repalceBooleanFlagsInCode, this is not a boolean flag?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Fixed in d239e5710c: replaceBooleanFlagsInCode is back to only replacing flags. The replacement itself moved to a generic replaceInCode(code, replacements). getBooleanFlagReplacements and getServerModulesReplacement build the entries, and the Rollup transform passes both to it.

function getServerModules(): Record<string, string> {
// webpack: the token is replaced with a literal at build time.
if (typeof __SENTRY_SERVER_MODULES__ !== 'undefined') {
if (typeof __SENTRY_SERVER_MODULES__ === 'undefined') {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm wait would that inline the whole object twice here? that seems non-ideal. can we do this in a way that the SENTRY_SERVER_MODULES only exists once and is replaced in a single place somehow, that would be cleaner imho.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it inlined the object two to three times: in the typeof check, the return, and the JSON branch. Fixed in d239e5710c: getServerModules now reads the placeholder once (serverModules = __SENTRY_SERVER_MODULES__) inside a try/catch. The catch covers builds that didn't replace it. Bundlers now inline the versions in exactly one place, and the built modules.js contains the placeholder once.

@mydea
mydea marked this pull request as ready for review November 25, 2026 10:36

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d239e57. Configure here.

@timfish

timfish commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

@sentry/bundler-plugins now depends on @sentry/server-utils. Each vite.config or webpack.config that loads the plugin now loads the whole server-utils barrel, and browser-only users install @opentelemetry/api and @sentry/conventions.

};

function isNodeTarget(target: string | string[] | false | undefined): boolean {
return (Array.isArray(target) ? target : [target]).some(t => typeof t === 'string' && /^(async-)?node/.test(t));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also matches node-webkit and misses electron-main

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 64de48d. isNodeTarget now matches whole target names: node[X[.Y]], async-node[X[.Y]] and electron[X[.Y]]-main. node-webkit/nwjs, electron-preload and electron-renderer no longer count as server builds. I didn't use externalsPresets.node, because webpack sets it for the Electron renderer and NW.js as well. The webpack test now covers each of these targets.

@timfish

timfish commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

This registers transform for every Vite build now, where before it only existed with flags or component annotation. On Rolldown that is a Rust-to-JS call per JS module, including client builds. Could we move the placeholder replacement to its own plugin object with filter: { id: JS_MODULE_ID_FILTER, code: SERVER_MODULES_PLACEHOLDER } and applyToEnvironment for server consumers? Then only the SDK's modules.js reaches the handler, and main keeps its old shouldTransform condition. The code.includes() check should stay for Rollup < 4.38 and Vite < 6.3, which ignore the filter.

@sentry-junior

sentry-junior Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@sentry/bundler-plugins now depends on @sentry/server-utils.

Fixed in 64de48d. collectInstalledModules has no imports, so I moved it to @sentry/core/server, which the bundler plugins already load. @sentry/node imports it from there too. The @sentry/server-utils dependency is gone, and so are the extra tarball and pnpm-workspace.yaml overrides in the bundler plugin integration tests. The function was only on develop (from #26637), so the @sentry/server-utils export is removed without a release in between.

@sentry-junior

sentry-junior Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

This registers transform for every Vite build now [...]

Done in 64de48d, as suggested. The replacement now lives in its own sentry-vite-module-versions / sentry-rollup-module-versions plugin:

  • transform has filter: { id: JS_MODULE_ID_FILTER, code: SERVER_MODULES_PLACEHOLDER }. The code.includes() check stays for Rollup < 4.38 and Vite < 6.3.
  • In Vite it sets applyToEnvironment for consumer === 'server'. With injectModuleVersions: true there's no applyToEnvironment, so the plugin applies everywhere. Vite < 6 still falls back to build.ssr.
  • The plugin is only added when injection can happen: by default for Vite, and only with injectModuleVersions: true for plain Rollup.
  • main uses its old shouldTransform condition (annotations or flags) again.

The SvelteKit and SolidStart plugin-list tests now include the new plugin name.

mydea added a commit that referenced this pull request Dec 1, 2026
## What

The size check on a stacked PR now compares against the size-limit
results of the PR it is stacked on, not against develop. Before this,
the base PR's own size changes showed up in every PR above it, as in
#26645.

- PR runs now upload their size-limit results too. Each artifact records
the commit that was measured. Older artifacts without that field still
work.
- When the merge base belongs to an open PR, the check waits up to 10
minutes for that PR's Size Check, then uses its results. If the base PR
still has no results, the check fails and asks for a re-run. It does not
fall back to develop, because that baseline would count the base PR's
changes. The job timeout goes from 15 to 25 minutes to cover the wait.
- The baseline counts as matching when the commits are equal or have the
same tree.

Stacked on #26778, which simplifies the
action without changing behavior.

## Why

With GitHub stacks, `base_ref` is `develop`, but the PR is tested on top
of its base PR's test merge commit. Only develop pushes uploaded
results, so the lookup fell back to the develop commit the stack started
from, and the comparison included every change in the base PR. So the
base PR is found from the test merge's parents, not from the branch
name. That covers both GitHub stacks and PRs that use another PR's
branch as their base.

Once this lands, PRs in a stack that's already open fail their size
check until the base PR's CI runs again and uploads its results.

<!-- junior-request-attribution:start -->
via @mydea.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC0C22CSDV6X%3A1795429503.948419 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/slack%3AC0C22CSDV6X%3A1795429503.948419)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC0C22CSDV6X%3A1795429503.948419/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Francesco Gringl-Novy <2411343+mydea@users.noreply.github.com>
sentry-junior Bot and others added 4 commits December 1, 2026 08:40
…undles

In server builds, the Sentry bundler plugins replace the
`__SENTRY_SERVER_MODULES__` placeholder that `modulesIntegration` reads
with the app's installed module versions, so the integration reports exact
versions when `node_modules` is missing or trimmed at runtime. A new
`injectModuleVersions` option forces this or opts out.

Next.js webpack builds drop their own DefinePlugin and Turbopack reuses the
shared resolver through `compiler.defineServer`. SvelteKit, Nuxt,
SolidStart and Astro add the plugin in production builds even when source
maps are off, with every other plugin feature disabled.

Co-Authored-By: Francesco Gringl-Novy <2411343+mydea@users.noreply.github.com>
…ction

- The Node SDK references `__SENTRY_SERVER_MODULES__` once, so bundlers
  inline the versions in one place instead of two or three.
- `replaceBooleanFlagsInCode` only replaces boolean flags again. The Rollup
  plugin replaces the flags and the placeholder with a generic
  `replaceInCode`.
- The bundler plugin integration test setup builds the three packed
  packages with one `build:dev:filter` call.

Co-Authored-By: Francesco Gringl-Novy <2411343+mydea@users.noreply.github.com>
…ection

- Move `collectInstalledModules` to `@sentry/core/server`, so
  `@sentry/bundler-plugins` no longer depends on `@sentry/server-utils` and
  its dependencies.
- Replace the placeholder in a separate `sentry-{vite,rollup}-module-versions`
  plugin with a `transform` filter on the placeholder and, in Vite,
  `applyToEnvironment` for server environments. The main plugin registers
  `transform` only for flags and component annotations again.
- Count webpack `node[X[.Y]]`, `async-node[X[.Y]]` and
  `electron[X[.Y]]-main` targets as server builds, and no longer match
  `node-webkit`.

Co-Authored-By: Francesco Gringl-Novy <2411343+mydea@users.noreply.github.com>
…ection

`compiler.defineServer` inlines `__SENTRY_SERVER_MODULES__`, so it uses
`stringifyForCodeInjection` like the other bundlers. The output is still
JSON, which `modulesIntegration` parses.

Co-Authored-By: Francesco Gringl-Novy <2411343+mydea@users.noreply.github.com>
@sentry-junior
sentry-junior Bot force-pushed the feat/bundler-plugins-inject-modules branch from 0c302d3 to e3a1c1c Compare December 1, 2026 08:48
export type { SqlDialect } from './utils/sql';
export { isBun, isCloudflareWorkers, isDeno } from './utils/runtime';
export { collectInstalledModules } from './utils/installedModules';
export { instrumentPostgresJsSql } from './integrations/postgresjs-wrapper';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the server-utils export breaks Deno SDK module linking

@sentry/deno still statically imports collectInstalledModules from @sentry/server-utils, which no longer exports it. Since the Deno SDK eagerly imports this integration, normal SDK entrypoints fail to link or build.

Evidence
  • packages/server-utils/src/exports.ts no longer exports collectInstalledModules, and the server-utils root re-exports that file.
  • packages/deno/src/integrations/modules.ts still imports and calls collectInstalledModules from @sentry/server-utils; no alternate export from that package root provides it.
  • packages/deno/src/sdk.ts eagerly imports modulesIntegration and includes it in the default integrations, making the missing named export reachable for standard Deno SDK use.

Identified by Warden · code-review · X3U-MLD

This branch has not been deployed

No deployments
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.

3 participants