Firefox does not handle modules in web workers yet, but that is what we
asked vite to build (to work around a compatibility issue after
upgrading to vite 4). So Chrome worked, but Firefox did not.
This PR adds a pretty ugly work around to that problem.
The good news is: Firefox will apparently be able to handle modules in
web workers starting with 111, so let's hope we do not need this for too
long!
The update to vite 4 triggered the vite 3 bug vitejs/vite#9879
for us, where the wasm-pack generated .js is included as iife and
therefore the use of import.meta.url gets transpiled to some shim that
tries to access the document, assuming that the JS is running in the
browser instead of in a worker environment.
Explicitly set the output type for the worker to ES modules, so that no
changes are needed and import.meta.url remains in use. This matches the
worker invocation anyway, as we pass "type": "module" to the Worker
constructor.
The upgrade of vite from 2 to 4 in commit
5951ae6272 also brought an update of
rollup to version three. That one documents that relative externals are
resolved to absolute paths by default, which explains the symptom that
the online editor tried to load /some/absolute/path/wasm_interpreter.js.
Resolving back to resolve paths fixes it.
* Rework the online editor
Implement something that looks more like an application and e.g. allows
to have dockable widgets, a menu bar and keyboard shortcuts.
* xtask: Handle .css files license information
* xtask: Simplify xtask file regexps
No need for many of the .+/.*, we can group them better with the most
specific matches first and then getting more and more general
afterwards.
* reuse: Add .css files for the online_editor
Enable the Slint LSP in the online editor.
The approach is modeled after the Slint Web extension for VSCode, using
the `monaco-languageclient` packet from NPM.
Use the typical src/ setup used in TS projects and split out the code
for the workers into src/worker so that this can get its own
configuration for the typescript compiler. This is necessary as the
web workers run in a more restricted environment as the rest of the
code and because `dom` and `webworker` can not be used together.
Re-use the wasm interpreter from the web site when building for the web
site. It's built & copied in the CI at the same time, and we can
convince rollup to preserve the relative link for production builds,
while aliasing to the local directory for dev builds.
This brings down the editor to ~2.3MB on my machine.