TypeFox / vscode-ws-jsonrpc

NPM module to implement communication between a jsonrpc client and server over WebSocket
https://www.npmjs.com/package/vscode-ws-jsonrpc
MIT License
55 stars 30 forks source link

Usage in browsers #2

Open bali182 opened 6 years ago

bali182 commented 6 years ago

Looking at the example here: https://github.com/TypeFox/monaco-languageclient/blob/master/example/src/client.ts I got the impression that this package is meant to be consumed in the browser. However when I try the above sample (instead of typescript I'm just using js), there is an error because vscode-jsonrpc (used by this module) seems to require the net module which is obviously not available for browsers.

Is this expected? Should I just polyfill the net module?

ERROR in ./node_modules/vscode-jsonrpc/lib/pipeSupport.js
Module not found: Error: Can't resolve 'net' in '/Users/balazs.edes/code/studio-prototype-bitbucket/node_modules/vscode-jsonrpc/lib'
 @ ./node_modules/vscode-jsonrpc/lib/pipeSupport.js 10:12-26
 @ ./node_modules/vscode-jsonrpc/lib/main.js
 @ ./node_modules/vscode-ws-jsonrpc/lib/index.js
 @ ./src/components/TempEditorScreen/connectWithLanguageServer.js
 @ ./src/components/TempEditorScreen/index.js
 @ ./src/components/App/index.js
 @ ./src/index.js
 @ multi (webpack)-dev-server/client?http://localhost:3000 ./src/index.js

ERROR in ./node_modules/vscode-jsonrpc/lib/socketSupport.js
Module not found: Error: Can't resolve 'net' in '/Users/balazs.edes/code/studio-prototype-bitbucket/node_modules/vscode-jsonrpc/lib'
 @ ./node_modules/vscode-jsonrpc/lib/socketSupport.js 7:12-26
 @ ./node_modules/vscode-jsonrpc/lib/main.js
 @ ./node_modules/vscode-ws-jsonrpc/lib/index.js
 @ ./src/components/TempEditorScreen/connectWithLanguageServer.js
 @ ./src/components/TempEditorScreen/index.js
 @ ./src/components/App/index.js
 @ ./src/index.js
 @ multi (webpack)-dev-server/client?http://localhost:3000 ./src/index.js

The error happens just after I require listen:

import { listen } from 'vscode-ws-jsonrpc'

akosyakov commented 6 years ago

@bali182 it is expected to be used in node env as well. Please stub it for now with webpack, having 2 entry points for different envs will be useful.