Skip to content

Commit 3b56c93

Browse files
committed
chore: reduce tsserver size
1 parent de3609a commit 3b56c93

11 files changed

+31
-34
lines changed

src/compiler/moduleNameResolver.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,8 @@ import {
109109
versionMajorMinor,
110110
VersionRange,
111111
} from "./_namespaces/ts";
112-
import {
113-
getPnpApi,
114-
getPnpTypeRoots,
115-
} from "./pnp";
112+
import { getPnpTypeRoots } from "./pnp";
113+
import { getPnpApi } from "./pnpapi";
116114

117115
/** @internal */
118116
export function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void {

src/compiler/moduleSpecifiers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ import {
126126
TypeChecker,
127127
UserPreferences,
128128
} from "./_namespaces/ts";
129-
import { getPnpApi } from "./pnp";
129+
import { getPnpApi } from "./pnpapi";
130130

131131
// Used by importFixes, getEditsForFileRename, and declaration emit to synthesize import module specifiers.
132132

src/compiler/pnp.ts

+1-16
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,7 @@ import {
22
getDirectoryPath,
33
resolvePath,
44
} from "./path";
5-
6-
export function getPnpApi(path: string) {
7-
if (typeof process.versions.pnp === "undefined") {
8-
return;
9-
}
10-
11-
const { findPnpApi } = require("module");
12-
if (findPnpApi) {
13-
return findPnpApi(`${path}/`);
14-
}
15-
}
16-
17-
export function getPnpApiPath(path: string): string | undefined {
18-
// eslint-disable-next-line no-restricted-syntax
19-
return getPnpApi(path)?.resolveRequest("pnpapi", /*issuer*/ null);
20-
}
5+
import { getPnpApi } from "./pnpapi";
216

227
export function getPnpTypeRoots(currentDirectory: string) {
238
const pnpApi = getPnpApi(currentDirectory);

src/compiler/pnpapi.ts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// To preserve the effects of https://github.com/microsoft/TypeScript/pull/55326
2+
// this file needs to avoid importing large graphs.
3+
4+
export function getPnpApi(path: string) {
5+
if (typeof process.versions.pnp === "undefined") {
6+
return;
7+
}
8+
9+
const { findPnpApi } = require("module");
10+
if (findPnpApi) {
11+
return findPnpApi(`${path}/`);
12+
}
13+
}
14+
15+
export function getPnpApiPath(path: string): string | undefined {
16+
// eslint-disable-next-line no-restricted-syntax
17+
return getPnpApi(path)?.resolveRequest("pnpapi", /*issuer*/ null);
18+
}

src/compiler/watchPublic.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ import {
9595
WatchTypeRegistry,
9696
WildcardDirectoryWatcher,
9797
} from "./_namespaces/ts";
98-
import { getPnpApiPath } from "./pnp";
98+
import { getPnpApiPath } from "./pnpapi";
9999

100100
export interface ReadBuildProgramHost {
101101
useCaseSensitiveFileNames(): boolean;

src/server/editorServices.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getPnpApiPath } from "../compiler/pnp";
1+
import { getPnpApiPath } from "../compiler/pnpapi";
22
import {
33
addToSeen,
44
arrayFrom,

src/server/project.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getPnpApi } from "../compiler/pnp";
1+
import { getPnpApi } from "../compiler/pnpapi";
22
import * as ts from "./_namespaces/ts";
33
import {
44
addRange,

src/services/exportInfoMap.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import {
2-
getPnpApi,
3-
isImportablePathPnp,
4-
} from "../compiler/pnp";
1+
import { isImportablePathPnp } from "../compiler/pnp";
2+
import { getPnpApi } from "../compiler/pnpapi";
53
import {
64
__String,
75
addToSeen,

src/services/stringCompletions.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { getModuleSpecifierPreferences } from "../compiler/moduleSpecifiers";
2-
import {
3-
getPnpApi,
4-
getPnpTypeRoots,
5-
} from "../compiler/pnp";
2+
import { getPnpTypeRoots } from "../compiler/pnp";
3+
import { getPnpApi } from "../compiler/pnpapi";
64
import {
75
addToSeen,
86
altDirectorySeparator,

src/services/utilities.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getPnpApi } from "../compiler/pnp";
1+
import { getPnpApi } from "../compiler/pnpapi";
22
import {
33
__String,
44
addEmitFlags,

src/tsserver/nodeServer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getPnpApiPath } from "../compiler/pnp";
1+
import { getPnpApiPath } from "../compiler/pnpapi";
22
import {
33
CharacterCodes,
44
combinePaths,

0 commit comments

Comments
 (0)