Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

composite makes gulp fail but not tsc #681

Open
FrancescElies opened this issue May 3, 2023 · 1 comment
Open

composite makes gulp fail but not tsc #681

FrancescElies opened this issue May 3, 2023 · 1 comment

Comments

@FrancescElies
Copy link

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?

@FrancescElies
Copy link
Author

Upgrading gulp-typescript to "^6.0.0-alpha.1" seems to solve the problem.

diff --git a/package.json b/package.json
index 5116346..9563e36 100644
--- a/package.json
+++ b/package.json
@@ -5,7 +5,7 @@
   "devDependencies": {
     "gulp": "^4.0.2",
     "gulp-debug": "^4.0.0",
-    "gulp-typescript": "^5.0.1",
+    "gulp-typescript": "^6.0.0-alpha.1",
     "typescript": "^5.0.4"
   }
 }
diff --git a/tsconfig.json b/tsconfig.json
index 8238da7..05234da 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -4,8 +4,8 @@
   "compilerOptions": {
     "outDir": "./dist",
     "declaration": true,
-    "declarationMap": true
-    // "composite": true
+    "declarationMap": true,
+    "composite": true
   },
   "include": ["src/**/*"]
 }

I'll leave the issue open to wait for suggestions but feel free to close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant