Title: @sentry/sveltekit: server entry statically re-exports the Vite plugin, pulling @babel/core into the runtime module graph · Issue #23243 · getsentry/sentry-javascript · GitHub
Open Graph Title: @sentry/sveltekit: server entry statically re-exports the Vite plugin, pulling @babel/core into the runtime module graph · Issue #23243 · getsentry/sentry-javascript
X Title: @sentry/sveltekit: server entry statically re-exports the Vite plugin, pulling @babel/core into the runtime module graph · Issue #23243 · getsentry/sentry-javascript
Description: Summary @sentry/sveltekit's server entry point statically re-exports the Vite build plugin, so importing the SDK in server code instantiates and evaluates the entire build-time module graph — including @babel/core and ~200 of its files. ...
Open Graph Description: Summary @sentry/sveltekit's server entry point statically re-exports the Vite build plugin, so importing the SDK in server code instantiates and evaluates the entire build-time module graph — inclu...
X Description: Summary @sentry/sveltekit's server entry point statically re-exports the Vite build plugin, so importing the SDK in server code instantiates and evaluates the entire build-time module graph — i...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/23243
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"@sentry/sveltekit: server entry statically re-exports the Vite plugin, pulling @babel/core into the runtime module graph","articleBody":"## Summary\n\n`@sentry/sveltekit`'s **server** entry point statically re-exports the Vite build plugin, so importing the SDK in server code instantiates and evaluates the entire build-time module graph — including `@babel/core` and ~200 of its files.\n\nThis is deliberately *not* a request to move `@sentry/vite-plugin` out of `dependencies` — I've read getsentry/sentry-javascript#19360 and [#18215](\u003chttps://github.com/getsentry/sentry-javascript/issues/18215>) and understand the one-package decision. This is the narrower follow-up to what @Lms24 wrote in getsentry/sentry-javascript#19360:\n\n> Our Vite plugin should not be *used* at runtime and hence *not* be pulled into any JS bundles executed at runtime. If that's the case, it's likely a bug we need to fix.\n\nIt is pulled in, and the mechanism is a single static re-export.\n\n## The chain\n\n`build/esm/index.server.js:2` — the Node/`default` condition entry:\n\n```js\nexport { trackComponent } from './server/index.js';\nexport { sentrySvelteKit } from './vite/sentryVitePlugins.js'; // \u003c-- build plugin, from the runtime entry\nexport * from '@sentry/node';\n```\n\nFrom there every link is a top-level static ESM import:\n\n```\nbuild/esm/index.server.js:2 export { sentrySvelteKit } from './vite/sentryVitePlugins.js'\nbuild/esm/vite/sentryVitePlugins.js:7 import { makeCustomSentryVitePlugins } from './sourceMaps.js'\nbuild/esm/vite/sourceMaps.js:3 import { sentryVitePlugin } from '@sentry/vite-plugin'\n@sentry/vite-plugin index.mjs:3 import { sentryCliBinaryExists } from '@sentry/bundler-plugin-core'\n@sentry/bundler-plugin-core index.mjs:1 import { transformAsync } from '@babel/core'\n```\n\nBecause these are static re-exports rather than lazy imports, they are part of the module graph and get evaluated when the entry is evaluated — no call to `sentrySvelteKit()` required.\n\n## Measurement\n\nNode v24.15.0, macOS, pnpm 11.16.0, 3 runs each. `cjs` counts `require.cache` keys after the dynamic import resolves:\n\n\u003c!-- linear:table-colwidths:200,200,200,200 -->\n| import | time | CJS modules loaded | of which `@babel/*` |\n| -- | -- | -- | -- |\n| `@sentry/node` (ESM entry) | 2.8 – 3.2 s | 168 | 0 |\n| `@sentry/sveltekit` (server entry) | 4.0 – 5.0 s | 392 | **201** |\n\nRepro:\n\n```js\n// probe.mjs, run with: node probe.mjs\nimport { createRequire } from 'node:module';\nconst require = createRequire(process.cwd() + '/');\nawait import('@sentry/sveltekit');\nconst loaded = Object.keys(require.cache);\nconsole.log(loaded.length, loaded.filter((p) => p.includes('/@babel/')).length);\n// -> 392 201\n```\n\nThe absolute timings are from a laptop and won't transfer to a serverless runtime, but the module counts are deterministic.\n\n## Impact we observed\n\nWith `@sveltejs/adapter-vercel`, SvelteKit leaves `@sentry/sveltekit` unbundled in the server output — it survives as a single bare `from \"@sentry/sveltekit\"` import in the chunk our logger lives in, and the logger is imported by essentially every repository and service. `@vercel/nft` then traces that specifier and, because it traces files rather than symbols, copies the whole reachable graph into the serverless function:\n\n* **156 packages / 2,743 files / 22 MB** in a single `.func`, including `@babel/core`, `@babel/traverse`, `@babel/parser`, `@babel/generator`, `@babel/types`, `caniuse-lite` (via babel's `browserslist`), `acorn` and `@sentry/bundler-plugin-core`\n* those 201 Babel files are then loaded on every cold start, per the measurement above\n\nNote this is the outcome @Lms24 suggested in getsentry/sentry-javascript#19360 as the mitigation (\"use tools like `@vercel/nft` to prune your runtime node modules\") — nft is already what runs here, and it can't help, because the reachability is real rather than incidental.\n\n## Suggested fix\n\nMove `sentrySvelteKit` off the runtime entry, e.g. to a dedicated `@sentry/sveltekit/vite` export used from `vite.config.ts`. That keeps the one-package installation story intact (no new package to publish, no version-skew risk) while keeping the build plugin out of the runtime graph.\n\nIf a breaking change to the `.` export isn't desirable, exposing it via a lazy accessor rather than a static re-export would also break the static edge.\n\n## Environment\n\n* `@sentry/sveltekit` 10.69.0\n* `@sveltejs/kit` 2.70.2, `@sveltejs/adapter-vercel` 6.3.4, `svelte` 5.56.8, `vite` 8.2.0\n* Node v24.15.0, pnpm 11.16.0","author":{"url":"https://github.com/MathiasWP","@type":"Person","name":"MathiasWP"},"datePublished":"2026-08-10T15:25:35Z","url":"https://github.com/getsentry/sentry-javascript/issues/23243"}
| 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:45032a4e-705b-28bf-f743-8e182cd0e189 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E3BC:281ABB:416C2D:59FF73:6B046DEA |
| html-safe-nonce | bf69749d79e08dfa5428b3a3be156d15d3af20d38027e23b40826acea0d935b0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFM0JDOjI4MUFCQjo0MTZDMkQ6NTlGRjczOjZCMDQ2REVBIiwidmlzaXRvcl9pZCI6IjU3NTg3OTM2NzI0MTQyMjc5NDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 18caf31bef2b2b7bb0037e32c99cfb367f371a6818ecaf4685cfc32688768c3b |
| hovercard-subject-tag | issue:5111690580 |
| 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/23243/issue_layout |
| twitter:image | https://opengraph.githubassets.com/690c98adb160a733c5acad2a43ffaff805ca8ed26d7f328cb526ee63b92d718c/getsentry/sentry-javascript/issues/23243 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/690c98adb160a733c5acad2a43ffaff805ca8ed26d7f328cb526ee63b92d718c/getsentry/sentry-javascript/issues/23243 |
| og:image:alt | Summary @sentry/sveltekit's server entry point statically re-exports the Vite build plugin, so importing the SDK in server code instantiates and evaluates the entire build-time module graph — inclu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MathiasWP |
| hostname | github.com |
| expected-hostname | github.com |
| None | ae8802492f12d3ba4f6b0d814054e617a2a5616b6327bf8555c10cd5b0dc2a6f |
| 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 | cfb5f24c6e01d85f70804652a5107e5cac03a161 |
| 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