Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,12 @@ for (const chunk of chunks) {
assert.ok(crossCheckedChunks > 0, 'Expected at least one uploaded chunk to cross-check debug IDs against');
console.log(`${crossCheckedChunks} chunk(s) ship a debug ID that was uploaded\n`);

const remainingClientMaps = fs
.readdirSync(CLIENT_ASSETS_DIR, { recursive: true })
.filter(file => file.endsWith('.map'));
assert.deepEqual(remainingClientMaps, [], 'Expected client source maps to be deleted after upload');

const remainingServerMaps = fs.readdirSync('build/server', { recursive: true }).filter(file => file.endsWith('.map'));
assert.ok(remainingServerMaps.length > 0, 'Expected server source maps outside the deletion pattern to be preserved');

console.log('All react-router source map assertions passed!');
1 change: 0 additions & 1 deletion packages/react-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
"@sentry/server-runtime-injection": "11.9.0",
"@sentry/server-utils": "11.9.0",
"@sentry/bundler-plugins": "11.9.0",
"glob": "^13.0.6",
"sentry": "^0.44.0"
},
"devDependencies": {
Expand Down
7 changes: 2 additions & 5 deletions packages/react-router/src/vite/buildEnd/handleOnBuildEnd.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { rm } from 'node:fs/promises';
import type { Config } from '@react-router/dev/config';
import { createSentrySDK } from 'sentry';
import { globFiles } from '@sentry/bundler-plugins/core';
import type { SentryVitePluginOptions } from '@sentry/bundler-plugins/vite';
import { glob } from 'glob';
import type { SentryReactRouterBuildOptions } from '../types';

type BuildEndHook = NonNullable<Config['buildEnd']>;
Expand Down Expand Up @@ -134,10 +134,7 @@ export const sentryOnBuildEnd: BuildEndHook = async ({ reactRouterConfig, viteCo
}
if (updatedFilesToDeleteAfterUpload) {
try {
const filePathsToDelete = await glob(updatedFilesToDeleteAfterUpload, {
absolute: true,
nodir: true,
});
const filePathsToDelete = await globFiles(updatedFilesToDeleteAfterUpload);
if (debug) {
filePathsToDelete.forEach(filePathToDelete => {
// eslint-disable-next-line no-console
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createSentrySDK } from 'sentry';
import { rm } from 'node:fs/promises';
import { glob } from 'glob';
import { globFiles } from '@sentry/bundler-plugins/core';
import type { ResolvedConfig } from 'vite';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { sentryOnBuildEnd } from '../../../src/vite/buildEnd/handleOnBuildEnd';
Expand All @@ -11,7 +11,7 @@ vi.mock('node:fs/promises', () => {
const rm = vi.fn().mockResolvedValue(undefined);
return { rm, default: { rm } };
});
vi.mock('glob');
vi.mock('@sentry/bundler-plugins/core', () => ({ globFiles: vi.fn() }));

type TestConfig = ResolvedConfig & {
sentryConfig: SentryReactRouterBuildOptions;
Expand Down Expand Up @@ -62,7 +62,7 @@ describe('sentryOnBuildEnd', () => {
vi.mocked(createSentrySDK)
.mockReset()
.mockReturnValue(mockSentrySdkInstance as unknown as ReturnType<typeof createSentrySDK>);
vi.mocked(glob).mockResolvedValue(['/build/file1.map', '/build/file2.map']);
vi.mocked(globFiles).mockResolvedValue(['/build/file1.map', '/build/file2.map']);
vi.mocked(rm).mockResolvedValue(undefined);
});

Expand Down Expand Up @@ -126,10 +126,7 @@ describe('sentryOnBuildEnd', () => {
directory: '/build',
release: '1.2.3',
});
expect(glob).toHaveBeenCalledWith(['./build/custom/**/*.map'], {
absolute: true,
nodir: true,
});
expect(globFiles).toHaveBeenCalledWith(['./build/custom/**/*.map']);
});

it('should upload source maps when enabled', async () => {
Expand Down Expand Up @@ -196,7 +193,7 @@ describe('sentryOnBuildEnd', () => {

expect(mockSentrySdkInstance.sourcemap.inject).not.toHaveBeenCalled();
expect(mockSentrySdkInstance.sourcemap.upload).not.toHaveBeenCalled();
expect(glob).not.toHaveBeenCalled();
expect(globFiles).not.toHaveBeenCalled();
expect(rm).not.toHaveBeenCalled();
});

Expand All @@ -219,7 +216,7 @@ describe('sentryOnBuildEnd', () => {

expect(mockSentrySdkInstance.sourcemap.inject).toHaveBeenCalledWith({ directory: '/build' });
expect(mockSentrySdkInstance.sourcemap.upload).not.toHaveBeenCalled();
expect(glob).not.toHaveBeenCalled();
expect(globFiles).not.toHaveBeenCalled();
});

it('should delete custom files after upload when specified', async () => {
Expand All @@ -239,10 +236,7 @@ describe('sentryOnBuildEnd', () => {
// @ts-expect-error - mocking the React config
await sentryOnBuildEnd(config);

expect(glob).toHaveBeenCalledWith('/custom/**/*.map', {
absolute: true,
nodir: true,
});
expect(globFiles).toHaveBeenCalledWith('/custom/**/*.map');
});

it('should handle errors during release creation gracefully', async () => {
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.