Search code examples
javascriptgulpgulp-typescript

Exclude node_modules form typescript compile via gulp-typescript


I'm trying to run a gulp task to compile my typescript but keep on getting errors related to dependencies.

/content/node_modules/@angular/core/src/facade/lang.d.ts(12,17): error TS2304: Cannot find name 'Map'.
/content/node_modules/@angular/core/src/facade/lang.d.ts(13,17): error TS2304: Cannot find name 'Set'.

I am trying to omit the node_modules directory so that it will only notify me of problems in my code. my files are as follows:

gulpfile.js

var tsProject = ts.createProject('tsconfig.json');
gulp.task('ts', function () {
    return gulp.src([aemPaths.jcrRoot + '**/*.ts'])
        .pipe(tsProject())
        .pipe(gulp.dest(aemPaths.jcrRoot));
});

I've also tried

gulp.task('ts', function () {
    return gulp.src([aemPaths.jcrRoot + '**/*.ts','!node_modules/**/*'])
        .pipe(tsProject())
        .pipe(gulp.dest(aemPaths.jcrRoot));
});

tsconfig.json

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": false,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false,
        "suppressImplicitAnyIndexErrors": true
    },
    "exclude": [
        "node_modules"
    ]
}

I've done many searches but can't seem to find a way to omit this with gulp-typescript. Any help would greatly be appreciated.


Solution

  • You don't need exlude node_modules directory into gulp, just add typings es6-collections and es6-promise into gulp.src array