-
Notifications
You must be signed in to change notification settings - Fork 44
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
Switch purely to module workers. #214
Comments
We've been discouraging the `bundle-global` build for a long time, and it will get infeasible to maintain once we stop supporting the inline string worker workaround. See #214
https://bugzilla.mozilla.org/show_bug.cgi?id=1247687 has been marked as It looks like it might be possible to instantiate module workers, but they error with |
... and reverted, for now: https://bugzilla.mozilla.org/show_bug.cgi?id=1247687#c77 |
Release notes: - [search] Remove the string-based classic worker instantiation fallback. With the release of Firefox 114, all modern browsers support module workers. This allows us to remove a significant amount of code, and load some `cubing.js`-based apps with 1/3 of the code. We will not support fallbacks going forward. For more details, see: #214
This has been merged. #273 covers the release process. |
Release notes: - Switch purely to module workers. - As of [Firefox 114](https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/114), all modern JavaScript browsers and runtimes with worker support are now able to instantiate module workers. This is important for performance, as it significantly improves worker loading for `cubing.js` (requiring ⅓ as much code as before): #214 - Due to the heavy complexity and maintenance burden of alternatives to module workers, `cubing.js` is dropping support for "classic" workers and there is no longer a "catch-all" fallback when worker instantiation fails. In removing this fallback, have carefully made sure `cubing.js` scrambles will continue work out of the box with all modern browsers, as well as the main runtimes that support web worker (`node` and `deno`). We have also tested compatibility against major bundlers. However, if you are passing `cubing.js` through your own choice of bundler, then it must correctly bundle the worker "entry file" using one of the following: - [`import.meta.resolve(…)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve) — this is the only "officially supported" way that we plan to support indefinitely, and the only one that will work without showing a warning in the JavaScript console. - One of two variants of using `new URL(…, import.meta.url)` as an alternative to `import.meta.resolve(…)`. - Using this workaround for `esbuild`: evanw/esbuild#312 (comment)
Release notes: - Switch purely to module workers. - As of [Firefox 114](https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/114), all modern JavaScript browsers and runtimes with worker support are now able to instantiate module workers. This is important for performance, as it significantly improves worker loading for `cubing.js` (requiring ⅓ as much code as before): #214 - Due to the heavy complexity and maintenance burden of alternatives to module workers, `cubing.js` is dropping support for "classic" workers and there is no longer a "catch-all" fallback when worker instantiation fails. In removing this fallback, have carefully made sure `cubing.js` scrambles will continue work out of the box with all modern browsers, as well as the main runtimes that support web worker (`node` and `deno`). We have also tested compatibility against major bundlers. However, if you are passing `cubing.js` through your own choice of bundler, then it must correctly bundle the worker "entry file" using one of the following: - [`import.meta.resolve(…)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve) — this is the only "officially supported" way that we plan to support indefinitely, and the only one that will work without showing a warning in the JavaScript console. - One of two variants of using `new URL(…, import.meta.url)` as an alternative to `import.meta.resolve(…)`. - Using this workaround for `esbuild`: evanw/esbuild#312 (comment)
We have several workarounds for environments that don't support module workers. All environments except Firefox have already supported them for over a year: https://caniuse.com/mdn-api_worker_worker_ecmascript_modules
But Firefox is slowly making progress: https://bugzilla.mozilla.org/show_bug.cgi?id=1247687
I don't want to break Firefox users, but I want to be ready to remove all our workarounds as soon as module worker support lands in a stable version of Firefox. Then we can tell Firefox users to update, rather than asking them to use a different browser.
Some details:
cubing/alg
).cubing.js/script/build/targets.js
Lines 130 to 191 in 48d9af3
cubing.js
take three times the amount of downloaded code with the fallback.src
tree, but also excluded fromgit
, linting, etc. Even trying to exclude it fromrome
will probably require more annoying, hacky workarounds.make build-esm
will briefly interruptmake dev
, which causes an error. (Also, ifEXPERIMENTAL_CUBING_JS_RELOAD_CHROME_MACOS
is set, it will refresh the current page. In fact, this behaviour caused me to lose 15 minutes work while typing up this very issue.)node
andcomlink
. Those are stable right now, but I'm certain I'll have to spend a few more hours on them in the future.import.meta.url
in worker entry files parcel-bundler/parcel#7623).The ecosystem is finally converging on module workers, and
esbuild
will soon have support fornew URL("./relative.js", import.meta.url)
. Onceesbuild
has that syntax, we can switch to a single canonical implementation that works in all major bundlers (including Parcel).Steps we need to take:
bundle-global
build, which will not be worth maintaining now that it can no longer be a single file. It's only stuck around this long becauseesbuild
is really fast at generating it. We've been discouraging its use already (it is convenient, but it suffers from several anti-patterns and we don't make it easy to download the build), but I want to stop supporting it. There are workarounds for anyone who wants to do "flat-file" development, such as using the CDN or vendoring the ESM build into a folder. If anyone finds an important use case that we'd be leaving behind, we'll hopefully be able to learn about this before we break our ability to support it.search-worker-inside-generated-string.js
. Document the removal of the inline string worker fallback and provide a canonical reference on compatibility.The text was updated successfully, but these errors were encountered: