Skip to content

Commit 3fcd172

Browse files
chargomeclaude
andcommitted
test(remix): Assert no source map survives the build
Remix runs a client and an SSR pass with different `outDir`s while the deletion glob is held in a promise that settles once, so one pass can be left behind. Walking the whole build output catches that, which the upload assertions cannot. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent cc53fda commit 3fcd172

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

‎dev-packages/e2e-tests/test-applications/remix-sourcemaps/assert-build.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as fs from 'fs';
33
import * as path from 'path';
44
import { getArtifactBundles, getDebugIdPairs, getSourcemaps, loadMockServerResults } from '@sentry-internal/test-utils';
55

6+
const BUILD_DIR = 'build';
67
const CLIENT_ASSETS_DIR = 'build/client/assets';
78

89
// Both injectors write this assignment, so counting it per file counts injections regardless of
@@ -96,4 +97,32 @@ assert.ok(
9697
);
9798
console.log(`${crossCheckedChunks} chunk(s) ship a debug ID that was uploaded\n`);
9899

100+
// 4. No source map survived the build.
101+
//
102+
// The plugin defaults `filesToDeleteAfterUpload` when the app configures no source map setting, so
103+
// a leftover `.map` means one of the builds was never cleaned up. Remix runs a client and an SSR
104+
// pass with different `outDir`s, while the deletion glob is held in a promise that settles once -
105+
// this is what catches the second pass being left behind.
106+
function findSourceMaps(dir: string): string[] {
107+
return fs.readdirSync(dir, { withFileTypes: true }).flatMap(entry => {
108+
const entryPath = path.join(dir, entry.name);
109+
110+
if (entry.isDirectory()) {
111+
return findSourceMaps(entryPath);
112+
}
113+
114+
return entry.name.endsWith('.map') ? [entryPath] : [];
115+
});
116+
}
117+
118+
const leftoverSourceMaps = findSourceMaps(BUILD_DIR);
119+
assert.deepEqual(
120+
leftoverSourceMaps,
121+
[],
122+
`Expected every source map to be deleted after upload, found ${leftoverSourceMaps.length}:\n${leftoverSourceMaps.join(
123+
'\n',
124+
)}`,
125+
);
126+
console.log('no source maps left in the build output\n');
127+
99128
console.log('All remix source map assertions passed!');

0 commit comments

Comments
 (0)