From 7129ef83b37757b63e33d402dc27061ecd9af5e6 Mon Sep 17 00:00:00 2001 From: Veesh Goldman Date: Sun, 1 Sep 2024 22:16:29 +0300 Subject: fix: find oniguruma dynamically --- server/src/parser.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/src/parser.ts b/server/src/parser.ts index 700a5a5..4d8c731 100644 --- a/server/src/parser.ts +++ b/server/src/parser.ts @@ -594,7 +594,13 @@ function PackageEndLine(state: ParserState) { return state.codeArray.length; } -const wasmBin = fs.readFileSync(path.join(__dirname, "./../node_modules/vscode-oniguruma/release/onig.wasm")).buffer; +// Resolve the path to the vscode-oniguruma package +const onigurumaPkgPath = path.dirname(require.resolve('vscode-oniguruma/package.json')); +console.log(onigurumaPkgPath); +// Construct the path to onig.wasm +const onigWasmPath = path.join(onigurumaPkgPath, 'release', 'onig.wasm'); +// Read the file +const wasmBin = fs.readFileSync(onigWasmPath).buffer; const vscodeOnigurumaLib = oniguruma.loadWASM(wasmBin).then(() => { return { createOnigScanner(patterns: any) { -- cgit v1.2.3 From 5ff3c85431224b38269c99b7dc4e0229f2fc6149 Mon Sep 17 00:00:00 2001 From: Veesh Goldman Date: Sun, 1 Sep 2024 22:21:56 +0300 Subject: chore: ENOCONSOLELOGS --- server/src/parser.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/server/src/parser.ts b/server/src/parser.ts index 4d8c731..e3d51cf 100644 --- a/server/src/parser.ts +++ b/server/src/parser.ts @@ -596,7 +596,6 @@ function PackageEndLine(state: ParserState) { // Resolve the path to the vscode-oniguruma package const onigurumaPkgPath = path.dirname(require.resolve('vscode-oniguruma/package.json')); -console.log(onigurumaPkgPath); // Construct the path to onig.wasm const onigWasmPath = path.join(onigurumaPkgPath, 'release', 'onig.wasm'); // Read the file -- cgit v1.2.3 From e18a8c9a2a2c4fcf861482af06c050e0cebd05e2 Mon Sep 17 00:00:00 2001 From: Veesh Goldman Date: Fri, 6 Sep 2024 10:27:05 +0300 Subject: fix: safer dynamic finding as fallback --- server/src/parser.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/src/parser.ts b/server/src/parser.ts index e3d51cf..951c8ee 100644 --- a/server/src/parser.ts +++ b/server/src/parser.ts @@ -594,12 +594,16 @@ function PackageEndLine(state: ParserState) { return state.codeArray.length; } -// Resolve the path to the vscode-oniguruma package -const onigurumaPkgPath = path.dirname(require.resolve('vscode-oniguruma/package.json')); -// Construct the path to onig.wasm -const onigWasmPath = path.join(onigurumaPkgPath, 'release', 'onig.wasm'); +// 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) { -- cgit v1.2.3