ref(nextjs): Use bundling instead of proxying to wrap pages and API routes#6685
Merged
ref(nextjs): Use bundling instead of proxying to wrap pages and API routes#6685
Conversation
added 7 commits
January 8, 2023 21:48
Member
|
Generally, I think this is a great approach, and probably more robust than what we had before. I am really not an expert in this part of the code at all, so mainly I have two questions, to be sure:
|
Contributor
size-limit report 📦
|
Contributor
Author
Source maps stay correct! Or rather they will become correct when using webpack 4. I also took a look at the fingerprinting and it looks the same.
No. The build time impact is negligible. For each user file, we're only bundling 2 files, our wrapper module, and the user module. We're not traversing the entire dependency tree. |
AbhiPrasad
approved these changes
Jan 9, 2023
mydea
approved these changes
Jan 9, 2023
Lms24
approved these changes
Jan 9, 2023
d42a897 to
06c7000
Compare
3 tasks
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.
Ref #6120
To automatically wrap data fetchers and API routes in the Next.js SDK we are currently using an approach we call "proxying". What this means is that we inject a webpack loader that replaces the page/API route files with a "proxy file" that imports the original page/API route file, wraps all data fetchers and API routes, and reexports everything.
In order to distinguish the original file from our proxy file within the loader, we're importing/exporting the user file with a query string at the end. It looks like this:
export * from '{user-module}?sentry-wrapped'. Unfortunately, this query string messes up a bunch of things:@vercel/nft(Node File Trace) which Vercel uses during the Next.js build process to determine which files are needed (issue)experimental-serverless-tracetarget is set in the Next.js config (issue)This PR fixes the issues above by replacing our "proxying" approach with a slightly different one. We will still be using a loader but instead of letting webpack take care of the "proxying" we simply return a bundled version of our wrapper code and the user code. For this bundling we are using rollup.
Fixes #6118
Fixes #5998