frontend-plugin: fix creating a webworker for frontend plugin (browser only)#9715
frontend-plugin: fix creating a webworker for frontend plugin (browser only)#9715vitaliy-guliy merged 11 commits intomasterfrom
Conversation
Signed-off-by: Vitaliy Gulyy <vgulyy@redhat.com>
Signed-off-by: Vitaliy Gulyy <vgulyy@redhat.com>
Co-authored-by: Chris Wilson <titanicswimteam@hotmail.com>
vince-fugnitto
left a comment
There was a problem hiding this comment.
I confirmed with the hello-world theia plugin that frontend plugins work again for the browser use-case 👍
| loader: 'worker-loader', | ||
| options: { | ||
| filename: 'worker-ext.[fullhash].js' | ||
| filename: 'worker-ext.js' |
There was a problem hiding this comment.
As I understand it, including the hash will make sure we're not referencing stale code from the cache. Can we find a way to preserve that feature?
There was a problem hiding this comment.
Nothing is impossible, but since we don't need a worker-loader we need to keep somewhere the file name.
Before it was inside generated worker-loader script
return new Worker(__webpack_require__.p + "worker-ext.5f6918e41dd2b417d716.js");
For now we need to keep somewhere a proper name of the file and fetch it before running a worker.
Btw, other javascript files don't have hash in their names. Do we really need to have it only for this specific file?
tsmaeder
left a comment
There was a problem hiding this comment.
I think we should turn off front-end plugins more cleanly in the electron case. Beyond that, I there are a couple of changes I just don't understand. It would help if you described hat the fix is a bit in the PR description.
Co-authored-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>
Co-authored-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>
Co-authored-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>
Don't want the PR to be blocked while I'm on vacation
Signed-off-by: Vitaliy Gulyy <vgulyy@redhat.com>
Signed-off-by: Vitaliy Gulyy <vgulyy@redhat.com>
|
@vitaliy-guliy why should we avoid using Modifying the generated Webpack configuration like you did will not work if we don't include |
With Webpack 5 we can use webworker without worker loader https://webpack.js.org/guides/web-workers/ I've tried to use it with loader and create a worker using a
Yes, it will fail, plugin-ext must be included. I will think how to improve it and make the build successful without plugin-ext. |
|
@paul-marechal I played with dependencies a bit, but was easily compile the browsrer/electron. |
So it only works in the Theia repo but will most likely fail in a downstream Theia app.
I played around with what the Webpack doc was saying: https://github.com/eclipse-theia/theia/compare/mp/frontend-plugins#diff-6ccaef7f7e0ffcd2911ccf76fd97fbe9f2e75f1009ddda5c9024d9807bb093a3R30-R35 It worked for me without the changes to the application-manager generators. |
I always get an error, when I try to create an URL with That's why I used |
Signed-off-by: Vitaliy Gulyy <vgulyy@redhat.com>
Signed-off-by: Vitaliy Gulyy <vgulyy@redhat.com>
Signed-off-by: Vitaliy Gulyy <vgulyy@redhat.com>
|
@paul-marechal I've updated the PR, based on your branch. Seems it works fine. |
Did it work with |
It works with |
|
Out of curiosity I tried the following: this.worker = new Worker(new URL('./worker/worker-main', location.href));It didn't work at all... So |
…r only) (eclipse-theia#9715) * frontend-plugin: fix creating a webworker for frontend plugin Signed-off-by: Vitaliy Gulyy <vgulyy@redhat.com> Co-authored-by: Chris Wilson <titanicswimteam@hotmail.com> Co-authored-by: Vincent Fugnitto <vincent.fugnitto@ericsson.com>
Signed-off-by: Vitaliy Gulyy vgulyy@redhat.com
What it does
After moving to webpack 5, frontend plugins were not working for some time. Now it's not necessary to create a worker-loader.
It's enough to create a worker, pointing on javascript file.
https://webpack.js.org/guides/web-workers/
It's still not possible to create a worker for electron browser. Frontend plugins were turned off and the appropriate check for the browser was added to the
hosted-plugin.ts.Partially solves #6601
How to test
Review checklist
Reminder for reviewers