ошибка TS5023: неизвестная опция компилятора 'исключить'. в gulpfile. js - PullRequest
0 голосов
/ 03 апреля 2020

Ожидаемое поведение: Я выполняю команду компиляции gulp, но получаю сообщение об ошибке: ошибка TS5023: неизвестная опция компилятора 'exclude'.] (Url) Также я получаю только конфигурацию. json файл в папке DIST после компиляции.

Фактическое поведение: Команда должна успешно работать без ошибок. Также я должен получить все файлы TS из папки SR C как JS файлы в папке DIST.

Ваш gulpfile:

var gulp = require('gulp');
var ts = require('gulp-typescript');
var zip = require('gulp-zip');
var del = require('del');
var install = require('gulp-install');
var runSequence = require('run-sequence');
var awsLambda = require("node-aws-lambda");
var sourcemaps = require('gulp-sourcemaps');
var gulpMocha = require('gulp-mocha');
var gutil = require('gulp-util');

const babel = require('gulp-babel');
gulp.task('clean', function () {
    return del(['./dist','./testJs', './dist.zip']);
});


gulp.task('compile', function () {
  return gulp.src(['src/**/*.ts' ]) //'typings/**/*.d.ts'])
    .pipe(sourcemaps.init())
    .pipe(ts({
      noImplicitAny: false,
      removeComments: true,
      preserveConstEnums: true,
      target: 'es2015',
      module: 'commonjs',
      noExternalResolve: true,
      exclude: ["node_modules", "dist"]
    }))
    .pipe(babel({
      presets: [ 'es2015' ],
      plugins: ['transform-runtime']      
    }))
    // sourceRoot must be relative to the running directory
    // It appears VSCode does resolve the path relative to the cwd
    // so using something like /src doesn't work, it has to be relative
    // to the /dist folder where we will run the app from
    // Need to test if maps help when errors are thrown in aws and if we should upload them
    .pipe(sourcemaps.write('.', { sourceRoot: '../src' }))
    .pipe(gulp.dest('./dist'))
    ,
    gulp.src(['src/**/*.json'])
    .pipe(gulp.dest('./dist'));
});


gulp.task('node-mods', function () {
    return gulp.src('./package.json')
    .pipe(gulp.dest('dist/'))
    .pipe(install({ production: true }));
});

gulp.task('zip', function () {
    return gulp.src(['dist/**/*', '!dist/package.json', '!dist/*.map'])
    .pipe(zip('1033_RMSG_MRDR.zip'))
    .pipe(gulp.dest('./dist/zip/'));
});

/* gulp.task('upload', ['zip'], function (callback) {
    awsLambda.deploy('./MME_TO_SAP EAC_VS_CODE PROJECT.zip', require("./lambda-config.js"), callback);
}); */


gulp.task('deploy', function (callback) {
    return runSequence(
        'clean',
        'compile',
        'compiletest',
        'test',
        'node-mods',
    callback
    );
});


/// *************** UNIT TEST TASKS **************
gulp.task('compiletest', function () {
  return gulp.src(['test/**/*.ts' ]) //'typings/**/*.d.ts'])
    .pipe(sourcemaps.init())
    .pipe(ts({
      noImplicitAny: true,
      removeComments: true,
      preserveConstEnums: true,
      target: 'es2015',
      module: 'commonjs',
      noExternalResolve: true,
      exclude: ["node_modules", "testJs"]
    }))
    .pipe(babel({
      presets: [ 'es2015' ],
      plugins: ['transform-runtime']      
    }))
    // sourceRoot must be relative to the running directory
    // It appears VSCode does resolve the path relative to the cwd
    // so using something like /src doesn't work, it has to be relative
    // to the /dist folder where we will run the app from
    // Need to test if maps help when errors are thrown in aws and if we should upload them
    .pipe(sourcemaps.write('.', { sourceRoot: '../test' }))
    .pipe(gulp.dest('./testJs'));
});

gulp.task('test', function(){
    return gulp.src(['testJS/**/*.js'],{read:false})
    .pipe(gulpMocha({reporter:'list'}))
    .on('error', gutil.log);
})

tsconfig. json

{
    "compilerOptions": {
        "module": "commonjs",
        "removeComments": true,
        "preserveConstEnums": true,
        "target": "es2015"
    },
    "exclude": ["node_modules", "dist"]
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...