Add an ignore field to adapters that is passed through to nft to, to prevent build time only exports from getting included in the bundle - #17027
Conversation
allow opting out of bundling exports of deps that should not be present in the bundle and are only needed at build time.
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/a6b0527f9c03b9e3d730cd9c8c9fbf82fd3351c7Open in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
🦋 Changeset detectedLatest commit: a6b0527 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: QUIET Plan: Advanced Run ID: 📒 Files selected for processing (4)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe Vercel adapter now supports an adapter-level Sequence Diagram(s)sequenceDiagram
participant AdapterPlugin
participant create_function_bundle
participant trace_ignore
participant nodeFileTrace
AdapterPlugin->>create_function_bundle: pass defaults.ignore
create_function_bundle->>trace_ignore: convert predicate for the bundle base
trace_ignore-->>create_function_bundle: return normalized ignore predicate
create_function_bundle->>nodeFileTrace: trace entrypoint with custom exclusions
nodeFileTrace-->>create_function_bundle: return traced bundle files
Merge Risk: ⚪ Minimal · up to This adds an adapter-level bundle ignore callback with normalized absolute paths, allowing build-only dependencies to be excluded from Vercel function bundles. The Windows path handling and documented path format are aligned, with no remaining merge-blocking risk. 🚥 Pre-merge checks | ✅ 1 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (1 passed)
Full details: Backward Compatibility Impact DisclosureExplanation No breaking public-interface change is introduced. The diff only adds the optional
Comment |
There was a problem hiding this comment.
Note
Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.
🟡 Other comments (1)
documentation/docs/25-build-and-deploy/90-adapter-vercel.md-71-71 (1)
71-71: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winMake the documented predicate platform-independent.
trace_ignorebuilds the absolute path withpath.join, which uses\on Windows. The documented POSIX-only predicate can returnfalseand leave the package in the bundle. Usenode:pathandpath.sep, or normalize the path before matching.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: QUIET
Plan: Advanced
Run ID: f4cbca06-697d-4654-8e23-e997114bc0d8
📒 Files selected for processing (6)
.changeset/witty-clouds-shave.mddocumentation/docs/25-build-and-deploy/90-adapter-vercel.mdpackages/adapter-vercel/index.d.tspackages/adapter-vercel/index.jspackages/adapter-vercel/utils.jspackages/adapter-vercel/utils.spec.js
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
sveltejs/svelte(manual)sveltejs/vite-plugin-svelte(manual)vitejs/vite(manual)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@Lms24 is this something that can be solved from Sentry's side? |
|
@teemingc yes, I believe this should be addressed by getsentry/sentry-javascript#23247 which will land in the next major version of our SDK. Scheduled stable release ~mid September. |
|
Thanks Lukas. I think I'm going to close this PR for now as in the past we've decided these issues stem from an underlying problem rather and having to manually configure paths to ignore is the ideal solution. If you have further issues with this, please open a new issue so that we can discuss the packages |
|
Thank you both! |
Preface:
I don't believe there is an open issue for this. I skimmed myself and couldn't find anything. When I asked my agent to look the closest thing it found was #13764 and that is already closed. Happy to make a new one if you'd like to.
I also want to add that the code in this PR should be interpretted as a bug report primarily, with code difff itself intended to demonstrate the bug and the fix/patch we are using in our codebase. I am not confident this is the right fix, but from my limited understanding of svelte internals it seems acceptable and I couldn't come up with a better one myself in the time I spent understanding the problem and the relevant svelte code and vercel code.
Finally I want to be upfront about my AI usage:
The issue itself
this statically pulls in a lot of unnecessary content, anything its dependencies re-export at build time. This leads to bloated bundle sizes and longer build times. The root cause of this is...
On my app itself, we are seeing an increase in bundle size from 146MB to 56MB. We pay this cost for each edge function our Vercel container packages into it (which I'm currently in the process of reducing, so the bloat here is slightly overstated for my app as of today)
Here's an the example case that lead me to this.