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.
This commit is contained in:
Koen Vlaswinkel 2022-12-23 11:04:17 +01:00 коммит произвёл Koen Vlaswinkel
Родитель 65696997de
Коммит 477b32662f
3 изменённых файлов: 14 добавлений и 3 удалений

Просмотреть файл

@ -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,

Просмотреть файл

@ -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"));
}

Просмотреть файл

@ -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",