Skip to content

Commit

Permalink
Update LKG
Browse files Browse the repository at this point in the history
  • Loading branch information
ivogabe committed May 26, 2016
1 parent 846faab commit 3645edb
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion release/compiler.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export declare class ProjectCompiler implements ICompiler {
* Calculates the difference between the common base directory calculated based on the base paths of the input files
* and the common source directory calculated by TypeScript.
*/
private commonBaseDiff;
private readonly commonBaseDiff;
correctSourceMap(map: RawSourceMap): boolean;
private removeSourceMapComment(content);
}
Expand Down
24 changes: 12 additions & 12 deletions release/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ var ProjectCompiler = (function () {
this.project.output.finish(reporter_1.emptyCompilationResult());
return;
}
var root = this.project.input.commonBasePath;
var rootFilenames = this.project.input.getFileNames(true);
if (!this.project.singleOutput) {
// Add an empty file under the root.
// This will make sure the commonSourceDirectory, calculated by TypeScript, won't point to a subdirectory of the root.
// We cannot use the `rootDir` option here, since that gives errors if the commonSourceDirectory points to a
// directory containing the rootDir instead of the rootDir, which will break the build when using `noEmitOnError`.
// The empty file is filtered out later on.
var emptyFileName = path.join(this.project.options['rootDir'] ? path.resolve(this.project.projectDirectory, this.project.options['rootDir']) : root, '________________empty.ts');
rootFilenames.push(emptyFileName);
this.project.input.addContent(emptyFileName, '');
}
if (!this.project.input.isChanged(true)) {
// Re-use old output
var old = this.project.previousOutput;
Expand All @@ -42,24 +54,12 @@ var ProjectCompiler = (function () {
this.project.output.finish(old.results);
return;
}
var root = this.project.input.commonBasePath;
this.project.options.sourceRoot = root;
this.host = new host_1.Host(this.project.typescript, this.project.currentDirectory, this.project.input, !this.project.noExternalResolve, this.project.options.target >= ts.ScriptTarget.ES6 ? 'lib.es6.d.ts' : 'lib.d.ts');
var rootFilenames = this.project.input.getFileNames(true);
if (this.project.filterSettings !== undefined) {
var filter_2 = new filter_1.Filter(this.project, this.project.filterSettings);
rootFilenames = rootFilenames.filter(function (fileName) { return filter_2.match(fileName); });
}
if (!this.project.singleOutput) {
// Add an empty file under the root.
// This will make sure the commonSourceDirectory, calculated by TypeScript, won't point to a subdirectory of the root.
// We cannot use the `rootDir` option here, since that gives errors if the commonSourceDirectory points to a
// directory containing the rootDir instead of the rootDir, which will break the build when using `noEmitOnError`.
// The empty file is filtered out later on.
var emptyFileName = path.join(this.project.options['rootDir'] ? path.resolve(this.project.projectDirectory, this.project.options['rootDir']) : root, '________________empty.ts');
rootFilenames.push(emptyFileName);
this.project.input.addContent(emptyFileName, '');
}
// Creating a program to compile the sources
// We cast to `tsApi.CreateProgram` so we can pass the old program as an extra argument.
// TS 1.6+ will try to reuse program structure (if possible)
Expand Down
1 change: 1 addition & 0 deletions release/host.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ export declare class Host implements ts.CompilerHost {
fileExists(fileName: string): boolean;
readFile(fileName: string): string;
getSourceFile: (fileName: string, languageVersion: ts.ScriptTarget, onError?: (message: string) => void) => ts.SourceFile;
realpath: any;
}
1 change: 1 addition & 0 deletions release/host.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var Host = (function () {
this.input = input;
this.externalResolve = externalResolve;
this.libFileName = libFileName;
this.realpath = typescript.createCompilerHost({})['realpath'];
this.reset();
}
Host.getLibDefault = function (typescript, libFileName, originalFileName) {
Expand Down
10 changes: 5 additions & 5 deletions release/input.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export declare class FileDictionary {
initTypeScriptSourceFile: (file: File) => void;
getFileNames(onlyGulp?: boolean): string[];
private getSourceFileNames(onlyGulp?);
commonBasePath: string;
commonSourceDirectory: string;
readonly commonBasePath: string;
readonly commonSourceDirectory: string;
}
export declare class FileCache {
previous: FileDictionary;
Expand All @@ -62,8 +62,8 @@ export declare class FileCache {
getFile(name: string): File;
getFileChange(name: string): FileChange;
getFileNames(onlyGulp?: boolean): string[];
firstSourceFile: File;
commonBasePath: string;
commonSourceDirectory: string;
readonly firstSourceFile: File;
readonly commonBasePath: string;
readonly commonSourceDirectory: string;
isChanged(onlyGulp?: boolean): boolean;
}
4 changes: 2 additions & 2 deletions release/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ var Project = (function () {
var _this = this;
var configPath = path.dirname(this.configFileName);
var base;
if (this.config.compilerOptions && this.config.compilerOptions.rootDir) {
base = path.resolve(configPath, this.config.compilerOptions.rootDir);
if (this.options["rootDir"]) {
base = path.resolve(configPath, this.options["rootDir"]);
}
if (!this.config.files) {
var files_1 = [path.join(configPath, '**/*.ts')];
Expand Down

0 comments on commit 3645edb

Please sign in to comment.