Repository navigation
feat(nitro): Support sourcemaps.upload, injectDebugIds and delete
#26584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2957e6c
feat(bundler-plugins): Add `sourcemaps.upload`, `injectDebugIds` and …
timfish 5a15a14
Merge branch 'develop' into feat/bundler-plugins-sourcemap-options
timfish d5200c0
ref(bundler-plugins): Tag unset source map options as `auto` in telem…
timfish a3aed62
feat(core): Add the new source map options to the shared build options
timfish bb2338e
feat(nitro): Support `sourcemaps.upload`, `injectDebugIds` and `delete`
timfish 36f613c
feat(core): Add the new source map options to the shared build options
timfish 53e6f3e
Merge branch 'feat/core-sourcemap-options' into feat/nitro-sourcemap-…
timfish 72be4b1
Merge remote-tracking branch 'origin/develop' into feat/nitro-sourcem…
timfish 4f129e7
fix(nitro): Create the release when the build has no source map files
timfish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| import type { Nitro } from 'nitro/types'; | ||
| import { beforeEach, describe, expect, it, vi } from 'vitest'; | ||
| import type { SentryNitroOptions } from '../src/config'; | ||
| import { setupSourceMaps } from '../src/sourceMaps'; | ||
|
|
||
| const manager = vi.hoisted(() => ({ | ||
| telemetry: { emitBundlerPluginExecutionSignal: vi.fn().mockResolvedValue(undefined) }, | ||
| createRelease: vi.fn().mockResolvedValue(undefined), | ||
| injectDebugIds: vi.fn().mockResolvedValue(undefined), | ||
| uploadSourcemaps: vi.fn().mockResolvedValue(undefined), | ||
| deleteArtifacts: vi.fn().mockResolvedValue(undefined), | ||
| })); | ||
|
|
||
| vi.mock('@sentry/bundler-plugins/core', () => ({ | ||
| createSentryBuildPluginManager: vi.fn(() => manager), | ||
| })); | ||
|
|
||
| /** Runs the `compiled` hook that `setupSourceMaps` registers, if any. */ | ||
| async function runBuild(options: SentryNitroOptions, sourcemap?: boolean | 'hidden' | 'inline'): Promise<boolean> { | ||
| const hooks: ((nitro: Nitro) => Promise<void>)[] = []; | ||
| const nitro = { | ||
| options: { dev: false, sourcemap, output: { serverDir: '/output/server' } }, | ||
| hooks: { hook: (_name: string, hook: (nitro: Nitro) => Promise<void>) => hooks.push(hook) }, | ||
| } as unknown as Nitro; | ||
|
|
||
| setupSourceMaps(nitro, options, true); | ||
| await Promise.all(hooks.map(hook => hook(nitro))); | ||
| return hooks.length > 0; | ||
| } | ||
|
|
||
| describe('the `compiled` hook', () => { | ||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| }); | ||
|
|
||
| it('uploads and deletes by default', async () => { | ||
| await runBuild({}); | ||
|
|
||
| expect(manager.createRelease).toHaveBeenCalledTimes(1); | ||
| expect(manager.injectDebugIds).toHaveBeenCalledWith(['/output/server']); | ||
| expect(manager.uploadSourcemaps).toHaveBeenCalledTimes(1); | ||
| expect(manager.deleteArtifacts).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| it.each([{ upload: false }, { injectDebugIds: false }, { disable: 'disable-upload' }] as const)( | ||
| 'creates the release but uploads and deletes nothing with %j', | ||
| async sourcemaps => { | ||
| await runBuild({ sourcemaps }); | ||
|
|
||
| expect(manager.createRelease).toHaveBeenCalledTimes(1); | ||
| expect(manager.uploadSourcemaps).not.toHaveBeenCalled(); | ||
| expect(manager.deleteArtifacts).not.toHaveBeenCalled(); | ||
| }, | ||
| ); | ||
|
|
||
| it('deletes without an upload with `delete: true`', async () => { | ||
| await runBuild({ sourcemaps: { upload: false, delete: true } }); | ||
|
|
||
| expect(manager.uploadSourcemaps).not.toHaveBeenCalled(); | ||
| expect(manager.deleteArtifacts).toHaveBeenCalledTimes(1); | ||
| }); | ||
|
|
||
| // Nitro resolves an unset `sourcemap` to `false`, so this is also `upload: false` without a source map setting. | ||
| it.each([ | ||
| [{}, false], | ||
| [{ upload: false }, false], | ||
| [{ upload: false, delete: true }, false], | ||
| [{}, 'inline'], | ||
| ] as const)( | ||
| 'creates the release but skips the source map steps with %j and `sourcemap: %s`', | ||
| async (sourcemaps, sourcemap) => { | ||
| await runBuild({ sourcemaps }, sourcemap); | ||
|
|
||
| expect(manager.createRelease).toHaveBeenCalledTimes(1); | ||
| expect(manager.injectDebugIds).not.toHaveBeenCalled(); | ||
| expect(manager.uploadSourcemaps).not.toHaveBeenCalled(); | ||
| expect(manager.deleteArtifacts).not.toHaveBeenCalled(); | ||
| }, | ||
| ); | ||
|
|
||
| it('does not run with `disable: true`', async () => { | ||
| await expect(runBuild({ sourcemaps: { disable: true } })).resolves.toBe(false); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feat PR lacks integration tests
Medium Severity
This feat PR only adds mocked unit tests for
sourcemaps.upload,injectDebugIds, anddelete. The testing conventions for feat PRs require at least one integration or E2E test; the existingnitro-3E2E app does not cover source maps. Flagged because that requirement is in the review rules. The SolidStart follow-up does not say it will add this coverage.Additional Locations (1)
packages/nitro/test/sourceMaps.test.ts#L268-L326Triggered by project rule: PR Review Guidelines for Cursor Bot
Reviewed by Cursor Bugbot for commit 72be4b1. Configure here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
solidstart-2E2E app covers this end to end in #26335, which sits on this PR: its "no upload", "manual upload" and "delete all" variants run the Nitro server source map handling.