-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
Worker instantiation from URLs #30780
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
IIRC we have prior art on accepting file urls for various APIs, but i don't remember which ones. |
The initial URL support for the I think a) is not a large concern here. |
b) has typically been also seen as a backwards-incompatible change. Perhaps to implement it that way upfront now though would be permissible. Then, if users really need a directory named file: they can convert the path into a URL. |
Support for That said a filename matching |
I used it multiple times. It is convenient in apps to always use |
Just having something like the following would work... new Worker(new URL(import.meta.url)); |
^ This approach is how |
The explicit goal is to let users use `import.meta.url` to re-load thecurrent module inside a Worker instance. Fixes: nodejs#30780
The explicit goal is to let users use `import.meta.url` to re-load thecurrent module inside a Worker instance. Fixes: #30780 PR-URL: #31664 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
The explicit goal is to let users use `import.meta.url` to re-load thecurrent module inside a Worker instance. Fixes: #30780 PR-URL: #31664 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
The explicit goal is to let users use `import.meta.url` to re-load thecurrent module inside a Worker instance. Fixes: nodejs#30780 PR-URL: nodejs#31664 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
The explicit goal is to let users use `import.meta.url` to re-load thecurrent module inside a Worker instance. Fixes: #30780 PR-URL: #31664 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
When creating workers from within modules, we don't have
__filename
or__dirname
so rather have to rely on import.meta.url, something like:To avoid the
fileURLToPath
call being necessary here, should we consider supporting URLs as input intonew Worker
?The text was updated successfully, but these errors were encountered: