Open russaa opened 5 years ago
Agreed. Pull requests welcome! russaa notifications@github.com於 2018年12月4日 週二,00:33寫道:
currently importScripts() resolves against the current working directory (cwd): this makes it difficult to make it usable as an npm package, since the path would need to be adjusted according to where the npm package is installed/run from.
The Web Worker implementation in browsers (e.g. Firefox, Chrome) do resolve against the Web Worker script file instead, e.g. for
index.html index.js workers/worker1.js workers/helperScript.js
if worker1.js is loaded in index.html (or index.js), then worker1.js would load helperScript.js with importScripts("helperScript.js") and not importScripts("workers/helperScript.js")
And if I understand the Web Worker specification correctly, importScripts() really should resolve against the (worker) script file where the importScripts() statement occurs:
5.1 Importing scripts and libraries https://www.w3.org/TR/workers/#importing-scripts-and-libraries:
- Resolve each argument relative to settings object's API base URL.
and then in 4.6.2 Script settings for workers https://www.w3.org/TR/workers/#script-settings-for-workers:
The API base URL Return script address.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/audreyt/node-webworker-threads/issues/192, or mute the thread https://github.com/notifications/unsubscribe-auth/AABQ888_6FhTwdff8f7g7RNd8eFXxSi6ks5u1VJfgaJpZM4Y-8u7 .
--
Cheers, Audrey
currently
importScripts()
resolves against the current working directory (cwd):this makes it difficult to make it usable as an npm package, since the imported script path would need to be adjusted according to where the npm package is installed/run from.
The Web Worker implementations in browsers (e.g. Firefox, Chrome) do resolve against the Web Worker script file instead, e.g. for
if
worker1.js
is loaded inindex.html
(orindex.js
), thenworker1.js
would loadhelperScript.js
withimportScripts("helperScript.js")
and not
importScripts("workers/helperScript.js")
And if I understand the Web Worker specification correctly,
importScripts()
really should resolve against the (worker) script file where theimportScripts()
statement occurs:5.1 Importing scripts and libraries:
and then in 4.6.2 Script settings for workers: