1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ //@ts -check
6
+ const esbuild = require ( 'esbuild' ) ;
7
+
8
+ /**
9
+ * @typedef {import('esbuild').BuildOptions } BuildOptions
10
+ */
11
+
12
+ /** @type BuildOptions */
13
+ const clientOptions = {
14
+ bundle : true ,
15
+ external : [ 'vscode' ] ,
16
+ target : 'ES2022' ,
17
+ platform : 'node' ,
18
+ sourcemap : false ,
19
+ entryPoints : [ 'client/src/extension.ts' ] ,
20
+ outfile : 'client/out/extension.js' ,
21
+ preserveSymlinks : true ,
22
+ format : 'cjs' ,
23
+ } ;
24
+
25
+ /** @type BuildOptions */
26
+ const serverOptions = {
27
+ bundle : true ,
28
+ target : 'ES2022' ,
29
+ platform : 'node' ,
30
+ sourcemap : false ,
31
+ entryPoints : [ 'server/src/eslintServer.ts' ] ,
32
+ outfile : 'server/out/eslintServer.js' ,
33
+ preserveSymlinks : true ,
34
+ format : 'cjs' ,
35
+ } ;
36
+
37
+ function createContexts ( ) {
38
+ return Promise . all ( [
39
+ esbuild . context ( clientOptions ) ,
40
+ esbuild . context ( serverOptions ) ,
41
+ ] ) ;
42
+ }
43
+
44
+ createContexts ( ) . then ( contexts => {
45
+ if ( process . argv [ 2 ] === '--watch' ) {
46
+ const promises = [ ] ;
47
+ for ( const context of contexts ) {
48
+ promises . push ( context . watch ( ) ) ;
49
+ }
50
+ return Promise . all ( promises ) . then ( ( ) => { return undefined ; } ) ;
51
+ } else {
52
+ const promises = [ ] ;
53
+ for ( const context of contexts ) {
54
+ promises . push ( context . rebuild ( ) ) ;
55
+ }
56
+ Promise . all ( promises ) . then ( async ( ) => {
57
+ for ( const context of contexts ) {
58
+ await context . dispose ( ) ;
59
+ }
60
+ } ) . then ( ( ) => { return undefined ; } ) . catch ( console . error ) ;
61
+ }
62
+ } ) . catch ( console . error ) ;
0 commit comments