From 646f09f6d564eaac3da98090cfcd30aaf597503c Mon Sep 17 00:00:00 2001 From: Rolando Bosch Date: Thu, 26 Feb 2026 02:09:00 -0800 Subject: [PATCH] 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 --- packages/remix/package.json | 1 - packages/remix/scripts/deleteSourcemaps.js | 40 +++++++++++++++++++- packages/remix/test/integration/package.json | 3 -- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/packages/remix/package.json b/packages/remix/package.json index c18114d7fe8f..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": "^10.3.4", "yargs": "^17.6.0" }, "devDependencies": { diff --git a/packages/remix/scripts/deleteSourcemaps.js b/packages/remix/scripts/deleteSourcemaps.js index f73cc678f7df..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 glob = 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 = glob.sync('**/*.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": {