Skip to content

Commit

Permalink
fix wrong size
Browse files Browse the repository at this point in the history
  • Loading branch information
guyutongxue committed Jan 30, 2024
1 parent 8ecfb86 commit 59350f0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const jsModule = import( /* @vite-ignore */ `${wasmBase}clangd.js`);

// Pre-fetch wasm, and report progress to main
const wasmResponse = await fetch(wasmUrl);
const wasmSize = wasmResponse.headers.get("Content-Length");
const wasmSize = wasmResponse.headers.get("Content-Length") ?? __WASM_SIZE__;
const wasmReader = wasmResponse.body!.getReader();
let receivedLength = 0;
let chunks: Uint8Array[] = [];
Expand Down
2 changes: 2 additions & 0 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/// <reference types="vite/client" />

declare const __WASM_SIZE__: number;
4 changes: 4 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,9 @@ export default defineConfig({
},
resolve: {
dedupe: ['monaco-editor', 'vscode'],
},
define: {
// Server may not provide Content-Length header, get it in build time
__WASM_SIZE__: fs.statSync("public/wasm/clangd.wasm").size,
}
});

0 comments on commit 59350f0

Please sign in to comment.