Skip to content
Open
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
1 change: 0 additions & 1 deletion packages/remix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"@sentry/core": "10.40.0",
"@sentry/node": "10.40.0",
"@sentry/react": "10.40.0",
"glob": "^13.0.6",
"yargs": "^17.6.0"
},
"devDependencies": {
Expand Down
40 changes: 38 additions & 2 deletions packages/remix/scripts/deleteSourcemaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,49 @@
const fs = require('fs');
const path = require('path');

const { globSync } = require('glob');
/**
* Recursively walks a directory and returns relative paths of all files
* matching the given extension.
*
* Uses manual recursion instead of `fs.readdirSync({ recursive: true, withFileTypes: true })`
* to avoid a bug in Node 18.17–18.18 where `withFileTypes` returns incorrect `parentPath` values
* when combined with `recursive: true`.
*
* @param {string} rootDir - The root directory to start walking from.
* @param {string} extension - The file extension to match (e.g. '.map').
* @returns {string[]} Relative file paths from rootDir.
*/
function walkDirectory(rootDir, extension) {
const results = [];

function walk(dir) {
let entries;
try {
entries = fs.readdirSync(dir, { withFileTypes: true });
} catch {
return;
}

for (const entry of entries) {
const fullPath = path.join(dir, entry.name);

if (entry.isDirectory()) {
walk(fullPath);
} else if (entry.name.endsWith(extension)) {
results.push(path.relative(rootDir, fullPath));
}
}
}

walk(rootDir);
return results;
}

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

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

mapFiles.forEach(file => {
fs.unlinkSync(path.join(buildPath, file));
Expand Down
3 changes: 0 additions & 3 deletions packages/remix/test/integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@
"@vanilla-extract/css": "1.13.0",
"@vanilla-extract/integration": "6.2.4",
"@types/mime": "^3.0.0",
"@sentry/remix/glob": "<10.4.3",
"jackspeak": "<3.4.1",
"**/path-scurry/lru-cache": "10.2.0",
"vite": "^6.0.0"
},
"engines": {
Expand Down
Loading