fix(nextjs): Stop using eval
when checking for sentry-cli
binary
#5447
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.
In #4988, we switched to using
eval
inensureCLIBinaryExists
(called by our build-time config code in the nextjs SDK), in order to prevent Vercel's dependency-tracing algorithm from thinking the binary was a (n enormous) dependency and including it in people's serverless functions. (It was getting tricked by therequire.resolve()
call; turning that call into a string was the only way we could find to hide it from the algorithm.)But
eval
is kind of gross. And Rollup, which agrees it's gross, keeps yelling at us for using it. In order to suppress the warnings and generally clean things up, this replaces theeval
with real code again, and in that real code replaces therequire.resolve()
call with a manual check of all of the pathsrequire.resolve()
would consider. Norequire
means no confused algorithm means no erroneously bundled cli binary in Vercel. And noeval
means happy Rollup means happy us, because now it's easier to see when the build has legit errors. Wins all around.