-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(nextjs): Sourcemaps for custom build directories #4003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
340d830
c970f13
e6b8c89
5a366c5
c0fbb21
b70837a
b0da15b
3a03e22
deab160
20b6b9d
508d46a
fa27150
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,11 +47,18 @@ function sdkAlreadyInitialized(): boolean { | |
return !!hub.getClient(); | ||
} | ||
|
||
const SOURCEMAP_FILENAME_REGEX = /^.*\/\.next\//; | ||
/** | ||
* WARNING: don't refactor this variable. | ||
* This variable gets overridden at build time to set the correct path -- what users | ||
* defined in the `distDir` option in their Next.js configuration. | ||
*/ | ||
export const PROJECT_BASEPATH = '.next'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if this should just go in it's own file - and then we can even snapshot test (https://jestjs.io/docs/snapshot-testing) against potential regressions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, yes. There's more code related to integrations that should be moved to another file, like the |
||
const projectBasepathRegex = PROJECT_BASEPATH[0] === '.' ? `\\${PROJECT_BASEPATH}` : PROJECT_BASEPATH; | ||
const sourcemapFilenameRegex = new RegExp(`^.*/${projectBasepathRegex}/`); | ||
|
||
const defaultRewriteFramesIntegration = new RewriteFrames({ | ||
iteratee: frame => { | ||
frame.filename = frame.filename?.replace(SOURCEMAP_FILENAME_REGEX, 'app:///_next/'); | ||
frame.filename = frame.filename?.replace(sourcemapFilenameRegex, 'app:///_next/'); | ||
return frame; | ||
}, | ||
}); | ||
|
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.
has to be sync? we can't async await?
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.
That was my initial approach and afaik we can definitely do it, but since we're running the code before webpack runs, the number of files is small (2 currently, and this is not something that scales), and files themselves are small, I believe the sync approach is faster (even if we block the event loop). That said, if you think the async approach is more convenient, I'm happy to change it. What do you think?
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 prefer defaulting to async, but I'll leave it up to you to make the final call.