-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Workers as ESM, remove RequireJS #11400
Conversation
Thanks for the pull request @ggetz!
Reviewers, don't forget to make sure that:
|
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.
Thanks @ggetz, it's nice to get rid of an old dependency!
How do I measure the worker built size? If I just run du -h
on the Build/CesiumUnminified/Workers
and /Build/Cesium/Workers
paths, I get 2.3M for unminified, 1.1M for minified.
Other than that, I just have one question about the TestWorkers
path.
@@ -1372,7 +1357,7 @@ export async function runCoverage(options) { | |||
// Static assets are always served from the shared/combined folders. | |||
{ pattern: "Build/CesiumUnminified/**", included: false }, | |||
{ pattern: "Specs/Data/**", included: false }, | |||
{ pattern: "Specs/TestWorkers/**", included: false }, | |||
{ pattern: "Build/Specs/TestWorkers/**", included: false }, | |||
{ pattern: "Specs/TestWorkers/**/*.wasm", included: false }, |
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.
Most of these paths are changed from "Specs/TestWorkers"
to "Build/Specs/TestWorkers"
. The remaining "Specs/Testworkers/**/*.wasm"
pattern is only matching "Specs/Testworkers/TestWasm/testWasm.wasm"
, is that correct?
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.
The .js files require a build, but the .wasm files are already built so can be included directly from their original directory. I'll add the .js extension to the blobs to be clear.
travis/release.sh
Outdated
@@ -5,6 +5,7 @@ if [ $TRAVIS_BRANCH == "cesium.com" ]; then | |||
else | |||
npm --silent run make-zip | |||
npm pack &> /dev/null | |||
npm pack --workspaces &> /dev/null |
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.
This was added to ensure the parent cesium
package installs the working version of each workspace package, not the official published version.
Thanks @jjhembd! This should be ready to go. |
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.
Looks good, thanks @ggetz!
Fixes #9024
Firefox added support for ESM workers as of 114 released in June. This was the last holdout among browsers for support of this feature.
When updating our build process, this prevented us from using ebuild to bundle workers, needing to fallback to rollup to bundle as AMD, and to include a copy of RequireJS which has security implications and does not play nicely with all bundlers.
Given the support in Firefox, we can now revisit how we handle workers and simplify things a bit.
cesiumWorkerBootstrapper
as it should no longer be needed given how import works in ESM modulescesiumWorkerBootstrapper
in order to facilitate dynamic module loading.- We still bundle each worker individually with code splitting, and load the workers dynamically at runtime. I'd like to leave changing the distribution method to work for Inline Static Assets in Builds #10619 to keep the scope of this contained.
Workers
ThirdParty/Workers/basis_transcoder.js
with an extraza
appended which I can only assume was added accidentally that has been removed.I3S*
classes to better fit the pattern established by Draco and KTX2 decoding for using web workers with Web Assembly.There is still a significant number of users that are not up-to-date on the compatible Firefox version. When using incompatible versions of FF, there following error is shown:
Stats
Worker build times
Measured by adding timing output around
bundleWorkers
.main
workers-as-esm
Worker built size
To measure this, I started built from a clean repository:
Sizes are the sum of the
Build/X/Workers
andBuild/X/ThirdParty/Workers
directories, where X is "CesiumUnminified" or "Cesium".main
workers-as-esm
Minification here is at least constant with previous sizes, but it should be possible to get sizes of bundles down even further using terser directly.
– ESBuild docs
TODO
CHANGES.md