Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSP web extension with worker failed #26

Closed
liweijian opened this issue Apr 26, 2023 · 5 comments
Closed

LSP web extension with worker failed #26

liweijian opened this issue Apr 26, 2023 · 5 comments

Comments

@liweijian
Copy link

liweijian commented Apr 26, 2023

I wanna to place this extension under the sample folder:

image

It looks well and it has been deployed to the web server:

sample/moonbit$ ls
dist  language-configuration.json  LICENSE.txt  package.json  README.md  snippets  syntaxes

$ ls dist/
client.js  client.web.js  server.js  server.web.js

However, when I tried to run on web page, there's an error:

"Uncaught NetworkError: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://moonbit/dist/server.web.js' failed to load."

image

For the extension itself, the syntax highlight works, the snippets works. However, auto-complete not work(It depends on the server.web.js), just wondering if anything I'd missed?

And it's weird that the client.web.js loaded succeed:

image

@liweijian
Copy link
Author

liweijian commented Apr 26, 2023

The source code which load the server.web.js:

export function activate(context: ExtensionContext) {
  const clientOptions: LanguageClientOptions = {
    documentSelector: [{ language: 'moonbit' }],
  }
  // Create a worker. The worker main file implements the language server.
  const serverMain = Uri.joinPath(context.extensionUri, 'dist/server.web.js')

  const worker = new Worker(serverMain.toString(true))

  // create the language server client to communicate with the server running in the worker
  const client = new LanguageClient('moonbit', 'Moonbit', clientOptions, worker)

  const disposable = client.start()
  context.subscriptions.push(disposable)
}

This extension works pretty well on VS Code client, not sure if we need to change it to work in web ?

@liweijian
Copy link
Author

I did try to add the script from index.html:

<script src="./moonbit/dist/server.web.js"></script>

But the extension's auto-complete still not work:
image

@liweijian
Copy link
Author

I tried to install it from Open VSX, and got the same error:

image

image

@liweijian liweijian changed the title Script under my own extension failed to load. LSP web extension with worker failed Apr 27, 2023
@liweijian
Copy link
Author

image

And it works in github.dev(see the auto-complete from LSP server)

type u struct {
  x:float
  y:int
}

func init {
    let h = {x:3.1, y:2}
    h.   
}

@lemanschik
Copy link

out of scope for this package this is not a VSCODE Implementation it is the packaging process and the dev dependencies to do your own how ever i could extract out of your screen shoots that you got type errors in your code i saw stuff like mixing of importScript:/// so you did maybe write that wrong some where and maybe 100 other failures you need to get eslint up and running first then typescript then proceed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants