Skip to content

Commit 6446de0

Browse files
committed
Attempt to build unified extension.ts for browser/node
1 parent 32c5dda commit 6446de0

File tree

5 files changed

+31
-10
lines changed

5 files changed

+31
-10
lines changed

wasm-language-server/bin/esbuild.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const sharedWebOptions = {
1616
target: 'es2020',
1717
platform: 'browser',
1818
sourcemap: true,
19+
define: {
20+
'IS_DESKTOP': 'false'
21+
}
1922
};
2023

2124
/** @type BuildOptions */
@@ -33,12 +36,15 @@ const sharedDesktopOptions = {
3336
target: 'es2020',
3437
platform: 'node',
3538
sourcemap: true,
39+
define: {
40+
'IS_DESKTOP': 'true'
41+
}
3642
};
3743

3844
/** @type BuildOptions */
3945
const desktopOptions = {
4046
entryPoints: ['client/src/extension.ts'],
41-
outfile: 'client/dist/desktop/extension.js',
47+
outfile: 'client/out/extension.js',
4248
format: 'cjs',
4349
...sharedDesktopOptions,
4450
};
@@ -68,4 +74,4 @@ createContexts().then(contexts => {
6874
}
6975
}).then(() => { return undefined; }).catch(console.error);
7076
}
71-
}).catch(console.error);
77+
}).catch(console.error);

wasm-language-server/client/bin/esbuild.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const sharedWebOptions = {
1616
target: 'es2020',
1717
platform: 'browser',
1818
sourcemap: true,
19+
define: {
20+
'IS_DESKTOP': 'false'
21+
}
1922
};
2023

2124
/** @type BuildOptions */
@@ -33,12 +36,15 @@ const sharedDesktopOptions = {
3336
target: 'es2020',
3437
platform: 'node',
3538
sourcemap: true,
39+
define: {
40+
'IS_DESKTOP': 'true'
41+
}
3642
};
3743

3844
/** @type BuildOptions */
3945
const desktopOptions = {
4046
entryPoints: ['src/extension.ts'],
41-
outfile: 'dist/desktop/extension.js',
47+
outfile: 'out/extension.js',
4248
format: 'cjs',
4349
...sharedDesktopOptions,
4450
};
@@ -68,4 +74,4 @@ createContexts().then(contexts => {
6874
}
6975
}).then(() => { return undefined; }).catch(console.error);
7076
}
71-
}).catch(console.error);
77+
}).catch(console.error);

wasm-language-server/client/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
"@types/node": "^22"
3030
},
3131
"scripts": {
32-
"compile": "tsc -b",
32+
"compile": "npm run esbuild",
3333
"watch": "tsc -b -w",
3434
"lint": "eslint",
35-
"esbuild": "^0.25.0"
35+
"esbuild": "node ./bin/esbuild.js"
3636
}
37-
}
37+
}

wasm-language-server/client/src/extension.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
* ------------------------------------------------------------------------------------------ */
55

6+
// declared in esbuild.js
7+
declare const IS_DESKTOP: boolean;
8+
69
import { ExtensionContext, Uri, window, workspace, commands } from 'vscode';
7-
import { LanguageClient, LanguageClientOptions, ServerOptions, RequestType } from 'vscode-languageclient/node';
10+
import { LanguageClient, ServerOptions, RequestType, LanguageClientOptions } from 'vscode-languageclient';
11+
if (IS_DESKTOP) {
12+
require('vscode-languageclient/node');
13+
} else {
14+
require('vscode-languageclient/browser');
15+
}
16+
817
import { Wasm, ProcessOptions } from '@vscode/wasm-wasi/v1';
918
import { createStdioOptions, createUriConverters, startServer } from '@vscode/wasm-wasi-lsp';
1019

@@ -63,4 +72,4 @@ export async function activate(context: ExtensionContext) {
6372

6473
export function deactivate() {
6574
return client.stop();
66-
}
75+
}

wasm-language-server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@
5454
"esbuild": "node ./bin/esbuild.js",
5555
"serve": "serve --cors -l 5000 --ssl-cert $HOME/certs/localhost.pem --ssl-key $HOME/certs/localhost-key.pem"
5656
}
57-
}
57+
}

0 commit comments

Comments
 (0)