From 477b32662ff7350ee046ac3e26b004a6be8af679 Mon Sep 17 00:00:00 2001 From: Koen Vlaswinkel Date: Fri, 23 Dec 2022 11:04:17 +0100 Subject: [PATCH] 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. --- extensions/ql-vscode/gulpfile.ts/index.ts | 3 +++ extensions/ql-vscode/gulpfile.ts/typescript.ts | 10 ++++++++++ extensions/ql-vscode/package.json | 4 +--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/extensions/ql-vscode/gulpfile.ts/index.ts b/extensions/ql-vscode/gulpfile.ts/index.ts index b7119199a..9a428898c 100644 --- a/extensions/ql-vscode/gulpfile.ts/index.ts +++ b/extensions/ql-vscode/gulpfile.ts/index.ts @@ -5,6 +5,7 @@ import { checkTypeScript, watchCheckTypeScript, cleanOutput, + copyWasmFiles, } from "./typescript"; import { compileTextMateGrammar } from "./textmate"; import { compileView, watchView } from "./webpack"; @@ -15,6 +16,7 @@ export const buildWithoutPackage = series( cleanOutput, parallel( compileEsbuild, + copyWasmFiles, checkTypeScript, compileTextMateGrammar, compileView, @@ -30,6 +32,7 @@ export { watchCheckTypeScript, watchView, compileEsbuild, + copyWasmFiles, checkTypeScript, injectAppInsightsKey, compileView, diff --git a/extensions/ql-vscode/gulpfile.ts/typescript.ts b/extensions/ql-vscode/gulpfile.ts/typescript.ts index df4905bcc..af00de84d 100644 --- a/extensions/ql-vscode/gulpfile.ts/typescript.ts +++ b/extensions/ql-vscode/gulpfile.ts/typescript.ts @@ -67,3 +67,13 @@ export function checkTypeScript() { export function watchCheckTypeScript() { watch("src/**/*.ts", checkTypeScript); } + +export function copyWasmFiles() { + // We need to copy this file for the source-map package to work. Without this fie, the source-map + // package is not able to load the WASM file because we are not including the full node_modules + // directory. In version 0.7.4, it is not possible to call SourceMapConsumer.initialize in Node environments + // to configure the path to the WASM file. So, source-map will always load the file from `__dirname/mappings.wasm`. + // In version 0.8.0, it may be possible to do this properly by calling SourceMapConsumer.initialize by + // using the "browser" field in source-map's package.json to load the WASM file from a given file path. + return src("node_modules/source-map/lib/mappings.wasm").pipe(dest("out")); +} diff --git a/extensions/ql-vscode/package.json b/extensions/ql-vscode/package.json index 5b9496530..f44b4425e 100644 --- a/extensions/ql-vscode/package.json +++ b/extensions/ql-vscode/package.json @@ -1332,9 +1332,7 @@ }, "scripts": { "build": "gulp", - "watch": "npm-run-all -p watch:*", - "watch:extension": "tsc --watch", - "watch:webpack": "gulp watchView", + "watch": "gulp watch", "test": "npm-run-all -p test:*", "test:unit": "cross-env TZ=UTC LANG=en-US jest --projects test/unit-tests", "test:view": "jest --projects src/view",