Skip to content

Commit 3444964

Browse files
committed
Update release
1 parent e6d72c6 commit 3444964

File tree

4 files changed

+28
-18
lines changed

4 files changed

+28
-18
lines changed

release/compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var ts = require('typescript');
22
var path = require('path');
3-
var tsApi = require('./tsApi');
3+
var tsApi = require('./tsapi');
44
var output = require('./output');
55
var host = require('./host');
66
var filter = require('./filter');

release/main.js

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
///<reference path='../typings/tsd.d.ts'/>
2-
var __extends = this.__extends || function (d, b) {
2+
var __extends = (this && this.__extends) || function (d, b) {
33
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
44
function __() { this.constructor = d; }
55
__.prototype = b.prototype;
@@ -77,18 +77,28 @@ function compile(param, filters, theReporter) {
7777
proj.compiler.prepare(proj);
7878
return inputStream;
7979
}
80-
var langMap = {
81-
'es3': 0 /* ES3 */,
82-
'es5': 1 /* ES5 */,
83-
'es6': 2 /* ES6 */
84-
};
85-
var moduleMap = {
86-
'commonjs': 1 /* CommonJS */,
87-
'amd': 2 /* AMD */,
88-
'none': 0 /* None */
89-
};
80+
function createEnumMap(input) {
81+
var map = {};
82+
var keys = Object.keys(input);
83+
for (var key in keys) {
84+
var value = map[key];
85+
if (typeof value === 'number') {
86+
map[key.toLowerCase()] = value;
87+
}
88+
}
89+
return map;
90+
}
91+
function getScriptTarget(typescript, language) {
92+
var map = createEnumMap(ts.ScriptTarget);
93+
return map[language.toLowerCase()];
94+
}
95+
function getModuleKind(typescript, moduleName) {
96+
var map = createEnumMap(ts.ModuleKind);
97+
return map[moduleName.toLowerCase()];
98+
}
9099
function getCompilerOptions(settings) {
91100
var tsSettings = {};
101+
var typescript = settings.typescript || ts;
92102
for (var key in settings) {
93103
if (!Object.hasOwnProperty.call(settings, key))
94104
continue;
@@ -104,13 +114,13 @@ function getCompilerOptions(settings) {
104114
tsSettings[key] = settings[key];
105115
}
106116
if (typeof settings.target === 'string') {
107-
tsSettings.target = langMap[settings.target.toLowerCase()];
117+
tsSettings.target = getScriptTarget(typescript, settings.target);
108118
}
109119
else if (typeof settings.target === 'number') {
110120
tsSettings.target = settings.target;
111121
}
112122
if (typeof settings.module === 'string') {
113-
tsSettings.module = moduleMap[settings.module.toLowerCase()];
123+
tsSettings.module = getModuleKind(typescript, settings.module);
114124
}
115125
else if (typeof settings.module === 'number') {
116126
tsSettings.module = settings.module;
@@ -128,9 +138,6 @@ function getCompilerOptions(settings) {
128138
if (settings.sourceRoot !== undefined) {
129139
console.warn('gulp-typescript: sourceRoot isn\'t supported any more. Use sourceRoot option of gulp-sourcemaps instead.');
130140
}
131-
if (settings.rootDir !== undefined) {
132-
console.warn('gulp-typescript: rootDir isn\'t supported. Use the base option of gulp.src instead.');
133-
}
134141
if (settings.declarationFiles !== undefined) {
135142
tsSettings.declaration = settings.declarationFiles;
136143
}

release/output.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var path = require('path');
33
var sourceMap = require('source-map');
44
var gutil = require('gulp-util');
55
var utils = require('./utils');
6-
var tsApi = require('./tsApi');
6+
var tsApi = require('./tsapi');
77
(function (OutputFileKind) {
88
OutputFileKind[OutputFileKind["JavaScript"] = 0] = "JavaScript";
99
OutputFileKind[OutputFileKind["SourceMap"] = 1] = "SourceMap";

release/project.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ var Project = (function () {
3030
throw new Error('gulp-typescript: You can only use src() if the \'files\' property exists in your tsconfig.json. Use gulp.src(\'**/**.ts\') instead.');
3131
}
3232
var base = path.dirname(this.configFileName);
33+
if (this.config.compilerOptions && this.config.compilerOptions.rootDir) {
34+
base = path.resolve(base, this.config.compilerOptions.rootDir);
35+
}
3336
return vfs.src(this.config.files.map(function (file) { return path.resolve(base, file); }), { base: base });
3437
};
3538
return Project;

0 commit comments

Comments
 (0)