chore(remix): replace yargs with native util.parseArgs#19532
Open
roli-lpci wants to merge 1 commit intogetsentry:developfrom
Open
chore(remix): replace yargs with native util.parseArgs#19532roli-lpci wants to merge 1 commit intogetsentry:developfrom
roli-lpci wants to merge 1 commit intogetsentry:developfrom
Conversation
Replaces the yargs dependency with Node's built-in util.parseArgs for CLI argument parsing in the sentry-upload-sourcemaps script. Adds --keepAfterUpload flag as a cross-version alternative to yargs' --no-deleteAfterUpload boolean negation (which requires Node >= 20.16). Behavioral changes from yargs: - Unknown flags now throw (stricter, catches typos early) - Kebab-case aliases (--url-prefix) no longer supported; use camelCase - Boolean flags do not accept =true/=false values Removes ~10 transitive dependencies (cliui, escalade, string-width, etc.). Ref: getsentry#19447 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| @@ -1,68 +1,74 @@ | |||
| #!/usr/bin/env node | |||
| const yargs = require('yargs'); | |||
| const { parseArgs } = require('node:util'); | |||
There was a problem hiding this comment.
Bug: The script uses util.parseArgs, which will crash on Node.js versions 18.0.0-18.2.x, despite the package.json allowing these versions.
Severity: MEDIUM
Suggested Fix
Update the package.json engines field to require "node": ">=18.3.0". Alternatively, add a runtime check for util.parseArgs and provide a helpful error message or a fallback implementation for older Node.js versions.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: packages/remix/scripts/sentry-upload-sourcemaps.js#L2
Potential issue: The `sentry-upload-sourcemaps.js` script utilizes the `util.parseArgs`
function, which is only available in Node.js versions 18.3.0 and later. The project's
`package.json` declares support for Node.js version 18.0.0 and above (`"node": ">=18"`).
Consequently, users running the script on Node.js versions between 18.0.0 and 18.2.x
will encounter a runtime crash because the `util.parseArgs` function does not exist in
their environment. The current CI setup does not test against these specific older patch
versions of Node 18, so this issue would not be caught automatically.
Did we get this right? 👍 / 👎 to inform future reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the
yargsdependency in@sentry/remixwith Node's built-inutil.parseArgsfor CLI argument parsing in thesentry-upload-sourcemapsscript.yarn lint) & (yarn test).Ref #19447
What this does
Replaces yargs with
util.parseArgs(built-in since Node 18.3) for parsing CLI flags in the source map upload script. Adds--keepAfterUploadflag as a cross-version alternative to yargs'--no-deleteAfterUploadboolean negation.Removes yargs and ~10 transitive dependencies (cliui, escalade, string-width, y18n, yargs-parser, wrap-ansi, etc.).
Behavioral changes from yargs
--relaseearly.--url-prefix) no longer work. Use the documented camelCase names (--urlPrefix).=true/=falsesyntax. Use the bare flag (--disableDebugIds) to enable, or--keepAfterUploadto prevent source map deletion.Why --keepAfterUpload?
util.parseArgsdoes not support boolean negation (--no-deleteAfterUpload) on Node < 20.16. Since@sentry/remixsupports Node >= 18,--keepAfterUploadprovides a cross-version way to prevent source map deletion after upload.