Skip to content

Commit 30b0ee2

Browse files
committed
[experiment] make tsc use the public API
1 parent 8e11448 commit 30b0ee2

File tree

6 files changed

+24
-20
lines changed

6 files changed

+24
-20
lines changed

Herebyfile.mjs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -383,18 +383,6 @@ function entrypointBuildTask(options) {
383383
return { build, bundle, shim, main, watch };
384384
}
385385

386-
const { main: tsc, watch: watchTsc } = entrypointBuildTask({
387-
name: "tsc",
388-
description: "Builds the command-line compiler",
389-
buildDeps: [generateDiagnostics],
390-
project: "src/tsc",
391-
srcEntrypoint: "./src/tsc/tsc.ts",
392-
builtEntrypoint: "./built/local/tsc/tsc.js",
393-
output: "./built/local/tsc.js",
394-
mainDeps: [generateLibs],
395-
});
396-
export { tsc, watchTsc };
397-
398386
const { main: services, build: buildServices, watch: watchServices } = entrypointBuildTask({
399387
name: "services",
400388
description: "Builds the typescript.js library",
@@ -408,6 +396,19 @@ const { main: services, build: buildServices, watch: watchServices } = entrypoin
408396
});
409397
export { services, watchServices };
410398

399+
const { main: tsc, watch: watchTsc } = entrypointBuildTask({
400+
name: "tsc",
401+
description: "Builds the command-line compiler",
402+
buildDeps: [generateDiagnostics],
403+
project: "src/tsc",
404+
srcEntrypoint: "./src/tsc/tsc.ts",
405+
builtEntrypoint: "./built/local/tsc/tsc.js",
406+
output: "./built/local/tsc.js",
407+
mainDeps: [generateLibs, services],
408+
bundlerOptions: { usePublicAPI: true },
409+
});
410+
export { tsc, watchTsc };
411+
411412
export const dtsServices = task({
412413
name: "dts-services",
413414
description: "Bundles typescript.d.ts",

src/executeCommandLine/executeCommandLine.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ import {
8585
validateLocaleAndSetLanguage,
8686
version,
8787
WatchCompilerHost,
88+
WatchOfConfigFile,
8889
WatchOptions,
8990
} from "./_namespaces/ts";
9091

@@ -94,6 +95,7 @@ interface Statistic {
9495
type: StatisticType;
9596
}
9697

98+
/** @internal */
9799
export enum StatisticType {
98100
time,
99101
count,
@@ -730,6 +732,7 @@ function executeCommandLineWorker(
730732
}
731733
}
732734

735+
/** @internal */
733736
export function isBuild(commandLineArgs: readonly string[]) {
734737
if (commandLineArgs.length > 0 && commandLineArgs[0].charCodeAt(0) === CharacterCodes.minus) {
735738
const firstOption = commandLineArgs[0].slice(commandLineArgs[0].charCodeAt(1) === CharacterCodes.minus ? 2 : 1).toLowerCase();
@@ -738,12 +741,14 @@ export function isBuild(commandLineArgs: readonly string[]) {
738741
return false;
739742
}
740743

744+
/** @internal */
741745
export type ExecuteCommandLineCallbacks = (program: Program | BuilderProgram | ParsedCommandLine) => void;
746+
/** @internal */
742747
export function executeCommandLine(
743748
system: System,
744749
cb: ExecuteCommandLineCallbacks,
745750
commandLineArgs: readonly string[],
746-
) {
751+
): void | SolutionBuilder<EmitAndSemanticDiagnosticsBuilderProgram> | WatchOfConfigFile<EmitAndSemanticDiagnosticsBuilderProgram> {
747752
if (isBuild(commandLineArgs)) {
748753
const { buildOptions, watchOptions, projects, errors } = parseBuildCommand(commandLineArgs.slice(1));
749754
if (buildOptions.generateCpuProfile && system.enableCPUProfiler) {

src/tsc/_namespaces/ts.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
/* Generated file to emulate the ts namespace. */
2-
3-
export * from "../../compiler/_namespaces/ts";
4-
export * from "../../executeCommandLine/_namespaces/ts";
1+
export * from "../../typescript/typescript";

src/tsc/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"compilerOptions": {
44
},
55
"references": [
6-
{ "path": "../compiler" },
7-
{ "path": "../executeCommandLine" }
6+
{ "path": "../typescript" }
87
],
98
"include": ["**/*"]
109
}

src/typescript/_namespaces/ts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ export * from "../../compiler/_namespaces/ts";
44
export * from "../../jsTyping/_namespaces/ts";
55
export * from "../../services/_namespaces/ts";
66
export * from "../../server/_namespaces/ts";
7+
export * from "../../executeCommandLine/_namespaces/ts";
78
import * as server from "./ts.server";
89
export { server };

src/typescript/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
{ "path": "../compiler" },
77
{ "path": "../jsTyping" },
88
{ "path": "../services" },
9-
{ "path": "../server" }
9+
{ "path": "../server" },
10+
{ "path": "../executeCommandLine" }
1011
],
1112
"include": ["**/*"]
1213
}

0 commit comments

Comments
 (0)