-
Notifications
You must be signed in to change notification settings - Fork 147
importScripts() should resolve against webworker file not cwd #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Agreed. Pull requests welcome!
russaa <[email protected]>於 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>:
1. 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
<#192>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AABQ888_6FhTwdff8f7g7RNd8eFXxSi6ks5u1VJfgaJpZM4Y-8u7>
.
--
Cheers,
Audrey
|
audreyt
added a commit
that referenced
this issue
Jan 28, 2019
#192 importScripts: resolve relative path against WebWorker location
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
The text was updated successfully, but these errors were encountered: