Skip to content

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

Merged
chargome merged 2 commits into
developfrom
cg/thirdparty-nodemodules
Mar 9, 2026
Merged

fix(nextjs): Align Turbopack module metadata injection with webpack behavior#19645
chargome merged 2 commits into
developfrom
cg/thirdparty-nodemodules

Conversation

@chargome

Copy link
Copy Markdown
Member
  • 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 logaretmMarch 5, 2026 10:47
@chargomechargome self-assigned this Mar 5, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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.

PathSize% ChangeChange
@sentry/browser25.63 kB--
@sentry/browser - with treeshaking flags24.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 flags70.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/react27.38 kB--
@sentry/react (incl. Tracing)44.77 kB--
@sentry/vue30.08 kB--
@sentry/vue (incl. Tracing)44.3 kB--
@sentry/svelte25.66 kB--
CDN Bundle28.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 - uncompressed82.35 kB--
CDN Bundle (incl. Tracing) - uncompressed128.07 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed85.19 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed130.9 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed208.85 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed244.95 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed247.77 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed257.86 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed260.67 kB--
@sentry/nextjs (client)47.18 kB--
@sentry/sveltekit (client)42.89 kB--
@sentry/node-core52.25 kB+0.03%+12 B 🔺
@sentry/node174.71 kB+0.02%+22 B 🔺
@sentry/node - without tracing97.39 kB+0.02%+17 B 🔺
@sentry/aws-serverless113.2 kB+0.02%+15 B 🔺

View base workflow run

@chargome
chargome merged commit cd05479 into developMar 9, 2026
72 checks passed
@chargome
chargome deleted the cg/thirdparty-nodemodules branch March 9, 2026 08:43
Sign up for freeto 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

@chargome@logaretm