Skip to content

Commit

Permalink
Fix VS code extension not loading when building with latest wasm-pack
Browse files Browse the repository at this point in the history
The latest wasm-pack version creates, by default, a package.json
that has a "type": "module" entry in it.

We invoke wasm-pack to build the lsp module and store it in the out/
folder. Next we run esbuild to place out/extension.js - the main entry
point - into the same directory. That directory now also has the
wasm-pack generated package.json, which has the "type": "module", which
doesn't match our CJS out/extension.js.

When VS code does require("/path/to/extension/out/extension.js"),
node.js complains that extension.js is not an ESM because
out/package.json claims that it should be.

The fix here is to not generate the package.json file we don't need
anyway.
  • Loading branch information
tronical committed Jul 3, 2024
1 parent 4a1bb19 commit 97de0d8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions editors/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@
"vscode:prepublish": "npm run build:wasm_lsp-release && npm run compile && shx echo \"GPL-3.0-only OR LicenseRef-Slint-Software-3.0\" > LICENSE.txt",
"build:lsp": "cargo build -p slint-lsp",
"build:lsp-release": "cargo build --release -p slint-lsp",
"build:wasm_lsp": "env-var wasm-pack build --dev --target web ../../tools/lsp --out-dir {{npm_config_local_prefix}}/out -- --no-default-features --features backend-winit,renderer-femtovg,preview",
"build:wasm_lsp-release": "env-var wasm-pack build --release --target web ../../tools/lsp --out-dir {{npm_config_local_prefix}}/out -- --no-default-features --features backend-winit,renderer-femtovg,preview",
"build:wasm_lsp": "env-var wasm-pack build --dev --target web --no-pack ../../tools/lsp --out-dir {{npm_config_local_prefix}}/out -- --no-default-features --features backend-winit,renderer-femtovg,preview",
"build:wasm_lsp-release": "env-var wasm-pack build --release --target web --no-pack ../../tools/lsp --out-dir {{npm_config_local_prefix}}/out -- --no-default-features --features backend-winit,renderer-femtovg,preview",
"compile": "node ./esbuild.js",
"local-package": "shx mkdir -p bin && shx cp ../../target/debug/slint-lsp* bin/ && npx vsce package",
"watch": "tsc -watch -p ./",
Expand Down

0 comments on commit 97de0d8

Please sign in to comment.