-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
feat(worker): allow passing options to worker constructors #6145
Conversation
const objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob); | ||
try { | ||
return objURL ? new Worker(objURL) : new Worker("data:application/javascript;base64," + encodedJs, {type: "module"}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @andreasg123
I don't quite understand why we didn't pass {type: "module"}
to new Worker(objURL)
(#4674). An oversight maybe?
Dingtalk's chromium is 72, Worker module type surport 80, It Is Necessary! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Closing as the support has landed with different syntax. #2550 (comment) |
It can be used in the development environment, but when 'NPM run build', my new URL is a typescript file? new URL("./worker.ts", import.meta.url)
// after npm run build
const ng=new URL("./worker.ts",self.location);Yr=new Worker(ng,{type:"classic"}); Does this mean that I have to compile my web worker file in advance in this way? Or is there something wrong with the way I use it? I still think this method can better solve the problem import MyClassicWorker from './ classic-worker? worker'
const worker = new MyClassicWorker({ type: 'classic' }) |
@0x30 I feel your usage is not correct. Please create an Q&A discussion with reproduction. |
Yes, you are right. You can see discussions#8525.
|
|
Description
This PR adds support for the
options
parameter of worker constructors, notably allowing{ type: "classic" }
(fixes #2550).Additional context
There is #2578, but it's closed at #2578 (comment). This PR workarounds that problem by prepending
importScript(...)
instead ofimport ...
to classic worker scripts.What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).