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

Api for tsc --build and --incremental #31432

Merged
merged 44 commits into from Jun 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5443447
Instead of maintaining queue for invalidated projects, use the pendin…
sheetalkamat Apr 18, 2019
1de70de
No need to calculate and store project references graph
sheetalkamat Apr 18, 2019
b9eeaab
Remove unused variable
sheetalkamat Apr 18, 2019
3e77b96
Fix the graph ordering test case to check actual order and not just m…
sheetalkamat Apr 18, 2019
845f67a
Make api to return build order
sheetalkamat Apr 18, 2019
e9d4e0b
Unchanged output time is no more required
sheetalkamat Apr 18, 2019
9236502
Remove `getUpToDateStatusOfFile` from solution builder since that tes…
sheetalkamat Apr 18, 2019
b42e76b
Remove usage of fileMap for output unchanged timestamp modification a…
sheetalkamat Apr 18, 2019
d4474a5
More refactoring to move file map creation inside solution builder
sheetalkamat Apr 18, 2019
c615d48
Make use of maps in build order calculation
sheetalkamat Apr 18, 2019
50741e6
Use maps for all the watch data structures
sheetalkamat Apr 18, 2019
579d2bf
Make FileMap Apis to match map but just ensure that keys are always p…
sheetalkamat Apr 19, 2019
05257e8
configFileCache, projectStatus, buildInfoChecked is now ConfigFileMap
sheetalkamat Apr 19, 2019
fd6773f
Diagnostics as ConfigFileMap
sheetalkamat Apr 19, 2019
11b21fb
builderPrograms as ConfigFileMap
sheetalkamat Apr 19, 2019
65ed413
Remove resolveProjectName as api
sheetalkamat Apr 19, 2019
ddee617
Make SolutionBuilder and SolutionBuilderWithWatch separate
sheetalkamat Apr 19, 2019
4b572be
Instead of having two separate paths for building projects, (build al…
sheetalkamat Apr 19, 2019
04a972b
More refactoring
sheetalkamat Apr 19, 2019
1a75c62
Remove resetBuildContext
sheetalkamat Apr 19, 2019
9ba4ab1
Merge branch 'master' into builderAPI
sheetalkamat Apr 30, 2019
5b361c8
Make API to build project and wire cancellation token
sheetalkamat May 2, 2019
e8074f7
Rename cleanAll to clean and take optional project as input
sheetalkamat May 2, 2019
3da4796
Remove startWatching as explicit method from api
sheetalkamat May 2, 2019
5c18513
Make SolutionBuilder as Public API
sheetalkamat May 2, 2019
0a25524
Enable apis to create incremental program
sheetalkamat May 2, 2019
71b190a
Create api for buildNextProject
sheetalkamat May 2, 2019
f017433
Move everything into state so we can pass it around
sheetalkamat May 3, 2019
6227fab
Make invalidated project when only need to be built or updated
sheetalkamat May 7, 2019
5270b7e
Make invalidated projects as api so we can expose it later
sheetalkamat May 7, 2019
e4fe4ac
Make update bundle return invalidated project if it cant update the b…
sheetalkamat May 7, 2019
9f9ae00
Enable getSemanticDiagnosticsOfNextAffectedFile for EmitAndSemanticDi…
sheetalkamat May 7, 2019
f0b7e08
Move towards BuildInvalidatedProject api where one can query program …
sheetalkamat May 9, 2019
8c489bf
UpdateBundleProject<T> to contain emit method
sheetalkamat May 9, 2019
97fcea1
Api to get next invalidated project
sheetalkamat May 9, 2019
b3dac18
Merge branch 'master' into builderAPI
sheetalkamat May 9, 2019
f069534
Merge branch 'master' into builderAPI
sheetalkamat May 14, 2019
d7c3b5e
Add getParsedCommandLine as optional method on SolutionBuilderHost
sheetalkamat May 14, 2019
89d1475
Add writeFileCallbacks to done method and also on host
sheetalkamat May 15, 2019
629bc0c
Always emit tsbuild info if path says so (irrespecitive of if there e…
sheetalkamat May 15, 2019
0cb980d
Add api to build referenced projects
sheetalkamat May 15, 2019
ec4ea0e
Watch only built projects
sheetalkamat May 16, 2019
138f757
Fix the test since tsbuildinfo is now always emitted (629bc0c)
sheetalkamat May 16, 2019
098c900
Make more build options internal which correspond to internal compile…
sheetalkamat May 16, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 10 additions & 14 deletions src/compiler/builder.ts
Expand Up @@ -796,6 +796,7 @@ namespace ts {
(result as SemanticDiagnosticsBuilderProgram).getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
}
else if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
(result as EmitAndSemanticDiagnosticsBuilderProgram).getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
(result as EmitAndSemanticDiagnosticsBuilderProgram).emitNextAffectedFile = emitNextAffectedFile;
}
else {
Expand Down Expand Up @@ -913,6 +914,11 @@ namespace ts {
);
}

// Add file to affected file pending emit to handle for later emit time
if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
addToAffectedFilesPendingEmit(state, [(affected as SourceFile).path]);
}

// Get diagnostics for the affected file if its not ignored
if (ignoreSourceFile && ignoreSourceFile(affected as SourceFile)) {
// Get next affected file
Expand Down Expand Up @@ -951,18 +957,8 @@ namespace ts {

// When semantic builder asks for diagnostics of the whole program,
// ensure that all the affected files are handled
let affected: SourceFile | Program | undefined;
let affectedFilesPendingEmit: Path[] | undefined;
while (affected = getNextAffectedFile(state, cancellationToken, computeHash)) {
if (affected !== state.program && kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
(affectedFilesPendingEmit || (affectedFilesPendingEmit = [])).push((affected as SourceFile).path);
}
doneWithAffectedFile(state, affected);
}

// In case of emit builder, cache the files to be emitted
if (affectedFilesPendingEmit) {
addToAffectedFilesPendingEmit(state, affectedFilesPendingEmit);
// tslint:disable-next-line no-empty
while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) {
}

let diagnostics: Diagnostic[] | undefined;
Expand Down Expand Up @@ -997,7 +993,7 @@ namespace ts {
return map;
}

export function createBuildProgramUsingProgramBuildInfo(program: ProgramBuildInfo): EmitAndSemanticDiagnosticsBuilderProgram & SemanticDiagnosticsBuilderProgram {
export function createBuildProgramUsingProgramBuildInfo(program: ProgramBuildInfo): EmitAndSemanticDiagnosticsBuilderProgram {
const fileInfos = createMapFromTemplate(program.fileInfos);
const state: ReusableBuilderProgramState = {
fileInfos,
Expand Down Expand Up @@ -1181,7 +1177,7 @@ namespace ts {
* The builder that can handle the changes in program and iterate through changed file to emit the files
* The semantic diagnostics are cached per file and managed by clearing for the changed/affected files
*/
export interface EmitAndSemanticDiagnosticsBuilderProgram extends BuilderProgram {
export interface EmitAndSemanticDiagnosticsBuilderProgram extends SemanticDiagnosticsBuilderProgram {
/**
* Emits the next affected file's emit result (EmitResult and sourceFiles emitted) or returns undefined if iteration is complete
* The first of writeFile if provided, writeFile of BuilderProgramHost if provided, writeFile of compiler host
Expand Down
3 changes: 1 addition & 2 deletions src/compiler/commandLineParser.ts
Expand Up @@ -1022,8 +1022,7 @@ namespace ts {
}
}

/* @internal */
export interface OptionsBase {
interface OptionsBase {
[option: string]: CompilerOptionsValue | undefined;
}

Expand Down
15 changes: 12 additions & 3 deletions src/compiler/emitter.ts
Expand Up @@ -284,7 +284,6 @@ namespace ts {
// Write build information if applicable
if (!buildInfoPath || targetSourceFile || emitSkipped) return;
const program = host.getProgramBuildInfo();
if (!bundle && !program) return;
if (host.isEmitBlocked(buildInfoPath) || compilerOptions.noEmit) {
emitSkipped = true;
return;
Expand Down Expand Up @@ -638,7 +637,12 @@ namespace ts {
}

/*@internal*/
export function emitUsingBuildInfo(config: ParsedCommandLine, host: EmitUsingBuildInfoHost, getCommandLine: (ref: ProjectReference) => ParsedCommandLine | undefined): EmitUsingBuildInfoResult {
export function emitUsingBuildInfo(
config: ParsedCommandLine,
host: EmitUsingBuildInfoHost,
getCommandLine: (ref: ProjectReference) => ParsedCommandLine | undefined,
customTransformers?: CustomTransformers
): EmitUsingBuildInfoResult {
const { buildInfoPath, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath } = getOutputPathsForBundle(config.options, /*forceDtsPaths*/ false);
const buildInfoText = host.readFile(Debug.assertDefined(buildInfoPath));
if (!buildInfoText) return buildInfoPath!;
Expand Down Expand Up @@ -723,7 +727,12 @@ namespace ts {
useCaseSensitiveFileNames: () => host.useCaseSensitiveFileNames(),
getProgramBuildInfo: returnUndefined
};
emitFiles(notImplementedResolver, emitHost, /*targetSourceFile*/ undefined, getTransformers(config.options), /*emitOnlyDtsFiles*/ false);
emitFiles(
notImplementedResolver,
emitHost,
/*targetSourceFile*/ undefined,
getTransformers(config.options, customTransformers)
);
return outputFiles;
}

Expand Down