Optimized production build of server, reducing the startup time and overall size of the VS Code extension significantly.

This commit is contained in:
Eric Traut 2019-10-05 22:42:25 -07:00
parent 74eab99bbb
commit 5a7903133a
7 changed files with 38 additions and 20 deletions

4
.vscode/launch.json vendored
View File

@ -8,7 +8,7 @@
"program": "${workspaceRoot}/index.debug.js",
"protocol": "inspector",
"cwd": "${workspaceRoot}",
"preLaunchTask": "npm: build:analyzer",
"preLaunchTask": "npm: build:serverDebug",
"args": [
"-p",
"${workspaceRoot}/../brain",
@ -38,7 +38,7 @@
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/client/out/src/extension.js",
"preLaunchTask": "npm: build:clientServer",
"preLaunchTask": "npm: build:clientServerDebug",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}/client"
],

12
client/.vscodeignore Normal file
View File

@ -0,0 +1,12 @@
# Don't include the large "lsif" files that are included
# in some node_modules.
**/*.lsif
# No need to include source maps, original copy of the src or tests.
**/*.map
tsconfig.json
# Omit all of the server directory except for the main bundle.
server
!server/server.bundle.js

View File

@ -16,14 +16,15 @@ import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind,
import { ProgressReporting } from './progress';
export function activate(context: ExtensionContext) {
let serverModule = context.asAbsolutePath(path.join('server', 'server.js'));
let serverModule = context.asAbsolutePath(path.join('server', 'server.bundle.js'));
let serverModuleDebug = context.asAbsolutePath(path.join('server', 'server.js'));
let debugOptions = { execArgv: ["--nolazy", "--inspect=6600"] };
// If the extension is launched in debug mode, then the debug server options are used.
// Otherwise the run options are used.
let serverOptions: ServerOptions = {
run : { module: serverModule, transport: TransportKind.ipc },
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
debug: { module: serverModuleDebug, transport: TransportKind.ipc, options: debugOptions }
}
// Options to control the language client

View File

@ -14,11 +14,11 @@
},
"scripts": {
"install:all": "npm install && cd server && npm install && cd ../client && npm install && cd ..",
"build": "npm run build:clientServer && npm run build:cli",
"build": "npm run build:clientServerDebug && npm run build:cli",
"build:client": "cd client && npm run build && cd ..",
"build:server": "cd server && npm run build && cd ..",
"build:clientServer": "npm run build:client && npm run build:server",
"build:analyzer": "cd server && npm run build:analyzer && cd ..",
"build:clientServerDebug": "npm run build:client && npm run build:serverDebug",
"build:serverProd": "cd server && npm run build:serverProd && cd ..",
"build:serverDebug": "cd server && npm run build:serverDebug && cd ..",
"build:cli": "cd server && npm run build:cli && cd ..",
"package": "npm run install:all && npm run build && cd client && npx vsce package && cd .."
},

View File

@ -5,14 +5,13 @@
"version": "1.0.70",
"license": "MIT",
"scripts": {
"start": "npm run start:analyzer && npm run start:server",
"start:analyzer": "npm i && npm run build:analyzer",
"start:server": "npm i && npm run build:server",
"build": "npm run build:server && npm run build:analyzer && npm run build:cli",
"build:analyzer": "tsc",
"build:server": "npm run installServer && npm run removeLsifFiles && webpack --config webpack.config-server.js",
"start": "npm run start:serverDebug && npm run start:server",
"start:serverDebug": "npm i && npm run build:serverDebug",
"start:serverProd": "npm i && npm run build:serverProd",
"build": "npm run build:serverProd && npm run build:serverDebug && npm run build:cli",
"build:serverDebug": "tsc",
"build:serverProd": "npm run installServer && webpack --config webpack.config-server.js",
"installServer": "node ./customInstallServerIntoExtension.js ../client ./package.json ./tsconfig.json ./package-lock.json",
"removeLsifFiles": "find . -name '*.lsif' -type f -delete",
"build:cli": "node ./copyTypeshedFallback.js && npm run tslint && webpack --config webpack.config-cli.js",
"watch": "tsc --watch",
"tslint": "tslint --project tsconfig.json --fix",

View File

@ -9,8 +9,7 @@ import {
DiagnosticSeverity, DiagnosticTag, ExecuteCommandParams, IConnection,
InitializeResult, IPCMessageReader, IPCMessageWriter, Location, ParameterInformation,
Position, Range, ResponseError, SignatureInformation, SymbolInformation, TextDocuments,
TextEdit,
WorkspaceEdit
TextEdit, WorkspaceEdit
} from 'vscode-languageserver';
import VSCodeUri from 'vscode-uri';

View File

@ -9,13 +9,18 @@
const path = require('path');
module.exports = {
context: path.resolve(__dirname),
entry: './src/server.ts',
mode: 'development',
mode: 'production',
target: 'node',
devtool: 'source-map',
output: {
filename: 'server.js',
filename: 'server.bundle.js',
path: path.resolve(__dirname, '../client/server')
},
optimization: {
usedExports: true,
},
resolve: {
modules: [
path.resolve(__dirname, '.'),
@ -35,6 +40,8 @@ module.exports = {
]
},
node: {
fs: 'empty'
fs: 'empty',
__dirname: false,
__filename: false
}
};