Skip to content

Commit 89fba5d

Browse files
roli-lpciclaude
authored andcommitted
chore(remix): replace glob with native recursive fs walk
Replaces the glob dependency with a simple recursive fs.readdirSync walk for finding .map files to delete after upload. Uses manual recursion instead of fs.readdirSync({recursive}) to avoid the Node 18.17-18.18 withFileTypes bug. Removes glob and its transitive dependencies (minimatch, brace-expansion, balanced-match, minipass, jackspeak, path-scurry, foreground-child). Also removes orphaned glob-related resolution overrides from the integration test package.json. Ref: #19447 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cac4c46 commit 89fba5d

3 files changed

Lines changed: 38 additions & 6 deletions

File tree

packages/remix/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
"@sentry/core": "10.45.0",
7373
"@sentry/node": "10.45.0",
7474
"@sentry/react": "10.45.0",
75-
"glob": "^13.0.6",
7675
"yargs": "^17.6.0"
7776
},
7877
"devDependencies": {

packages/remix/scripts/deleteSourcemaps.js

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,49 @@
22
const fs = require('fs');
33
const path = require('path');
44

5-
const { globSync } = require('glob');
5+
/**
6+
* Recursively walks a directory and returns relative paths of all files
7+
* matching the given extension.
8+
*
9+
* Uses manual recursion instead of `fs.readdirSync({ recursive: true, withFileTypes: true })`
10+
* to avoid a bug in Node 18.17–18.18 where `withFileTypes` returns incorrect `parentPath` values
11+
* when combined with `recursive: true`.
12+
*
13+
* @param {string} rootDir - The root directory to start walking from.
14+
* @param {string} extension - The file extension to match (e.g. '.map').
15+
* @returns {string[]} Relative file paths from rootDir.
16+
*/
17+
function walkDirectory(rootDir, extension) {
18+
const results = [];
19+
20+
function walk(dir) {
21+
let entries;
22+
try {
23+
entries = fs.readdirSync(dir, { withFileTypes: true });
24+
} catch {
25+
return;
26+
}
27+
28+
for (const entry of entries) {
29+
const fullPath = path.join(dir, entry.name);
30+
31+
if (entry.isDirectory()) {
32+
walk(fullPath);
33+
} else if (entry.name.endsWith(extension)) {
34+
results.push(path.relative(rootDir, fullPath));
35+
}
36+
}
37+
}
38+
39+
walk(rootDir);
40+
return results;
41+
}
642

743
function deleteSourcemaps(buildPath) {
844
console.info(`[sentry] Deleting sourcemaps from ${buildPath}`);
945

1046
// Delete all .map files in the build folder and its subfolders
11-
const mapFiles = globSync('**/*.map', { cwd: buildPath });
47+
const mapFiles = walkDirectory(buildPath, '.map');
1248

1349
mapFiles.forEach(file => {
1450
fs.unlinkSync(path.join(buildPath, file));

packages/remix/test/integration/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@
3939
"@vanilla-extract/css": "1.13.0",
4040
"@vanilla-extract/integration": "6.2.4",
4141
"@types/mime": "^3.0.0",
42-
"@sentry/remix/glob": "<10.4.3",
43-
"jackspeak": "<3.4.1",
44-
"**/path-scurry/lru-cache": "10.2.0",
4542
"vite": "^6.0.0"
4643
},
4744
"engines": {

0 commit comments

Comments
 (0)