Skip to content

Commit

Permalink
feat: add js embedding example
Browse files Browse the repository at this point in the history
  • Loading branch information
x1unix committed Jul 18, 2024
1 parent 0b5a094 commit 56ef7f3
Show file tree
Hide file tree
Showing 9 changed files with 554 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/js/example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.DS_Store
.vscode
.idea
14 changes: 14 additions & 0 deletions internal/js/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Gnopls Embedding Example

This directory contains a bare-minimum code to integrate Gnopls as a WebAssembly module
into browser or Node.js environment.

This example omits such nuances as editor integration or file system support and focuses just on basics.

## Prerequisites

* Copy `wasm_exec.js` file using following command:
* `cp $(go env GOROOT)/misc/wasm/wasm_exec.js .`
* Build gnopls as a WebAssembly file for JavaScript environment:
* `GOOS=js GOARCH=wasm make build`
* Modify paths to `wasm_exec.js` and WASM file in [worker.ts](./worker.ts) file.
251 changes: 251 additions & 0 deletions internal/js/example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions internal/js/example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@types/golang-wasm-exec": "^1.15.2",
"comlink": "^4.4.1",
"monaco-languageclient": "^8.7.0",
"vscode-languageclient": "^9.0.1",
"vscode-languageserver-protocol": "^3.17.5"
}
}
Loading

0 comments on commit 56ef7f3

Please sign in to comment.