Skip to content

Commit e8a12eb

Browse files
committed
Update release
1 parent e304440 commit e8a12eb

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

release/compiler.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export declare class ProjectCompiler implements ICompiler {
1414
host: Host;
1515
project: ProjectInfo;
1616
program: ts.Program;
17+
private hasSourceMap;
1718
prepare(project: ProjectInfo): void;
1819
inputFile(file: File): void;
1920
inputDone(): void;

release/compiler.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ var ProjectCompiler = (function () {
1212
}
1313
ProjectCompiler.prototype.prepare = function (project) {
1414
this.project = project;
15+
this.hasSourceMap = false;
16+
};
17+
ProjectCompiler.prototype.inputFile = function (file) {
18+
if (file.gulp.sourceMap)
19+
this.hasSourceMap = true;
1520
};
16-
ProjectCompiler.prototype.inputFile = function (file) { };
1721
ProjectCompiler.prototype.inputDone = function () {
1822
var _this = this;
1923
if (!this.project.input.firstSourceFile) {
@@ -27,6 +31,7 @@ var ProjectCompiler = (function () {
2731
.map(function (fileName) { return _this.project.input.getFile(fileName).gulp.base; }));
2832
}
2933
}
34+
this.project.options.sourceMap = this.hasSourceMap;
3035
var currentDirectory = utils.getCommonBasePathOfArray(rootFilenames.map(function (fileName) { return _this.project.input.getFile(fileName).gulp.cwd; }));
3136
this.host = new host_1.Host(this.project.typescript, currentDirectory, this.project.input, this.project.options);
3237
this.program = this.project.typescript.createProgram(rootFilenames, this.project.options, this.host, this.program);
@@ -57,7 +62,6 @@ var ProjectCompiler = (function () {
5762
this.project.output.finish(result);
5863
};
5964
ProjectCompiler.prototype.emitFile = function (result, currentDirectory, file) {
60-
var _this = this;
6165
var jsFileName;
6266
var dtsFileName;
6367
var jsContent;
@@ -69,7 +73,7 @@ var ProjectCompiler = (function () {
6973
case 'js':
7074
case 'jsx':
7175
jsFileName = fileName;
72-
jsContent = _this.removeSourceMapComment(content);
76+
jsContent = content;
7377
break;
7478
case 'd.ts':
7579
dtsFileName = fileName;
@@ -106,6 +110,9 @@ var ProjectCompiler = (function () {
106110
base = jsFileName.substring(0, jsFileName.length - outFile.length);
107111
}
108112
if (jsContent !== undefined) {
113+
if (jsMapContent !== undefined) {
114+
jsContent = this.removeSourceMapComment(jsContent);
115+
}
109116
this.project.output.writeJs(base, jsFileName, jsContent, jsMapContent, file ? file.gulp.cwd : currentDirectory, file);
110117
}
111118
if (dtsContent !== undefined) {

release/host.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ export declare class Host implements ts.CompilerHost {
1818
getSourceFile: (fileName: string, languageVersion: ts.ScriptTarget, onError?: (message: string) => void) => ts.SourceFile;
1919
realpath: (path: string) => string;
2020
getDirectories: (path: string) => string[];
21+
directoryExists: (path: string) => boolean;
2122
}

release/host.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,9 @@ var Host = (function () {
2626
return sourceFile.ts;
2727
return _this.fallback.getSourceFile(fileName, languageVersion, onError);
2828
};
29-
this.realpath = function (path) {
30-
return _this.fallback.realpath(path);
31-
};
32-
this.getDirectories = function (path) {
33-
return _this.fallback.getDirectories(path);
34-
};
29+
this.realpath = function (path) { return _this.fallback.realpath(path); };
30+
this.getDirectories = function (path) { return _this.fallback.getDirectories(path); };
31+
this.directoryExists = function (path) { return _this.fallback.directoryExists(path); };
3532
this.typescript = typescript;
3633
this.fallback = typescript.createCompilerHost(options);
3734
this.currentDirectory = currentDirectory;

release/output.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ var Output = (function () {
3535
};
3636
Output.prototype.applySourceMap = function (sourceMapContent, original, output) {
3737
var _this = this;
38+
if (sourceMapContent === undefined)
39+
return undefined;
3840
var map = JSON.parse(sourceMapContent);
3941
var directory = path.dirname(output.path);
4042
// gulp-sourcemaps docs:
@@ -62,7 +64,7 @@ var Output = (function () {
6264
continue;
6365
for (var i = 0; i < inputMap.sources.length; i++) {
6466
var absolute = path.resolve(sourceFile.gulp.base, inputMap.sources[i]);
65-
var relative = path.relative(directory, absolute);
67+
var relative = path.relative(output.base, absolute);
6668
generator.setSourceContent(relative, inputMap.sourcesContent[i]);
6769
}
6870
}

0 commit comments

Comments
 (0)