-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Switch to esbuild instead of rollup for the client and banner
We have found that the performance with esbuild is much better than using rollup and especially rollup+terser. This allows us to efficiently build, minify, and treeshake the client code, especially with respect to the new dependency on the typescript scanner for the client middleware. We still need to investigate how or if we can use esbuild for the server code as well. Since it does not support the 'amd' format, we need to see if there is another way to configure it to generate the output we need to use the `define` from the banner for requires.
- Loading branch information
Showing
5 changed files
with
93 additions
and
42 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
const esbuild = require('esbuild'); | ||
const fs = require('fs'); | ||
|
||
const defaultOptions = { | ||
bundle: true, | ||
platform: 'node', | ||
logLevel: 'info', | ||
}; | ||
|
||
/** @type esbuild.BuildOptions */ | ||
const clientConfig = { | ||
...defaultOptions, | ||
entryPoints: ['dist/client/extension.js'], | ||
outfile: 'dist/npm/index.js', | ||
external: [ | ||
'fs', | ||
'path', | ||
'vscode', | ||
'vscode-languageclient/node', | ||
'vscode-languageserver-protocol', | ||
'vscode-jsonrpc', | ||
], | ||
format: 'cjs', | ||
minify: true, | ||
}; | ||
|
||
/** @type esbuild.BuildOptions */ | ||
const bannerConfig = { | ||
...defaultOptions, | ||
entryPoints: ['dist/banner/banner.js'], | ||
outfile: 'dist/banner/banner.esbuild.js', | ||
external: [ | ||
'path', | ||
], | ||
format: 'cjs', | ||
}; | ||
|
||
/** @type esbuild.BuildOptions */ | ||
const serverConfig = { | ||
...defaultOptions, | ||
entryPoints: ['dist/server/server.js'], | ||
outfile: 'dist/npm/server/index.js', | ||
external: [ | ||
'fs', | ||
'path', | ||
'typescript/lib/tsserverlibrary', | ||
'vscode-languageserver', | ||
'vscode-uri', | ||
'vscode-jsonrpc', | ||
], | ||
// TODO(atscott): Figure out how to use the banner correctly. | ||
// iife format produces a `require("typescript/lib/tsserverlibrary");` line but it needs to use | ||
// the `define` in the banner to resolve tsserverlibrary. | ||
format: 'iife', | ||
}; | ||
|
||
async function build() { | ||
try { | ||
await esbuild.build(clientConfig); | ||
await esbuild.build(bannerConfig); | ||
} catch (e) { | ||
console.error(e); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
build(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters