Skip to content

Commit

Permalink
Make tsserver a thin wrapper around tsserverlibrary
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebailey committed Aug 14, 2023
1 parent 3c6c557 commit 1aa4d3a
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 217 deletions.
6 changes: 5 additions & 1 deletion Herebyfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ function createBundler(entrypoint, outfile, taskOptions = {}) {
sourcesContent: false,
treeShaking: taskOptions.treeShaking,
packages: "external",
external: ["typescript", "./typescript.js"],
alias: {
typescript: "./typescript.js",
},
logLevel: "warning",
// legalComments: "none", // If we add copyright headers to the source files, uncomment.
};
Expand Down Expand Up @@ -384,7 +388,7 @@ const { main: tsserver, watch: watchTsserver } = entrypointBuildTask({
srcEntrypoint: "./src/tsserver/server.ts",
builtEntrypoint: "./built/local/tsserver/server.js",
output: "./built/local/tsserver.js",
mainDeps: [generateLibs],
mainDeps: [generateLibs, services],
});
export { tsserver, watchTsserver };

Expand Down
5 changes: 4 additions & 1 deletion src/tsconfig-eslint.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"extends": "./tsconfig-base",
"compilerOptions": {
"types": ["node", "mocha", "chai"]
"types": ["node", "mocha", "chai"],
"paths": {
"typescript": ["./typescript/typescript"]
}
}
}
6 changes: 0 additions & 6 deletions src/tsserver/_namespaces/ts.server.ts

This file was deleted.

8 changes: 0 additions & 8 deletions src/tsserver/_namespaces/ts.ts

This file was deleted.

36 changes: 15 additions & 21 deletions src/tsserver/common.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import { LanguageServiceMode } from "./_namespaces/ts";
import {
Logger,
LogLevel,
ServerCancellationToken,
SessionOptions,
} from "./_namespaces/ts.server";
import * as ts from "typescript";

/** @internal */
export function getLogLevel(level: string | undefined) {
if (level) {
const l = level.toLowerCase();
for (const name in LogLevel) {
for (const name in ts.server.LogLevel) {
if (isNaN(+name) && l === name.toLowerCase()) {
return LogLevel[name] as any as LogLevel;
return ts.server.LogLevel[name] as any as ts.server.LogLevel;
}
}
}
Expand All @@ -21,22 +15,22 @@ export function getLogLevel(level: string | undefined) {

/** @internal */
export interface StartSessionOptions {
globalPlugins: SessionOptions["globalPlugins"];
pluginProbeLocations: SessionOptions["pluginProbeLocations"];
allowLocalPluginLoads: SessionOptions["allowLocalPluginLoads"];
useSingleInferredProject: SessionOptions["useSingleInferredProject"];
useInferredProjectPerProjectRoot: SessionOptions["useInferredProjectPerProjectRoot"];
suppressDiagnosticEvents: SessionOptions["suppressDiagnosticEvents"];
noGetErrOnBackgroundUpdate: SessionOptions["noGetErrOnBackgroundUpdate"];
serverMode: SessionOptions["serverMode"];
globalPlugins: ts.server.SessionOptions["globalPlugins"];
pluginProbeLocations: ts.server.SessionOptions["pluginProbeLocations"];
allowLocalPluginLoads: ts.server.SessionOptions["allowLocalPluginLoads"];
useSingleInferredProject: ts.server.SessionOptions["useSingleInferredProject"];
useInferredProjectPerProjectRoot: ts.server.SessionOptions["useInferredProjectPerProjectRoot"];
suppressDiagnosticEvents: ts.server.SessionOptions["suppressDiagnosticEvents"];
noGetErrOnBackgroundUpdate: ts.server.SessionOptions["noGetErrOnBackgroundUpdate"];
serverMode: ts.server.SessionOptions["serverMode"];
}

/** @internal */
export interface StartInput {
args: readonly string[];
logger: Logger;
cancellationToken: ServerCancellationToken;
serverMode: LanguageServiceMode | undefined;
logger: ts.server.Logger;
cancellationToken: ts.server.ServerCancellationToken;
serverMode: ts.LanguageServiceMode | undefined;
unknownServerMode?: string;
startSession: (option: StartSessionOptions, logger: Logger, cancellationToken: ServerCancellationToken) => void;
startSession: (option: StartSessionOptions, logger: ts.server.Logger, cancellationToken: ts.server.ServerCancellationToken) => void;
}
Loading

0 comments on commit 1aa4d3a

Please sign in to comment.