mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
### What Disable swc transform optimizer for node_modules in browser layer of app router bundles Fixes #61858 Fixes #60644 Fixes #60920 Fixes #61740 Closes NEXT-2418 ### Why In browser there could be not only one runtime, it could have both js worker and browser. In js worker the `typeof window` is not as same as in browser, so disabling the swc optimizer which will replace the code. Leave the condition as it as.
23 lines
513 B
JavaScript
23 lines
513 B
JavaScript
'use client'
|
|
import { useState } from 'react'
|
|
|
|
export default function Home() {
|
|
const [state, setState] = useState('default')
|
|
return (
|
|
<div>
|
|
<button
|
|
onClick={() => {
|
|
const worker = new Worker(new URL('./worker', import.meta.url))
|
|
worker.addEventListener('message', (event) => {
|
|
setState(event.data)
|
|
})
|
|
}}
|
|
>
|
|
Get web worker data
|
|
</button>
|
|
<p>Worker state: </p>
|
|
<p id="worker-state">{state}</p>
|
|
</div>
|
|
)
|
|
}
|