Skip to content

feat(bundler-plugins)!: Migrate from @sentry/cli to the sentry CLI SDK - #23398

Draft
JPeer264 wants to merge 1 commit into
developfrom
jp/cli-v3-migration
Draft

feat(bundler-plugins)!: Migrate from @sentry/cli to the sentry CLI SDK#23398
JPeer264 wants to merge 1 commit into
developfrom
jp/cli-v3-migration

Conversation

@JPeer264

@JPeer264 JPeer264 commented Aug 13, 2026

Copy link
Copy Markdown
Member

closes #18518
closes JS-1312

This PR is removing @sentry/cli in favor of sentry.

Following was done:

  • Using a SentryCliAdapter to make the usage a little bit more comfortable (especially around uploading sourcemaps for more projects)
  • I was in between mocking the CLI and not mocking the CLI, as it would increase the CI 4 times by just using the real CLI. So I kept a mock like we had before
  • Removed sentryCliBinaryExists, because there is no binary anymore

Clanker description:

Replace the @sentry/cli v2 binary wrapper with the programmatic SDK (createSentrySDK) exposed by the new sentry CLI package. A SentryCliAdapter in src/core/cli.ts maps the plugin's structured option shapes onto the SDK's typed methods, keeping all translation in one place:

  • release create/finalize/set-commits/deploy and sourcemap upload now go through the SDK instead of spawning the CLI binary; one SDK client is created per (options, project) pair since project selection is bound at client creation time
  • the integration-test fixtures replace the @sentry__cli.patch with a local sentry-stub fixture recording CLI invocations to sentry-cli-mock.json, so upload assertions no longer depend on the binary's internals
  • remix's release/sourcemap scripts and react-router's buildEnd hook are migrated to the same SDK
  • add a react-router-7-sourcemaps e2e test app covering the new upload path against a mock Sentry server

Requires sentry >= 0.41.0: earlier 0.x builds had a link-fatal named import of Node 22.15+ zstd builtins in the ESM entry, which crashed the whole module on Node 18/20.

@JPeer264 JPeer264 self-assigned this Aug 13, 2026
@linear-code

linear-code Bot commented Aug 13, 2026

Copy link
Copy Markdown

JS-1312

@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 30.3 kB - -
@sentry/browser - with treeshaking flags 28.47 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 26.81 kB - -
@sentry/browser (incl. Tracing) 48.58 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.59 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.46 kB - -
@sentry/browser (incl. Tracing, Replay) 87.98 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.36 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 92.7 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 105.39 kB - -
@sentry/browser (incl. Feedback) 47.65 kB - -
@sentry/browser (incl. sendFeedback) 35.13 kB - -
@sentry/browser (incl. FeedbackAsync) 40.28 kB - -
@sentry/browser (incl. Metrics) 31.24 kB - -
@sentry/browser (incl. Logs) 31.52 kB - -
@sentry/browser (incl. Metrics & Logs) 32.15 kB - -
@sentry/react 32.09 kB - -
@sentry/react (incl. Tracing) 50.77 kB - -
@sentry/vue 35.34 kB - -
@sentry/vue (incl. Tracing) 50.54 kB - -
@sentry/svelte 30.33 kB - -
CDN Bundle 31.61 kB - -
CDN Bundle (incl. Tracing) 48.9 kB - -
CDN Bundle (incl. Logs, Metrics) 33.8 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 50.82 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 74.31 kB - -
CDN Bundle (incl. Tracing, Replay) 86.48 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.31 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 92.19 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.12 kB - -
CDN Bundle - uncompressed 93.84 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.75 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.14 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 152.44 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 229.08 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.01 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 271.68 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.71 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 285.37 kB - -
@sentry/nextjs (client) 53.29 kB - -
@sentry/sveltekit (client) 49 kB - -
@sentry/core/server 65.38 kB - -
@sentry/core/browser 51.72 kB - -
@sentry/node 116.99 kB +0.01% +1 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 0 B added added
@sentry/node - without tracing 81.43 kB - -
@sentry/aws-serverless 90.92 kB - -
@sentry/cloudflare (withSentry) - minified 213.98 kB - -
@sentry/cloudflare (withSentry) 528.93 kB - -

View base workflow run

Replace the @sentry/cli v2 binary wrapper with the programmatic SDK
(createSentrySDK) exposed by the new sentry CLI package. A
SentryCliAdapter in src/core/cli.ts maps the plugin's structured option
shapes onto the SDK's typed methods, keeping all translation in one
place:

- release create/finalize/set-commits/deploy and sourcemap upload now
  go through the SDK instead of spawning the CLI binary; one SDK client
  is created per (options, project) pair since project selection is
  bound at client creation time
- the integration-test fixtures replace the @sentry__cli.patch with a
  local sentry-stub fixture recording CLI invocations to
  sentry-cli-mock.json, so upload assertions no longer depend on the
  binary's internals
- remix's release/sourcemap scripts and react-router's buildEnd hook
  are migrated to the same SDK
- add a react-router-7-sourcemaps e2e test app covering the new upload
  path against a mock Sentry server

Requires sentry >= 0.41.0: earlier 0.x builds had a link-fatal named
import of Node 22.15+ zstd builtins in the ESM entry, which crashed the
whole module on Node 18/20.

Co-Authored-By: Claude <noreply@anthropic.com>
@JPeer264
JPeer264 force-pushed the jp/cli-v3-migration branch from 6a8fbbe to ed29e44 Compare August 14, 2026 10:18
@JPeer264

Copy link
Copy Markdown
Member Author

This PR is currently blocked by getsentry/cli#1421

betegon pushed a commit to getsentry/cli that referenced this pull request Aug 14, 2026
I opened a PR that is using the new CLI instead of the old
`@sentry/cli@2`:
getsentry/sentry-javascript#23398

Some E2E tests failed with `TypeError: Bun.serve is not a function`,
because we actually check internally if `Bun` would be an option. With
that polyfill in this CLI this behavior is now forced, without Bun
actually being there. Idk why this actually exists, but exporting `Bun`
instead fixes it.

---

AI description:

The Node polyfills were installed with `globalThis.Bun = BunPolyfill`,
which broke consumers of the npm package in both directions.

Under Bun the global is readonly, so merely importing the package threw
"Attempted to assign to readonly property" and took the whole process
down. Under Node it left an object named `Bun` on the global, so
unrelated libraries that feature-detect `typeof Bun !== "undefined"`
took their Bun code path and called methods the polyfill does not
implement, failing with errors like "Bun.serve is not a function". Both
are reachable by anyone who merely depends on this package, since
importing it is enough.

The polyfills are already delivered through esbuild's `inject`, which
substitutes unbound identifiers with exported bindings, so exporting
`Bun` gives the bundle the same value lexically without touching the
global. The real Bun is preferred when present, so running under Bun
keeps the genuine implementation rather than shadowing it.

Verified by importing the built bundle in Node: `globalThis.Bun` stays
undefined, where it previously became an object whose `serve` and
`version` were missing.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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.

Update to Sentry CLI v4

1 participant