forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turbopack: support module workers (vercel#72614)
- Also process `new Worker()` if there are options - Then remove the `type: module` from the options at runtime (as Webpack also does apparently). The alternative would be to keep the `type: module` and ESM imports instead in the worker.
- Loading branch information
Showing
8 changed files
with
55 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'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), { | ||
type: 'module', | ||
}) | ||
worker.addEventListener('message', (event) => { | ||
setState(event.data) | ||
}) | ||
}} | ||
> | ||
Get web worker data | ||
</button> | ||
<p>Worker state: </p> | ||
<p id="worker-state">{state}</p> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ut/b1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_b6426d.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...1abf_turbopack-tests_tests_snapshot_runtime_default_dev_runtime_input_index_b6426d.js.map
Large diffs are not rendered by default.
Oops, something went wrong.