From 3fceb14b94b12d12d47285402980f360aa4284ea Mon Sep 17 00:00:00 2001 From: Luca Maltagliati Date: Fri, 26 Jan 2024 10:02:01 +0100 Subject: [PATCH] docs: add warning on Worker import with constructor limitations (#15436) Co-authored-by: patak --- docs/guide/features.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/guide/features.md b/docs/guide/features.md index 1341ec00f7c0da..e75e84b08e866b 100644 --- a/docs/guide/features.md +++ b/docs/guide/features.md @@ -614,6 +614,8 @@ const worker = new Worker(new URL('./worker.js', import.meta.url), { }) ``` +The worker detection will only work if the `new URL()` constructor is used directly inside the `new Worker()` declaration. Additionally, all options parameters must be static values (i.e. string literals). + ### Import with Query Suffixes A web worker script can be directly imported by appending `?worker` or `?sharedworker` to the import request. The default export will be a custom worker constructor: