mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
## Summary - Preserve the original static worker request when generating the Turbopack module-context lookup, instead of passing an already-rewritten URL object. - Adds an e2e fixture for bare-module Worker URLs with conditional wildcard exports. It looks like this might have regressed in #88602 Fixes #94015 Closes #94043 ## Verification - `cargo check -p turbopack-ecmascript` - `HEADLESS=true pnpm test-start-turbo test/e2e/app-dir/worker-module-url/worker-module-url.test.ts` - `HEADLESS=true pnpm test-start-webpack test/e2e/app-dir/worker-module-url/worker-module-url.test.ts`
33 lines
709 B
TypeScript
33 lines
709 B
TypeScript
'use client'
|
|
|
|
import { useState } from 'react'
|
|
|
|
export default function Page() {
|
|
const [status, setStatus] = useState('idle')
|
|
|
|
function startWorker() {
|
|
try {
|
|
const worker = new Worker(
|
|
new URL('worker-package/worker.js', import.meta.url)
|
|
)
|
|
worker.onmessage = ({ data }) => {
|
|
setStatus(data)
|
|
worker.terminate()
|
|
}
|
|
worker.onerror = ({ message }) => {
|
|
setStatus(message)
|
|
worker.terminate()
|
|
}
|
|
} catch (error) {
|
|
setStatus(error instanceof Error ? error.message : String(error))
|
|
}
|
|
}
|
|
|
|
return (
|
|
<main>
|
|
<button onClick={startWorker}>Start worker</button>
|
|
<p id="status">{status}</p>
|
|
</main>
|
|
)
|
|
}
|