diff --git a/packages/remix/package.json b/packages/remix/package.json index d0e754ea137d..40b36be6f216 100644 --- a/packages/remix/package.json +++ b/packages/remix/package.json @@ -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": { diff --git a/packages/remix/scripts/deleteSourcemaps.js b/packages/remix/scripts/deleteSourcemaps.js index 82a00b5b0f92..47ec7f8bfd20 100644 --- a/packages/remix/scripts/deleteSourcemaps.js +++ b/packages/remix/scripts/deleteSourcemaps.js @@ -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)); diff --git a/packages/remix/test/integration/package.json b/packages/remix/test/integration/package.json index 28ef147b57d7..40652b48b905 100644 --- a/packages/remix/test/integration/package.json +++ b/packages/remix/test/integration/package.json @@ -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": {