Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove webServer #51699

Merged
merged 5 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Herebyfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,6 @@ const { main: tsserver, watch: watchTsserver } = entrypointBuildTask({
builtEntrypoint: "./built/local/tsserver/server.js",
output: "./built/local/tsserver.js",
mainDeps: [generateLibs],
// Even though this seems like an exectuable, so could be the default CJS,
// this is used in the browser too. Do the same thing that we do for our
// libraries and generate an IIFE with name `ts`, as to not pollute the global
// scope.
bundlerOptions: { exportIsTsObject: true },
});
export { tsserver, watchTsserver };

Expand Down
1 change: 0 additions & 1 deletion src/testRunner/_namespaces/ts.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

export * from "../../jsTyping/_namespaces/ts.server";
export * from "../../server/_namespaces/ts.server";
export * from "../../webServer/_namespaces/ts.server";
export * from "../../typingsInstallerCore/_namespaces/ts.server";
export * from "../../harness/_namespaces/ts.server";
export * from "../../loggedIO/_namespaces/ts.server";
1 change: 0 additions & 1 deletion src/testRunner/_namespaces/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export * from "../../executeCommandLine/_namespaces/ts";
export * from "../../services/_namespaces/ts";
export * from "../../jsTyping/_namespaces/ts";
export * from "../../server/_namespaces/ts";
export * from "../../webServer/_namespaces/ts";
export * from "../../typingsInstallerCore/_namespaces/ts";
export * from "../../deprecatedCompat/_namespaces/ts";
export * from "../../harness/_namespaces/ts";
Expand Down
1 change: 0 additions & 1 deletion src/testRunner/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,4 @@ import "./unittests/tsserver/typeReferenceDirectives";
import "./unittests/tsserver/typingsInstaller";
import "./unittests/tsserver/versionCache";
import "./unittests/tsserver/watchEnvironment";
import "./unittests/tsserver/webServer";
import "./unittests/debugDeprecation";
1 change: 0 additions & 1 deletion src/testRunner/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
{ "path": "../services" },
{ "path": "../jsTyping" },
{ "path": "../server" },
{ "path": "../webServer" },
{ "path": "../typingsInstallerCore" },
{ "path": "../deprecatedCompat" },
{ "path": "../harness" },
Expand Down
372 changes: 0 additions & 372 deletions src/testRunner/unittests/tsserver/webServer.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@
{ "path": "./typingsInstaller" },
{ "path": "./typingsInstallerCore" },
{ "path": "./watchGuard" },
{ "path": "./webServer" },
]
}
2 changes: 0 additions & 2 deletions src/tsserver/_namespaces/ts.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@

export * from "../../jsTyping/_namespaces/ts.server";
export * from "../../server/_namespaces/ts.server";
export * from "../../webServer/_namespaces/ts.server";
export * from "../nodeServer";
export * from "../webServer";
export * from "../common";
1 change: 0 additions & 1 deletion src/tsserver/_namespaces/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ export * from "../../compiler/_namespaces/ts";
export * from "../../services/_namespaces/ts";
export * from "../../jsTyping/_namespaces/ts";
export * from "../../server/_namespaces/ts";
export * from "../../webServer/_namespaces/ts";
import * as server from "./ts.server";
export { server };
15 changes: 14 additions & 1 deletion src/tsserver/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
Logger,
LogLevel,
ServerCancellationToken,
StartSessionOptions,
SessionOptions,
} from "./_namespaces/ts.server";
import { LanguageServiceMode } from "./_namespaces/ts";

Expand All @@ -19,6 +19,19 @@ export function getLogLevel(level: string | undefined) {
return 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"];
syntaxOnly: SessionOptions["syntaxOnly"];
serverMode: SessionOptions["serverMode"];
}

/** @internal */
export interface StartInput {
args: readonly string[];
Expand Down
64 changes: 54 additions & 10 deletions src/tsserver/nodeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
ActionPackageInstalled,
ActionSet,
Arguments,
BaseLogger,
BeginInstallTypes,
createInstallTypingsRequest,
EndInstallTypes,
Expand All @@ -27,6 +26,7 @@ import {
LogLevel,
ModuleImportResult,
Msg,
nowString,
nullCancellationToken,
nullTypingsInstaller,
PackageInstalledResponse,
Expand Down Expand Up @@ -65,6 +65,7 @@ import {
noopFileWatcher,
normalizePath,
normalizeSlashes,
perfLogger,
resolveJSModule,
SortedReadonlyArray,
startTracing,
Expand Down Expand Up @@ -205,14 +206,16 @@ export function initializeNodeSystem(): StartInput {
stat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void;
} = require("fs");

class Logger extends BaseLogger {
class Logger implements Logger {
private seq = 0;
private inGroup = false;
private firstInGroup = true;
private fd = -1;
constructor(
private readonly logFilename: string,
private readonly traceToConsole: boolean,
level: LogLevel
private readonly level: LogLevel
) {
super(level);
if (this.logFilename) {
try {
this.fd = fs.openSync(this.logFilename, "w");
Expand All @@ -222,25 +225,67 @@ export function initializeNodeSystem(): StartInput {
}
}
}

static padStringRight(str: string, padding: string) {
return (str + padding).slice(0, padding.length);
}
close() {
if (this.fd >= 0) {
fs.close(this.fd, noop);
}
}

getLogFileName() {
getLogFileName(): string | undefined {
return this.logFilename;
}

perftrc(s: string) {
this.msg(s, Msg.Perf);
}
info(s: string) {
this.msg(s, Msg.Info);
}
err(s: string) {
this.msg(s, Msg.Err);
}
startGroup() {
this.inGroup = true;
this.firstInGroup = true;
}
endGroup() {
this.inGroup = false;
}
loggingEnabled() {
return !!this.logFilename || this.traceToConsole;
}
hasLevel(level: LogLevel) {
return this.loggingEnabled() && this.level >= level;
}
msg(s: string, type: Msg = Msg.Err) {
switch (type) {
case Msg.Info:
perfLogger.logInfoEvent(s);
break;
case Msg.Perf:
perfLogger.logPerfEvent(s);
break;
default: // Msg.Err
perfLogger.logErrEvent(s);
break;
}

if (!this.canWrite()) return;

s = `[${nowString()}] ${s}\n`;
if (!this.inGroup || this.firstInGroup) {
const prefix = Logger.padStringRight(type + " " + this.seq.toString(), " ");
s = prefix + s;
}
this.write(s, type);
if (!this.inGroup) {
this.seq++;
}
}
protected canWrite() {
return this.fd >= 0 || this.traceToConsole;
}

protected write(s: string, _type: Msg) {
if (this.fd >= 0) {
const buf = sys.bufferFrom!(s);
Expand Down Expand Up @@ -463,7 +508,6 @@ function parseEventPort(eventPortStr: string | undefined) {
const eventPort = eventPortStr === undefined ? undefined : parseInt(eventPortStr);
return eventPort !== undefined && !isNaN(eventPort) ? eventPort : undefined;
}

function startNodeSession(options: StartSessionOptions, logger: Logger, cancellationToken: ServerCancellationToken) {
const childProcess: {
fork(modulePath: string, args: string[], options?: { execArgv: string[], env?: MapLike<string> }): NodeChildProcess;
Expand Down
17 changes: 1 addition & 16 deletions src/tsserver/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
findArgument,
hasArgument,
initializeNodeSystem,
initializeWebSystem,
Msg,
StartInput,
} from "./_namespaces/ts.server";
Expand All @@ -17,8 +16,6 @@ import {

export * from "./_namespaces/ts";

declare const addEventListener: any;
declare const removeEventListener: any;
function findArgumentStringArray(argName: string): readonly string[] {
const arg = findArgument(argName);
if (arg === undefined) {
Expand Down Expand Up @@ -73,16 +70,4 @@ function start({ args, logger, cancellationToken, serverMode, unknownServerMode,
}

setStackTraceLimit();
// Cannot check process var directory in webworker so has to be typeof check here
if (typeof process !== "undefined") {
start(initializeNodeSystem(), require("os").platform());
}
else {
// Get args from first message
const listener = (e: any) => {
removeEventListener("message", listener);
const args = e.data;
start(initializeWebSystem(args), "web");
};
addEventListener("message", listener);
}
start(initializeNodeSystem(), require("os").platform());
1 change: 0 additions & 1 deletion src/tsserver/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
{ "path": "../services" },
{ "path": "../jsTyping" },
{ "path": "../server" },
{ "path": "../webServer" }
],
"include": ["**/*"]
}
Loading