Skip to content

Commit

Permalink
Fix loading of the LSP worker script in the online editor
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tronical committed Feb 3, 2023
1 parent 33dc95f commit a7eaf5a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tools/online_editor/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export default defineConfig(({ command, _mode }) => {
// We need to enable support for bigint
target: "safari14",
},
worker: {
format: "es",
},
};

let global_aliases = {
Expand Down

0 comments on commit a7eaf5a

Please sign in to comment.