Skip to content

composite makes gulp fail but not tsc #681

@FrancescElies

Description

@FrancescElies

Expected behavior:

gulp and tsc behaves the same, but I suspect I might be missing or missusing something.

NOTE: as soon as "composite": true is removed from tsconfig, gulp doesn't complain any more.

Actual behavior:

While tsc runs fine, gulp fails with the following.

npx gulp
C:\s\mytest\m_node_lib> npx gulp
[10:30:12] Using gulpfile C:\s\mytest\m_node_lib\gulpfile.js
[10:30:12] Starting 'default'...
[10:30:13] input src\index.ts
[10:30:13] input 1 item
[10:30:15] 'default' errored after 2.94 s
[10:30:15] TypeError: Cannot read property 'length' of undefined
    at Object.writeFile (C:\s\mytest\m_node_lib\node_modules\gulp-typescript\release\compiler.js:81:33)
    at writeFile (C:\s\mytest\m_node_lib\node_modules\typescript\lib\typescript.js:16515:10)
    at emitBuildInfo (C:\s\mytest\m_node_lib\node_modules\typescript\lib\typescript.js:109458:7)
    at emitSourceFileOrBundle (C:\s\mytest\m_node_lib\node_modules\typescript\lib\typescript.js:109419:7)
    at forEachEmittedFile (C:\s\mytest\m_node_lib\node_modules\typescript\lib\typescript.js:109176:18)
    at emitFiles (C:\s\mytest\m_node_lib\node_modules\typescript\lib\typescript.js:109387:5)
    at emitWorker (C:\s\mytest\m_node_lib\node_modules\typescript\lib\typescript.js:116758:26)
    at C:\s\mytest\m_node_lib\node_modules\typescript\lib\typescript.js:116743:53
    at runWithCancellationToken (C:\s\mytest\m_node_lib\node_modules\typescript\lib\typescript.js:116832:16)
    at Object.emit (C:\s\mytest\m_node_lib\node_modules\typescript\lib\typescript.js:116743:22)

Code:

gulpfile.js
var gulp = require("gulp");
var ts = require("gulp-typescript");
var debug = require("gulp-debug");

var tsProject = ts.createProject("tsconfig.json");

gulp.task("default", () => {
  return tsProject
    .src()
    .pipe(debug({ title: "input" }))
    .pipe(tsProject())
    .js.pipe(debug({ title: "js" }))
    .pipe(gulp.dest("dist"));
});
package.json
{
  "name": "mytest",
  "version": "1.0.0",
  "main": "dist/index.js",
  "devDependencies": {
    "gulp": "^4.0.2",
    "gulp-debug": "^4.0.0",
    "gulp-typescript": "^5.0.1",
    "typescript": "^5.0.4"
  }
}
src\index.ts
const a = 1;
tsconfig.json
{
  "$schema": "https://json.schemastore.org/tsconfig",
  "compilerOptions": {
    "outDir": "./dist",
    "declaration": true,
    "declarationMap": true,
    // As soon as you remove composite gulp works fine
    "composite": true  
  },
  "include": ["src/**/*"]
}

Am I doing something wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions