add a `transpileOnly` option to gulp-tsb

pull/151609/head
Johannes 2022-06-08 17:33:54 +02:00
parent 6f5fc17622
commit 1105ead47b
No known key found for this signature in database
GPG Key ID: 6DEF802A22264FCA
2 changed files with 14 additions and 9 deletions

View File

@ -30,7 +30,7 @@ function createTypeScriptBuilder(config, projectFile, cmd) {
}
let host = new LanguageServiceHost(cmd, projectFile, _log), service = ts.createLanguageService(host, ts.createDocumentRegistry()), lastBuildVersion = Object.create(null), lastDtsHash = Object.create(null), userWantsDeclarations = cmd.options.declaration, oldErrors = Object.create(null), headUsed = process.memoryUsage().heapUsed, emitSourceMapsInStream = true;
// always emit declaraction files
host.getCompilationSettings().declaration = true;
host.getCompilationSettings().declaration = !config.transpileOnly;
function file(file) {
// support gulp-sourcemaps
if (file.sourceMap) {
@ -149,8 +149,10 @@ function createTypeScriptBuilder(config, projectFile, cmd) {
for (let fileName of host.getScriptFileNames()) {
if (lastBuildVersion[fileName] !== host.getScriptVersion(fileName)) {
toBeEmitted.push(fileName);
toBeCheckedSyntactically.push(fileName);
toBeCheckedSemantically.push(fileName);
if (!config.transpileOnly) {
toBeCheckedSyntactically.push(fileName);
toBeCheckedSemantically.push(fileName);
}
}
}
return new Promise(resolve => {
@ -177,7 +179,7 @@ function createTypeScriptBuilder(config, projectFile, cmd) {
// remember when this was build
newLastBuildVersion.set(fileName, host.getScriptVersion(fileName));
// remeber the signature
if (value.signature && lastDtsHash[fileName] !== value.signature) {
if (!config.transpileOnly && value.signature && lastDtsHash[fileName] !== value.signature) {
lastDtsHash[fileName] = value.signature;
filesWithChangedSignature.push(fileName);
}

View File

@ -14,6 +14,7 @@ import * as Vinyl from 'vinyl';
export interface IConfiguration {
verbose: boolean;
transpileOnly?: boolean;
_emitWithoutBasePath?: boolean;
}
@ -55,8 +56,7 @@ export function createTypeScriptBuilder(config: IConfiguration, projectFile: str
emitSourceMapsInStream = true;
// always emit declaraction files
host.getCompilationSettings().declaration = true;
host.getCompilationSettings().declaration = !config.transpileOnly;
function file(file: Vinyl): void {
// support gulp-sourcemaps
@ -196,8 +196,11 @@ export function createTypeScriptBuilder(config: IConfiguration, projectFile: str
if (lastBuildVersion[fileName] !== host.getScriptVersion(fileName)) {
toBeEmitted.push(fileName);
toBeCheckedSyntactically.push(fileName);
toBeCheckedSemantically.push(fileName);
if (!config.transpileOnly) {
toBeCheckedSyntactically.push(fileName);
toBeCheckedSemantically.push(fileName);
}
}
}
@ -233,7 +236,7 @@ export function createTypeScriptBuilder(config: IConfiguration, projectFile: str
newLastBuildVersion.set(fileName, host.getScriptVersion(fileName));
// remeber the signature
if (value.signature && lastDtsHash[fileName] !== value.signature) {
if (!config.transpileOnly && value.signature && lastDtsHash[fileName] !== value.signature) {
lastDtsHash[fileName] = value.signature;
filesWithChangedSignature.push(fileName);
}