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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to admit this feels a bit risky because of file path shenanigans (windows paths?). I am open to other suggestions.
Making it an exact match should be fine in combination with our query-string import approach because we don't want to process these files anyways. Maybe we can even remove the exit condition (
if (this.resourceQuery.includes('__sentry_wrapped__')) return userCode;
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have two regex - one for windows and one for Unix if this one does not support windows imo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, right, I always forget about windows path separators. Good call, @AbhiPrasad.
I don't think we need to do it in two regexes, though. We actually already know the pages directory, so I claim we can do this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah perfect, let’s do that then!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Katie that change gets rid of the solution for the
src
folder problematic: #5978I like however that we build the path to the Next.js
pages
before we pass it toescapeStringForRegex()
so I opted for a hybrid approach. 43f2823There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If their pages folder is in a
src
folder, that should be included inpagesDir
, no?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we shouldn't include both! It's either
pages
orsrc/pages
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I mean: If a user has their pages in
/pages
, then that will be reflected in the value ofpagesDir
. If a user has their pages insrc/pages
, that will also be reflected in the value ofpagesDir.
Either way, we don't need to recalculate the value.If I do
depending on whether or not I'm using a
src
directory I get eitheror
Update: Opened #6044 to remove the extra calculation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh sorry got confused and didn't realize that
pagesDir
was a thing. I'll approve that PR!