-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
ref(nextjs): Use bundling instead of proxying to wrap pages and API routes #6685
Conversation
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:
|
size-limit report 📦
|
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. |
d42a897
to
06c7000
Compare
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-trace
target 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