[turbopack] Respect {eval:true} in worker_threads constructors#91666
[turbopack] Respect {eval:true} in worker_threads constructors#91666lukesandberg merged 2 commits intocanaryfrom
{eval:true} in worker_threads constructors#91666Conversation
{eval:true} in nodejs worker_threads constructors
Merging this PR will not alter performance
Comparing Footnotes
|
{eval:true} in nodejs worker_threads constructors{eval:true} in worker_threads constructors
Stats from current PR🟢 1 improvement
📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles
Server Middleware
Build DetailsBuild Manifests
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📝 Changed Files (25 files)Files with changes:
View diffsapp-page-exp..ntime.dev.jsfailed to diffapp-page-exp..time.prod.jsfailed to diffapp-page-tur..ntime.dev.jsfailed to diffapp-page-tur..time.prod.jsfailed to diffapp-page-tur..ntime.dev.jsfailed to diffapp-page-tur..time.prod.jsfailed to diffapp-page.runtime.dev.jsfailed to diffapp-page.runtime.prod.jsfailed to diffapp-route-ex..ntime.dev.jsDiff too large to display app-route-ex..time.prod.jsDiff too large to display app-route-tu..ntime.dev.jsDiff too large to display app-route-tu..time.prod.jsDiff too large to display app-route-tu..ntime.dev.jsDiff too large to display app-route-tu..time.prod.jsDiff too large to display app-route.runtime.dev.jsDiff too large to display app-route.ru..time.prod.jsDiff too large to display server.runtime.prod.jsDiff too large to display pages-api-tu..ntime.dev.jsDiff too large to display pages-api-tu..time.prod.jsDiff too large to display pages-api.runtime.dev.jsDiff too large to display pages-api.ru..time.prod.jsDiff too large to display pages-turbo...ntime.dev.jsDiff too large to display pages-turbo...time.prod.jsDiff too large to display pages.runtime.dev.jsDiff too large to display pages.runtime.prod.jsDiff too large to display 📎 Tarball URL |
Tests Passed |
36437ad to
4b37578
Compare
Merge activity
|
) ### What? Fixed Turbopack incorrectly trying to resolve inline JavaScript code as module references when `new Worker()` is called with `{ eval: true }` option. Now we skip creating a reference when `eval:true`, and report warnings if we cannot tell what the value is ### Why? Libraries like jsPDF create Worker threads by passing inline JavaScript code as the first argument along with `{ eval: true }` as the second argument. Turbopack was incorrectly treating this inline code as a file path and attempting to resolve it as a module reference, causing build failures. ### How? Added logic to detect when the `eval: true` option is passed to the Worker constructor. When this option is present, Turbopack now skips creating a worker reference since the first argument contains executable code rather than a file path. Added comprehensive test coverage using jsPDF to verify the fix works correctly. Fixes #91642
Next.js 16.2.0 introduced a Turbopack regression where dynamic
Worker constructors with { eval: true } (used by fflate, a jspdf
dependency) fail with "Module not found: Can't resolve <dynamic>".
This was fixed upstream in vercel/next.js#91666, shipped in 16.2.1.

What?
Fixed Turbopack incorrectly trying to resolve inline JavaScript code as module references when
new Worker()is called with{ eval: true }option.Now we skip creating a reference when
eval:true, and report warnings if we cannot tell what the value isWhy?
Libraries like jsPDF create Worker threads by passing inline JavaScript code as the first argument along with
{ eval: true }as the second argument. Turbopack was incorrectly treating this inline code as a file path and attempting to resolve it as a module reference, causing build failures.How?
Added logic to detect when the
eval: trueoption is passed to the Worker constructor. When this option is present, Turbopack now skips creating a worker reference since the first argument contains executable code rather than a file path. Added comprehensive test coverage using jsPDF to verify the fix works correctly.Fixes #91642