feat(bundler-plugins)!: Migrate from @sentry/cli to the sentry CLI SDK - #23398
feat(bundler-plugins)!: Migrate from @sentry/cli to the sentry CLI SDK#23398JPeer264 wants to merge 3 commits into
Conversation
size-limit report 📦
|
6091f43 to
6a8fbbe
Compare
6a8fbbe to
ed29e44
Compare
|
This PR is currently blocked by getsentry/cli#1421 |
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>
2ebc1d7 to
9093933
Compare
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>
The e2e workflow's Playwright setup runs for every test app and fails with exit 127 when the app cannot resolve @playwright/test, even for build-only apps that never launch a browser. react-router-sourcemaps carries the dependency for the same reason. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
0153d5f to
d67c502
Compare
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6ddfabf. Configure here.
| : ['.js', '.map', '.jsbundle', '.bundle'], | ||
| ignore: includeEntry.ignore ? arrayify(includeEntry.ignore) : undefined, | ||
| })), | ||
| ); |
There was a problem hiding this comment.
Legacy upload drops urlPrefix
High Severity
When mapping release.uploadLegacySourcemaps entries into upload targets, urlPrefix from each IncludeEntry is never forwarded, even though UploadTarget and sourcemap.upload support it. Legacy uploads that rely on a custom URL prefix will associate artifacts under the wrong paths in Sentry.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 6ddfabf. Configure here.
| project, | ||
| url: this.#options.url, | ||
| }); | ||
| } |
There was a problem hiding this comment.
Headers option no longer applied
High Severity
The public headers option is still normalized and documented, but SentryCliAdapter never forwards it when creating the CLI SDK client. Self-hosted setups that depend on custom auth headers (IAP, Cloudflare Access, etc.) will lose those headers on every CLI request.
Reviewed by Cursor Bugbot for commit 6ddfabf. Configure here.
| ext: includeEntry.ext | ||
| ? includeEntry.ext.map(extension => `.${extension.replace(/^\./, '')}`) | ||
| : ['.js', '.map', '.jsbundle', '.bundle'], | ||
| ignore: includeEntry.ignore ? arrayify(includeEntry.ignore) : undefined, |
There was a problem hiding this comment.
Legacy ignore default dropped
Medium Severity
IncludeEntry documents that ignore defaults to node_modules when unset, and inject still applies that default, but legacy sourcemap upload now passes undefined through and uploads without an ignore pattern. Builds that previously skipped node_modules can start uploading those files.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 6ddfabf. Configure here.


closes #18518
closes #18518
This PR is removing
@sentry/cliin favor ofsentry.Following was done:
SentryCliAdapterto make the usage a little bit more comfortable (especially around uploading sourcemaps for more projects).run()for therelease.deploycommand (this should be fixed with fix(sdk): pass each positional argument as its own argv token cli#1415)sentryCliBinaryExists, because there is no binary anymoreClanker 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:
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.