mirror of
https://github.com/Microsoft/vscode
synced 2024-09-18 01:58:27 +00:00
debcf16fcd
* Mangle exported functions For #180461 This prototype tries to mangle exported functions, saving a further 440kb from the bundle size * Fix missing call * Also try mangling top level exported consts too * Fixing errors * Don't run on build files * Skip a few more manglings and revert change to namespace * Skip a few more monaco files * Also mangle consts that shadow types This increases savings up to 3325 * Also mangle exported classes * Skip mangling more localization functions for now * Opt out pfs * Update build script * Run find locations task in parallel This should speed up compile * Cleanup before close * Limit workers to avoid hitting memory limit * Limit pool size * Skip one more mangling * Exclude entrypoints from mangling * Try to fix web build and clean up code * Exempt a few more projects * Exempt another file * Also exempt html * Skip mangling ext entrypoints * Use prefix that can't be confused with rpc calls * Fix max call stack error * Switch prefixes * Don't mangle ambient declarations * Use correct way of checking modifier flags * Workaround getCombinedModifierFlags not doing what I'd expect Maybe needs the checker to be enabled too? Just check parent chain instead for now * Clean up code and add logic showing how enum mangling could work * Remove a few more skipMangles Use entrypoints instead * Fix entrypoint name
63 lines
2.1 KiB
TypeScript
63 lines
2.1 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import * as ts from 'typescript';
|
|
import * as path from 'path';
|
|
|
|
export class StaticLanguageServiceHost implements ts.LanguageServiceHost {
|
|
|
|
private readonly _cmdLine: ts.ParsedCommandLine;
|
|
private readonly _scriptSnapshots: Map<string, ts.IScriptSnapshot> = new Map();
|
|
|
|
constructor(readonly projectPath: string) {
|
|
const existingOptions: Partial<ts.CompilerOptions> = {};
|
|
const parsed = ts.readConfigFile(projectPath, ts.sys.readFile);
|
|
if (parsed.error) {
|
|
throw parsed.error;
|
|
}
|
|
this._cmdLine = ts.parseJsonConfigFileContent(parsed.config, ts.sys, path.dirname(projectPath), existingOptions);
|
|
if (this._cmdLine.errors.length > 0) {
|
|
throw parsed.error;
|
|
}
|
|
}
|
|
getCompilationSettings(): ts.CompilerOptions {
|
|
return this._cmdLine.options;
|
|
}
|
|
getScriptFileNames(): string[] {
|
|
return this._cmdLine.fileNames;
|
|
}
|
|
getScriptVersion(_fileName: string): string {
|
|
return '1';
|
|
}
|
|
getProjectVersion(): string {
|
|
return '1';
|
|
}
|
|
getScriptSnapshot(fileName: string): ts.IScriptSnapshot | undefined {
|
|
let result: ts.IScriptSnapshot | undefined = this._scriptSnapshots.get(fileName);
|
|
if (result === undefined) {
|
|
const content = ts.sys.readFile(fileName);
|
|
if (content === undefined) {
|
|
return undefined;
|
|
}
|
|
result = ts.ScriptSnapshot.fromString(content);
|
|
this._scriptSnapshots.set(fileName, result);
|
|
}
|
|
return result;
|
|
}
|
|
getCurrentDirectory(): string {
|
|
return path.dirname(this.projectPath);
|
|
}
|
|
getDefaultLibFileName(options: ts.CompilerOptions): string {
|
|
return ts.getDefaultLibFilePath(options);
|
|
}
|
|
directoryExists = ts.sys.directoryExists;
|
|
getDirectories = ts.sys.getDirectories;
|
|
fileExists = ts.sys.fileExists;
|
|
readFile = ts.sys.readFile;
|
|
readDirectory = ts.sys.readDirectory;
|
|
// this is necessary to make source references work.
|
|
realpath = ts.sys.realpath;
|
|
}
|