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

feat: support dynamic emscripten module import in web workers #970

Merged
merged 2 commits into from
Oct 13, 2023

Conversation

thewtex
Copy link
Member

@thewtex thewtex commented Oct 12, 2023

Firefox now has dynamic ESM support in web workers, and it is enabled in the current stable release.

This means we can:

  1. Allow WebPack, Vite, Rollup, to bundle the web workers as usual by default and they can use the dynamic import at runtime.
  2. Not build the UMD Emscripten module wrapper for importScript imports

This patch sets the bundler handling of pipeline.worker.js to be the default, and stops building the UMD wasm modules.

@thewtex
Copy link
Member Author

thewtex commented Oct 12, 2023

Addressing #476

@jadh4v @PaulHax

src/itk-wasm-cli.js Outdated Show resolved Hide resolved
@thewtex thewtex force-pushed the worker-dynamic-import branch from 8702bf0 to b63b9f1 Compare October 12, 2023 16:49
Firefox now has dynamic ESM support in web workers, and it is enabled in
the current stable release.

This means we can:

1. Allow WebPack, Vite, Rollup, to bundle the web workers as usual by
   default and they can use the dynamic import at runtime.
2. Not build the UMD Emscripten module wrapper for importScript imports

This patch sets the bundler handling of pipeline.worker.js to be the default,
and stops building the UMD wasm modules.
@thewtex thewtex force-pushed the worker-dynamic-import branch from b63b9f1 to 9d5cd0d Compare October 12, 2023 18:42
@thewtex thewtex marked this pull request as ready for review October 12, 2023 18:42
@thewtex thewtex merged commit 4cfde1d into InsightSoftwareConsortium:main Oct 13, 2023
67 checks passed
@thewtex thewtex deleted the worker-dynamic-import branch October 13, 2023 04:06
@github-actions
Copy link

🎉 This PR is included in version 1.0.0-b.148 🎉

The release is available on:

Your semantic-release bot 📦🚀

thewtex added a commit to thewtex/ITK-Wasm that referenced this pull request Oct 13, 2023
thewtex added a commit to thewtex/ITK-Wasm that referenced this pull request Oct 13, 2023
creation

Follow-up to InsightSoftwareConsortium#970 when using Vite with derived packages.
github-actions bot pushed a commit that referenced this pull request Oct 13, 2023
# [1.0.0-b.149](itk-wasm-v1.0.0-b.148...itk-wasm-v1.0.0-b.149) (2023-10-13)

### Bug Fixes

* **createWebWorkerPromise:** use type: 'module' option for Worker ([92f9492](92f9492)), closes [#970](#970)
thewtex added a commit to thewtex/ITK-Wasm that referenced this pull request Oct 16, 2023
thewtex added a commit to thewtex/ITK-Wasm that referenced this pull request Oct 17, 2023
No longer necessary via InsightSoftwareConsortium#970

Improve image-io testing speed via:

https://dev.to/noriste/speed-up-e2e-tests-for-vite-based-apps-3k4l

Resolve library worker bundling per:

https://medium.com/adevinta-tech-blog/introducing-web-workers-to-improve-subito-it-performance-part-2-92bcfed8a62

Vite does not support pre-bundling of web workers in dependencies, so we
have to add packages to optimizeDeps.exclude.

gkjohnson/three-gpu-pathtracer#355 (comment)
thewtex added a commit to thewtex/ITK-Wasm that referenced this pull request Oct 20, 2023
No longer necessary via InsightSoftwareConsortium#970

Improve image-io testing speed via:

https://dev.to/noriste/speed-up-e2e-tests-for-vite-based-apps-3k4l

Resolve library worker bundling per:

https://medium.com/adevinta-tech-blog/introducing-web-workers-to-improve-subito-it-performance-part-2-92bcfed8a62

Vite does not support pre-bundling of web workers in dependencies, so we
have to add packages to optimizeDeps.exclude.

gkjohnson/three-gpu-pathtracer#355 (comment)

Some updates in compare-images. Further updates to packages in follow-up
commits.
thewtex added a commit to thewtex/ITK-Wasm that referenced this pull request Oct 30, 2023
No longer necessary via InsightSoftwareConsortium#970

Improve image-io testing speed via:

https://dev.to/noriste/speed-up-e2e-tests-for-vite-based-apps-3k4l

Resolve library worker bundling per:

https://medium.com/adevinta-tech-blog/introducing-web-workers-to-improve-subito-it-performance-part-2-92bcfed8a62

Vite does not support pre-bundling of web workers in dependencies, so we
have to add packages to optimizeDeps.exclude.

gkjohnson/three-gpu-pathtracer#355 (comment)

Some updates in compare-images. Further updates to packages in follow-up
commits.
thewtex added a commit to thewtex/ITK-Wasm that referenced this pull request Nov 5, 2023
Use the app's bundler's support for the worker by default.

No longer necessary via InsightSoftwareConsortium#970

Improve image-io testing speed via:

https://dev.to/noriste/speed-up-e2e-tests-for-vite-based-apps-3k4l

Resolve library worker bundling per:

https://medium.com/adevinta-tech-blog/introducing-web-workers-to-improve-subito-it-performance-part-2-92bcfed8a62

Vite does not support pre-bundling of web workers in dependencies, so we
have to add packages to optimizeDeps.exclude.

gkjohnson/three-gpu-pathtracer#355 (comment)

Some updates in compare-images. Further updates to packages in follow-up
commits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants