diff options
author | bscan <10503608+bscan@users.noreply.github.com> | 2024-09-06 14:33:54 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-06 14:33:54 -0400 |
commit | a02f86e1b18f619041ebcd5d4f7d4aaa6c8fa535 (patch) | |
tree | 5e1788520fc4ccd40e277a44c287ed57774fd3cb | |
parent | 597da6f89d6cd6f9dac2c39a8ce02e449345c6e4 (diff) | |
parent | e18a8c9a2a2c4fcf861482af06c050e0cebd05e2 (diff) | |
download | PerlNavigator-a02f86e1b18f619041ebcd5d4f7d4aaa6c8fa535.zip |
Merge pull request #141 from rabbiveesh/veesh/find-onigwasm-dynamically
Find onig.wasm dynamically
-rw-r--r-- | server/src/parser.ts | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/server/src/parser.ts b/server/src/parser.ts index 700a5a5..951c8ee 100644 --- a/server/src/parser.ts +++ b/server/src/parser.ts @@ -594,7 +594,16 @@ function PackageEndLine(state: ParserState) { return state.codeArray.length; } -const wasmBin = fs.readFileSync(path.join(__dirname, "./../node_modules/vscode-oniguruma/release/onig.wasm")).buffer; +// we first try to find by absolute path, which is needed in webpack +let onigWasmPath = path.join(__dirname, "./../node_modules/vscode-oniguruma/release/onig.wasm") +if (!fs.existsSync(onigWasmPath)) { + // dynmacially retrieve the path to onig.wasm (we need to eval the require to stop webpack from + // bundling the wasm, which doesn't werk) + onigWasmPath = eval('require.resolve')('vscode-oniguruma/release/onig.wasm'); +} +// Read the file +const wasmBin = fs.readFileSync(onigWasmPath).buffer; + const vscodeOnigurumaLib = oniguruma.loadWASM(wasmBin).then(() => { return { createOnigScanner(patterns: any) { |