Skip to content

Commit 477b326

Browse files
committed
Copy WASM file from source-map
This will copy the WASM file from source-map to the output directory. This makes the source-map package work. See the comment in the code for more details.
1 parent 6569699 commit 477b326

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

extensions/ql-vscode/gulpfile.ts/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
checkTypeScript,
66
watchCheckTypeScript,
77
cleanOutput,
8+
copyWasmFiles,
89
} from "./typescript";
910
import { compileTextMateGrammar } from "./textmate";
1011
import { compileView, watchView } from "./webpack";
@@ -15,6 +16,7 @@ export const buildWithoutPackage = series(
1516
cleanOutput,
1617
parallel(
1718
compileEsbuild,
19+
copyWasmFiles,
1820
checkTypeScript,
1921
compileTextMateGrammar,
2022
compileView,
@@ -30,6 +32,7 @@ export {
3032
watchCheckTypeScript,
3133
watchView,
3234
compileEsbuild,
35+
copyWasmFiles,
3336
checkTypeScript,
3437
injectAppInsightsKey,
3538
compileView,

extensions/ql-vscode/gulpfile.ts/typescript.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,13 @@ export function checkTypeScript() {
6767
export function watchCheckTypeScript() {
6868
watch("src/**/*.ts", checkTypeScript);
6969
}
70+
71+
export function copyWasmFiles() {
72+
// We need to copy this file for the source-map package to work. Without this fie, the source-map
73+
// package is not able to load the WASM file because we are not including the full node_modules
74+
// directory. In version 0.7.4, it is not possible to call SourceMapConsumer.initialize in Node environments
75+
// to configure the path to the WASM file. So, source-map will always load the file from `__dirname/mappings.wasm`.
76+
// In version 0.8.0, it may be possible to do this properly by calling SourceMapConsumer.initialize by
77+
// using the "browser" field in source-map's package.json to load the WASM file from a given file path.
78+
return src("node_modules/source-map/lib/mappings.wasm").pipe(dest("out"));
79+
}

extensions/ql-vscode/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,9 +1332,7 @@
13321332
},
13331333
"scripts": {
13341334
"build": "gulp",
1335-
"watch": "npm-run-all -p watch:*",
1336-
"watch:extension": "tsc --watch",
1337-
"watch:webpack": "gulp watchView",
1335+
"watch": "gulp watch",
13381336
"test": "npm-run-all -p test:*",
13391337
"test:unit": "cross-env TZ=UTC LANG=en-US jest --projects test/unit-tests",
13401338
"test:view": "jest --projects src/view",

0 commit comments

Comments
 (0)