mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
### 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
21 lines
461 B
TypeScript
21 lines
461 B
TypeScript
import { NextResponse } from 'next/server'
|
|
|
|
export async function GET() {
|
|
try {
|
|
const { jsPDF } = await import('jspdf')
|
|
const doc = new jsPDF()
|
|
doc.text('Hello world!', 10, 10)
|
|
const pdfData = doc.output('arraybuffer')
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
size: pdfData.byteLength,
|
|
})
|
|
} catch (error) {
|
|
return NextResponse.json(
|
|
{ success: false, error: String(error) },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
}
|