Skip to content

fix(nextjs): Align Turbopack module metadata injection with webpack behavior#19645

Open
chargome wants to merge 2 commits intodevelopfrom
cg/thirdparty-nodemodules
Open

fix(nextjs): Align Turbopack module metadata injection with webpack behavior#19645
chargome wants to merge 2 commits intodevelopfrom
cg/thirdparty-nodemodules

Conversation

@chargome
Copy link
Member

@chargome chargome commented Mar 5, 2026

  • Remove condition: { not: 'foreign' } from the Turbopack metadata injection rule so node_modules (including e.g. React) are tagged as first-party, matching webpack's BannerPlugin behavior
  • Wrap injected code in a try-catch IIFE (matching the webpack plugin's CodeInjection pattern) to safely handle node_modules with strict initialization order
  • Exclude only next/dist/build/polyfills/ which contain non-standard syntax that causes Turbopack parse errors

Fixes the thirdPartyErrorFilterIntegration being unusable in Turbopack builds — previously, React frames in stack traces were treated as third-party because node_modules lacked metadata, causing apply-tag-if-contains-third-party-frames to incorrectly tag every error.

closes #19320 (again)

@chargome chargome requested review from Lms24 and logaretm March 5, 2026 10:47
@chargome chargome self-assigned this Mar 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 25.63 kB - -
@sentry/browser - with treeshaking flags 24.13 kB - -
@sentry/browser (incl. Tracing) 42.43 kB +0.01% +2 B 🔺
@sentry/browser (incl. Tracing, Profiling) 47.09 kB - -
@sentry/browser (incl. Tracing, Replay) 81.25 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.87 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 85.95 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 98.21 kB - -
@sentry/browser (incl. Feedback) 42.44 kB - -
@sentry/browser (incl. sendFeedback) 30.3 kB +0.01% +1 B 🔺
@sentry/browser (incl. FeedbackAsync) 35.35 kB - -
@sentry/browser (incl. Metrics) 26.8 kB - -
@sentry/browser (incl. Logs) 26.94 kB +0.01% +1 B 🔺
@sentry/browser (incl. Metrics & Logs) 27.61 kB - -
@sentry/react 27.38 kB - -
@sentry/react (incl. Tracing) 44.77 kB - -
@sentry/vue 30.08 kB - -
@sentry/vue (incl. Tracing) 44.3 kB - -
@sentry/svelte 25.66 kB - -
CDN Bundle 28.17 kB +0.01% +1 B 🔺
CDN Bundle (incl. Tracing) 43.26 kB - -
CDN Bundle (incl. Logs, Metrics) 29.01 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 44.1 kB +0.01% +1 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 68.09 kB - -
CDN Bundle (incl. Tracing, Replay) 80.14 kB +0.01% +1 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 81 kB +0.01% +1 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 85.65 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.53 kB - -
CDN Bundle - uncompressed 82.35 kB - -
CDN Bundle (incl. Tracing) - uncompressed 128.07 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 85.19 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 130.9 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 208.85 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 244.95 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 247.77 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 257.86 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 260.67 kB - -
@sentry/nextjs (client) 47.18 kB - -
@sentry/sveltekit (client) 42.89 kB - -
@sentry/node-core 52.25 kB +0.03% +12 B 🔺
@sentry/node 174.71 kB +0.02% +22 B 🔺
@sentry/node - without tracing 97.39 kB +0.02% +17 B 🔺
@sentry/aws-serverless 113.2 kB +0.02% +15 B 🔺

View base workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Next.js + Turbopack: thirdPartyErrorFilterIntegration (applicationKey)

2 participants