rhaiscript / lsp

Language server for Rhai.
Apache License 2.0
43 stars 4 forks source link

Feat-cli-and-wasm #79

Closed tamasfe closed 2 years ago

tamasfe commented 2 years ago

The following was added:

I pretty much copied the architecture I use for publishing stuff for taplo.

schungx commented 2 years ago

the vscode extension can be standalone now with the LSP bundled with it.

Do we need to make pre-built binaries? Or everything in wasm?

tamasfe commented 2 years ago

Do we need to make pre-built binaries? Or everything in wasm?

No need for platform-specific stuff, all WASM. The native cli is still a lot better for debugging and faster development, the vscode extension can use both.

schungx commented 2 years ago

For some reason the latest drop fails to start:

Error: Cannot find module '@rhaiscript/lsp'
Require stack:
- c:\Users\Stephen\.vscode\extensions\tamasfe.rhai-0.0.0\dist\server.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
    at Module._load (node:internal/modules/cjs/loader:832:27)
    at Function.c._load (node:electron/js2c/asar_bundle:5:13343)
    at Module.require (node:internal/modules/cjs/loader:1059:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (c:\Users\Stephen\.vscode\extensions\tamasfe.rhai-0.0.0\dist\server.js:1:105)
    at Module._compile (node:internal/modules/cjs/loader:1163:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1216:10)
    at Module.load (node:internal/modules/cjs/loader:1035:32)
    at Module._load (node:internal/modules/cjs/loader:876:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'c:\\Users\\Stephen\\.vscode\\extensions\\tamasfe.rhai-0.0.0\\dist\\server.js'
  ]
}
schungx commented 2 years ago

OK, I think something that has to do with the fact that Windows does not have symbolic links.

So the build on lsp failed because core couldn't be found.

Fixing...

schungx commented 2 years ago

OK, I got stuck on this:

$ vsce package --no-yarn
Executing prepublish script 'npm run vscode:prepublish'...

> rhai@0.0.0 vscode:prepublish
> yarn build

yarn run v1.22.19
warning rhai@0.0.0: The engine "vscode" appears to be invalid.
$ rm -rf dist && yarn build:syntax && yarn build:node
warning rhai@0.0.0: The engine "vscode" appears to be invalid.
$ js-yaml syntax/rhai.tmLanguage.yaml > syntax/rhai.tmLanguage.json
warning rhai@0.0.0: The engine "vscode" appears to be invalid.
$ rollup -c rollup.config.js

src/server.ts, src/extension.ts → dist...
(!) Circular dependency
node_modules/semver/classes/comparator.js -> node_modules/semver/classes/range.js -> node_modules/semver/classes/comparator.js
created dist in 6.3s
Done in 7.53s.
This extension consists of 1950 files, out of which 564 are JavaScript files. For performance reasons, you should bundle your extension: https://aka.ms/vscode-bundle-extension . You should also exclude unnecessary files by adding them to your .vscodeignore: https://aka.ms/vscode-vscodeignore
 ERROR  invalid relative path: extension/../../js/core/node_modules/@rollup/plugin-commonjs/dist/cjs/index.js
schungx commented 2 years ago

The relative paths ../js/core/ etc. are really tripping up Windows.

tamasfe commented 2 years ago

Great, js environments are always a pain, I can't even imagine it on windows. I've fought with relative local packages in yarn before even on linux.

Alternatively we can publish the packages on npm and just pull them from there in the extension. That's what I intend to do anyway I just didn't want to publish WIP stuff if it's not necessary.

schungx commented 2 years ago

I'm just trying to resolve it such that it builds...

tamasfe commented 2 years ago

I know, you can try yarn pack, or npm pack and then add the .tar.gz as a dependency, it should be pretty similar to pulling it from npm.

I'll boot up a vm and see if I can get it working as well.

schungx commented 2 years ago

This occurs when I cleaned it up and changed file:../ to ../

Running yarn in editors/vscode

$ yarn
yarn install v1.22.19
info No lockfile found.
[1/5] Validating package.json...
warning rhai@0.0.0: The engine "vscode" appears to be invalid.
[2/5] Resolving packages...
error Package "" refers to a non-existing file '"C:\\Git\\rhai-lsp\\editors\\core"'.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
schungx commented 2 years ago

Well, I'm totally stuck. I can't build the thing on Windows.

Something to do with yarn and not find the rollup command and broken relative paths etc.

I've spun up a small cloud Ubuntu VM and tried it there, but it seems to have loads of trouble as well. Probably the toolchain not being setup completely...

tamasfe commented 2 years ago

Alright, I've went through the steps in an almost empty windows vm and updated the readme with them on master.

schungx commented 2 years ago

Ah, so it seems yarn install --force is the missing command that I omitted!

The extension builds cleanly except for a few warnings:

warning rhai@0.0.0: The engine "vscode" appears to be invalid.
$ yarn build:syntax && yarn build:node
warning rhai@0.0.0: The engine "vscode" appears to be invalid.
$ js-yaml syntax/rhai.tmLanguage.yaml > syntax/rhai.tmLanguage.json
warning rhai@0.0.0: The engine "vscode" appears to be invalid.
$ rollup -c rollup.config.js

I wonder if we can make a rebuild shell script to automate this, although I guess it shouldn't be difficult to manually rebuild.