Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e5061a0

Browse files
docs(Guides): document Worker limitation in webpack (#6739)
1 parent 9811840 commit e5061a0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

‎src/content/guides/web-workers.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ The syntax was chosen to allow running code without bundler, it is also availabl
2525
2626
Note that while the [`Worker` API](https://developer.mozilla.org/en-US/docs/Web/API/Worker/Worker) suggests that `Worker` constructor would accept a string representing the URL of the script, in webpack 5 you can only use `URL` instead.
2727
28+
W> Using a variable in the `Worker` constructor is not supported by webpack. For example, the following code will not work: `const url = new URL('./path/to/worker.ts', import.meta.url); const worker = new Worker(url);`. This is because webpack cannot analyse the syntax statically. It is important to be aware of this limitation when using `Worker` syntax with webpack.
29+
2830
## Example
2931
3032
**src/index.js**

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /