diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5b40d53..d88a42d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: run: npm clean-install && npm run postinstall - name: Build package - run: npm run compile + run: npm run esbuild - name: Test language server run: npm run test:server diff --git a/.gitignore b/.gitignore index 0716848..9761efa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .vscode-test -client/server modelica-language-server*.vsix -node_modules -out +node_modules/ +out/ diff --git a/.vscode/launch.json b/.vscode/launch.json index 815d6b4..f5b149e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,19 +4,19 @@ "version": "0.2.0", "configurations": [ { + "name": "Launch Client", "type": "extensionHost", "request": "launch", - "name": "Launch Client", "runtimeExecutable": "${execPath}", "args": [ "--extensionDevelopmentPath=${workspaceRoot}" ], "outFiles": [ - "${workspaceRoot}/client/out/**/*.js" + "${workspaceRoot}/out/**/*.js" ], "preLaunchTask": { "type": "npm", - "script": "watch" + "script": "esbuild-watch" } }, { @@ -31,7 +31,11 @@ ], "outFiles": [ "${workspaceRoot}/client/out/test/**/*.js" - ] + ], + "preLaunchTask": { + "type": "npm", + "script": "test-compile" + } } ] } diff --git a/.vscodeignore b/.vscodeignore index 9194345..53186a8 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -1,15 +1,16 @@ +!server/OSMC-License.txt +.eslintignore +.github +.gitignore +.travis.yml .vscode/** -**/*.ts **/*.map -.gitignore -**/tsconfig.json +**/*.ts **/tsconfig.base.json +**/tsconfig.json +client/ contributing.md -.travis.yml -client/node_modules/** -!client/node_modules/vscode-jsonrpc/** -!client/node_modules/vscode-languageclient/** -!client/node_modules/vscode-languageserver-protocol/** -!client/node_modules/vscode-languageserver-types/** -!client/node_modules/{minimatch,brace-expansion,concat-map,balanced-match}/** -!client/node_modules/{semver,lru-cache,yallist}/** +esbuild.config.js +node_modules/ +scripts/ +server/ diff --git a/LICENCE.md b/LICENSE.md similarity index 100% rename from LICENCE.md rename to LICENSE.md diff --git a/README.md b/README.md index c22a63c..ad05d99 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,8 @@ Check the Marketplace for ## Building the Language Server - - Run `npm install` in this folder. This installs all necessary npm modules in - both the client and server folder + - Run `npm install` and `npm run postinstall` in this folder.This installs all + necessary npm modules in both the client and server folder - Open VS Code on this folder. - Press Ctrl+Shift+B to start compiling the client and server in [watch mode](https://code.visualstudio.com/docs/editor/tasks#:~:text=The%20first%20entry%20executes,the%20HelloWorld.js%20file.). @@ -59,10 +59,8 @@ npx vsce package ## License -Copyright (C) 2023-2024 Andreas Heuermann, Osman Karabel - modelica-language-server is licensed under the -GNU Affero General Public License v3, see [COPYING.md](./COPYING.md). +GNU Affero General Public License v3, see [LICENSE.md](./LICENSE.md). ### 3rd Party Licenses @@ -71,8 +69,8 @@ This extension is based on licensed under MIT license. Some parts of the source code are taken from -[bash-language-server](https://github.com/bash-lsp/bash-language-server), -licensed under the MIT license, and adapted to the Modelica language server. +[bash-lsp/bash-language-server](https://github.com/bash-lsp/bash-language-server), +licensed under the MIT license and adapted to the Modelica language server. [OpenModelica/tree-sitter-modelica](https://github.com/OpenModelica/tree-sitter-modelica) v0.2.0 is included in this extension and is licensed under the [OSMC-PL diff --git a/client/src/extension.ts b/client/src/extension.ts index f95fd15..210e7f6 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -17,6 +17,7 @@ */ import * as path from 'path'; +import * as fs from 'fs'; import { languages, workspace, ExtensionContext, TextDocument } from 'vscode'; import { LanguageClient, @@ -25,6 +26,7 @@ import { TransportKind } from 'vscode-languageclient/node'; import { getFileExtension, getLanguage } from './getLanguage'; +import { fstat } from 'fs'; let client: LanguageClient; @@ -53,10 +55,13 @@ export function activate(context: ExtensionContext) { } }); - // The server is implemented in node + // The server is implemented in node, point to packed module const serverModule = context.asAbsolutePath( - path.join('server', 'out', 'server.js') + path.join('out', 'server.js') ); + if (!fs.existsSync(serverModule)) { + throw new Error(`Can't find server module in ${serverModule}`); + } // If the extension is launched in debug mode then the debug server options are used // Otherwise the run options are used diff --git a/client/src/test/symbolinformation.test.ts b/client/src/test/symbolinformation.test.ts index c61c4ba..6b52aaf 100644 --- a/client/src/test/symbolinformation.test.ts +++ b/client/src/test/symbolinformation.test.ts @@ -111,4 +111,4 @@ function assertDocumentSymbolsEqual(expected: vscode.DocumentSymbol[], actual: v // Recursive check for children symbols assertDocumentSymbolsEqual(expectedSymbol.children || [], actualSymbol.children || []); } -} \ No newline at end of file +} diff --git a/esbuild.config.js b/esbuild.config.js new file mode 100644 index 0000000..11c6c9a --- /dev/null +++ b/esbuild.config.js @@ -0,0 +1,39 @@ +const esbuild = require('esbuild'); +const fs = require('fs'); + +// Build client +esbuild.build({ + entryPoints: [ + './client/src/extension.ts' + ], + bundle: true, + outfile: './out/client.js', + platform: 'node', + external: [ + 'vscode' + ], + format: 'cjs', + tsconfig: './client/tsconfig.json', +}).catch(() => process.exit(1)); + +// Build server +esbuild.build({ + entryPoints: [ + './server/src/server.ts' + ], + bundle: true, + outfile: './out/server.js', + platform: 'node', + external: [ + 'vscode', + ], + format: 'cjs', + tsconfig: './server/tsconfig.json', +}).catch(() => process.exit(1)); + +// Copy tree-sitter.wasm and tree-sitter-modelica.wasm to the output directory +if (!fs.existsSync('out')) { + fs.mkdirSync('out'); +} +fs.copyFileSync('./server/src/tree-sitter-modelica.wasm', './out/tree-sitter-modelica.wasm'); +fs.copyFileSync('./server/node_modules/web-tree-sitter/tree-sitter.wasm', './out/tree-sitter.wasm'); diff --git a/package-lock.json b/package-lock.json index f84cdad..7f0b1ac 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@types/node": "^20.10.4", "@typescript-eslint/eslint-plugin": "^6.13.2", "@typescript-eslint/parser": "^6.13.2", + "esbuild": "^0.20.0", "eslint": "^8.55.0", "mocha": "^10.2.0", "ts-node": "^10.9.1", @@ -44,6 +45,374 @@ "node": ">=12" } }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.20.0.tgz", + "integrity": "sha512-fGFDEctNh0CcSwsiRPxiaqX0P5rq+AqE0SRhYGZ4PX46Lg1FNR6oCxJghf8YgY0WQEgQuh3lErUFE4KxLeRmmw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.20.0.tgz", + "integrity": "sha512-3bMAfInvByLHfJwYPJRlpTeaQA75n8C/QKpEaiS4HrFWFiJlNI0vzq/zCjBrhAYcPyVPG7Eo9dMrcQXuqmNk5g==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.20.0.tgz", + "integrity": "sha512-aVpnM4lURNkp0D3qPoAzSG92VXStYmoVPOgXveAUoQBWRSuQzt51yvSju29J6AHPmwY1BjH49uR29oyfH1ra8Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.20.0.tgz", + "integrity": "sha512-uK7wAnlRvjkCPzh8jJ+QejFyrP8ObKuR5cBIsQZ+qbMunwR8sbd8krmMbxTLSrDhiPZaJYKQAU5Y3iMDcZPhyQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.20.0.tgz", + "integrity": "sha512-AjEcivGAlPs3UAcJedMa9qYg9eSfU6FnGHJjT8s346HSKkrcWlYezGE8VaO2xKfvvlZkgAhyvl06OJOxiMgOYQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.20.0.tgz", + "integrity": "sha512-bsgTPoyYDnPv8ER0HqnJggXK6RyFy4PH4rtsId0V7Efa90u2+EifxytE9pZnsDgExgkARy24WUQGv9irVbTvIw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.20.0.tgz", + "integrity": "sha512-kQ7jYdlKS335mpGbMW5tEe3IrQFIok9r84EM3PXB8qBFJPSc6dpWfrtsC/y1pyrz82xfUIn5ZrnSHQQsd6jebQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.20.0.tgz", + "integrity": "sha512-uG8B0WSepMRsBNVXAQcHf9+Ko/Tr+XqmK7Ptel9HVmnykupXdS4J7ovSQUIi0tQGIndhbqWLaIL/qO/cWhXKyQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.20.0.tgz", + "integrity": "sha512-2ezuhdiZw8vuHf1HKSf4TIk80naTbP9At7sOqZmdVwvvMyuoDiZB49YZKLsLOfKIr77+I40dWpHVeY5JHpIEIg==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.20.0.tgz", + "integrity": "sha512-uTtyYAP5veqi2z9b6Gr0NUoNv9F/rOzI8tOD5jKcCvRUn7T60Bb+42NDBCWNhMjkQzI0qqwXkQGo1SY41G52nw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.20.0.tgz", + "integrity": "sha512-c88wwtfs8tTffPaoJ+SQn3y+lKtgTzyjkD8NgsyCtCmtoIC8RDL7PrJU05an/e9VuAke6eJqGkoMhJK1RY6z4w==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.20.0.tgz", + "integrity": "sha512-lR2rr/128/6svngnVta6JN4gxSXle/yZEZL3o4XZ6esOqhyR4wsKyfu6qXAL04S4S5CgGfG+GYZnjFd4YiG3Aw==", + "cpu": [ + "loong64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.20.0.tgz", + "integrity": "sha512-9Sycc+1uUsDnJCelDf6ZNqgZQoK1mJvFtqf2MUz4ujTxGhvCWw+4chYfDLPepMEvVL9PDwn6HrXad5yOrNzIsQ==", + "cpu": [ + "mips64el" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.20.0.tgz", + "integrity": "sha512-CoWSaaAXOZd+CjbUTdXIJE/t7Oz+4g90A3VBCHLbfuc5yUQU/nFDLOzQsN0cdxgXd97lYW/psIIBdjzQIwTBGw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.20.0.tgz", + "integrity": "sha512-mlb1hg/eYRJUpv8h/x+4ShgoNLL8wgZ64SUr26KwglTYnwAWjkhR2GpoKftDbPOCnodA9t4Y/b68H4J9XmmPzA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.20.0.tgz", + "integrity": "sha512-fgf9ubb53xSnOBqyvWEY6ukBNRl1mVX1srPNu06B6mNsNK20JfH6xV6jECzrQ69/VMiTLvHMicQR/PgTOgqJUQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.20.0.tgz", + "integrity": "sha512-H9Eu6MGse++204XZcYsse1yFHmRXEWgadk2N58O/xd50P9EvFMLJTQLg+lB4E1cF2xhLZU5luSWtGTb0l9UeSg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.20.0.tgz", + "integrity": "sha512-lCT675rTN1v8Fo+RGrE5KjSnfY0x9Og4RN7t7lVrN3vMSjy34/+3na0q7RIfWDAj0e0rCh0OL+P88lu3Rt21MQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.20.0.tgz", + "integrity": "sha512-HKoUGXz/TOVXKQ+67NhxyHv+aDSZf44QpWLa3I1lLvAwGq8x1k0T+e2HHSRvxWhfJrFxaaqre1+YyzQ99KixoA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.20.0.tgz", + "integrity": "sha512-GDwAqgHQm1mVoPppGsoq4WJwT3vhnz/2N62CzhvApFD1eJyTroob30FPpOZabN+FgCjhG+AgcZyOPIkR8dfD7g==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.20.0.tgz", + "integrity": "sha512-0vYsP8aC4TvMlOQYozoksiaxjlvUcQrac+muDqj1Fxy6jh9l9CZJzj7zmh8JGfiV49cYLTorFLxg7593pGldwQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.20.0.tgz", + "integrity": "sha512-p98u4rIgfh4gdpV00IqknBD5pC84LCub+4a3MO+zjqvU5MVXOc3hqR2UgT2jI2nh3h8s9EQxmOsVI3tyzv1iFg==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.20.0.tgz", + "integrity": "sha512-NgJnesu1RtWihtTtXGFMU5YSE6JyyHPMxCwBZK7a6/8d31GuSo9l0Ss7w1Jw5QnKUawG6UEehs883kcXf5fYwg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -800,6 +1169,44 @@ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, + "node_modules/esbuild": { + "version": "0.20.0", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.20.0.tgz", + "integrity": "sha512-6iwE3Y2RVYCME1jLpBqq7LQWK3MW6vjV2bZy6gt/WrqkY+WE74Spyc0ThAOYpMtITvnjX09CrC6ym7A/m9mebA==", + "dev": true, + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.20.0", + "@esbuild/android-arm": "0.20.0", + "@esbuild/android-arm64": "0.20.0", + "@esbuild/android-x64": "0.20.0", + "@esbuild/darwin-arm64": "0.20.0", + "@esbuild/darwin-x64": "0.20.0", + "@esbuild/freebsd-arm64": "0.20.0", + "@esbuild/freebsd-x64": "0.20.0", + "@esbuild/linux-arm": "0.20.0", + "@esbuild/linux-arm64": "0.20.0", + "@esbuild/linux-ia32": "0.20.0", + "@esbuild/linux-loong64": "0.20.0", + "@esbuild/linux-mips64el": "0.20.0", + "@esbuild/linux-ppc64": "0.20.0", + "@esbuild/linux-riscv64": "0.20.0", + "@esbuild/linux-s390x": "0.20.0", + "@esbuild/linux-x64": "0.20.0", + "@esbuild/netbsd-x64": "0.20.0", + "@esbuild/openbsd-x64": "0.20.0", + "@esbuild/sunos-x64": "0.20.0", + "@esbuild/win32-arm64": "0.20.0", + "@esbuild/win32-ia32": "0.20.0", + "@esbuild/win32-x64": "0.20.0" + } + }, "node_modules/escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", diff --git a/package.json b/package.json index 7696281..e553eea 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "activationEvents": [ "onLanguage:modelica" ], - "main": "./client/out/extension", + "main": "./out/client", "contributes": { "languages": [ { @@ -43,12 +43,14 @@ ] }, "scripts": { - "vscode:prepublish": "npm run compile", - "compile": "tsc -b", - "watch": "tsc -b -w", + "vscode:prepublish": "npm run esbuild-base -- --minify", + "esbuild-base": "node esbuild.config.js", + "esbuild": "npm run esbuild-base -- --sourcemap", + "esbuild-watch": "npm run esbuild-base -- --sourcemap --watch", + "test-compile": "tsc -b ./", "lint": "eslint ./client/src ./server/src --ext .ts,.tsx", "postinstall": "cd client && npm install && cd ../server && npm install && cd ..", - "test": "sh ./scripts/e2e.sh", + "test": "npm run test-compile && sh ./scripts/e2e.sh", "test:server": "cd server && npx mocha -r ts-node/register src/test/**/*.test.ts src/util/test/**/*.test.ts" }, "devDependencies": { @@ -56,6 +58,7 @@ "@types/node": "^20.10.4", "@typescript-eslint/eslint-plugin": "^6.13.2", "@typescript-eslint/parser": "^6.13.2", + "esbuild": "^0.20.0", "eslint": "^8.55.0", "mocha": "^10.2.0", "ts-node": "^10.9.1", diff --git a/scripts/e2e.sh b/scripts/e2e.sh index 860c62e..2a4ff73 100644 --- a/scripts/e2e.sh +++ b/scripts/e2e.sh @@ -3,4 +3,4 @@ export CODE_TESTS_PATH="$(pwd)/client/out/test" export CODE_TESTS_WORKSPACE="$(pwd)/client/testFixture" -node "$(pwd)/client/out/test/runTest" \ No newline at end of file +node "$(pwd)/client/out/test/runTest" diff --git a/server/src/parser.ts b/server/src/parser.ts index dbb80ab..7830599 100644 --- a/server/src/parser.ts +++ b/server/src/parser.ts @@ -22,7 +22,9 @@ * ----------------------------------------------------------------------------- */ -import * as Parser from 'web-tree-sitter'; +import Parser from 'web-tree-sitter'; +import * as fs from 'fs'; +import * as path from 'path'; /** * Initialize tree-sitter parser and load Modelica language. @@ -33,7 +35,12 @@ export async function initializeParser(): Promise { await Parser.init(); const parser = new Parser; - const Modelica = await Parser.Language.load(`${__dirname}/../tree-sitter-modelica.wasm`); + const modelicaWasmFile = path.join(__dirname, 'tree-sitter-modelica.wasm'); + if (!fs.existsSync(modelicaWasmFile)) { + throw new Error(`Can't find 'tree-sitter-modelica.wasm' at ${modelicaWasmFile}`); + } + + const Modelica = await Parser.Language.load(modelicaWasmFile); parser.setLanguage(Modelica); return parser; diff --git a/server/tree-sitter-modelica.wasm b/server/src/tree-sitter-modelica.wasm similarity index 100% rename from server/tree-sitter-modelica.wasm rename to server/src/tree-sitter-modelica.wasm diff --git a/server/tsconfig.json b/server/tsconfig.json index 5aba7a2..3798269 100644 --- a/server/tsconfig.json +++ b/server/tsconfig.json @@ -10,7 +10,8 @@ "sourceMap": true, "strict": true, "outDir": "out", - "rootDir": "src" + "rootDir": "src", + "esModuleInterop": true }, "include": [ "src",