Skip to content
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

How to use @chialab/esbuild-plugin-worker create web-workers? #22

Closed
okikio opened this issue Aug 6, 2021 · 10 comments
Closed

How to use @chialab/esbuild-plugin-worker create web-workers? #22

okikio opened this issue Aug 6, 2021 · 10 comments

Comments

@okikio
Copy link

okikio commented Aug 6, 2021

Quick question, I'd like to use @chialab/esbuild-plugin-worker together with gulp-esbuild as a plugin for loading workers, but I am not clear on how I'm supposed to do that. the docs don't mention how you create workers.

@edoardocavazza
Copy link
Member

Hello @okikio! I have updated the README file of the plugin with some information.

Please do not hesitate to ask questions or more examples, we are still setting up the ecosystem and things may be incomplete. Any feedback is appreciated.

@okikio
Copy link
Author

okikio commented Aug 9, 2021

Thanks for the quick response, but unfortunately I won't be able to use @chialab/esbuild-plugin-worker, as it lacks support for the { type: "module" } option, fortunately I was able to create a small custom solution for my use case.

In my case, the main reason why I need the { type: "module" } is to avoid redundant/repetitive code, I was hoping to have modules required for both the main thread and the worker be loaded once, as the project I am working on (an online bundler) is rather complex. I appreciate you taking the time, and I can't wait to see what this project turns into.

If you want to learn more about my project I suggest check out the repo github.com/okikio/bundle or the site itself bundle.js.org

@edoardocavazza
Copy link
Member

I see. Supporting { type: "module" } is quite easy, but at the moment there is not a way to emit chunks in esbuild, so the worker build cannot share code with the main build. We are looking forward for evanw/esbuild#795 and evanw/esbuild#312.

If you want to learn more about my project I suggest check out the repo github.com/okikio/bundle or the site itself bundle.js.org

Sure I will!

@okikio
Copy link
Author

okikio commented Aug 11, 2021

Ok, thanks

@okikio
Copy link
Author

okikio commented Oct 13, 2021

It's been a while, does @chialab/esbuild-plugin-worker now support module web-workers?

@edoardocavazza
Copy link
Member

Hi @okikio. Some time ago I added a check for type: 'module' in Worker initialization. It should work, but I have to admit I had not test it so much. Would you like to do some testing?

@okikio
Copy link
Author

okikio commented Oct 13, 2021

I'll see if I can do some testing

@okikio
Copy link
Author

okikio commented Oct 13, 2021

Btw I have finished the dev of github.com/okikio/bundle you can check out the final version at bundle.js.org

@edoardocavazza
Copy link
Member

Hello @okikio , any update on this? Can we close the issue?

@okikio
Copy link
Author

okikio commented Dec 28, 2021

Yeah, thanks so much for your help

@okikio okikio closed this as completed Dec 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants