text: const gulp = require('gulp');
  const ts = require('gulp-typescript');
  const babel = require('gulp-babel');
  const sq = require('gulp-sequence');
  const del = require('del');
  
  const isProd = process.env.NODE_ENV === 'production';
  const SRC = 'src';
  const TMP = '.tmp';
  const DIST = 'dist';
  const BABELRC = {
    presets: [
      [
        'env',
        {
          targets: {
            node: 'current',
          },
          spec: true,
          modules: 'commonjs',
          useBuiltIns: true,
        },
      ],
      ...(isProd ? [
        [
          'minify',
          {
            replace: false,
            removeConsole: false,
            removeDebugger: true,
          },
        ],
      ] : []),
    ],
    plugins: [
      'transform-function-bind',
      'transform-object-rest-spread',
    ],
    ignore: isProd
      ? [
        '**/__mocks*__/*.js',
        '**/__tests*__/*.dist.spec.js',
        '**/__tests*__/*.spec.js',
      ]
      : [],
  };
  
  gulp.task('ts', () =>
    gulp.src([
      `${SRC}/**/*.ts`,
    ])
      .pipe(ts.createProject('./tsconfig.json')())
      .pipe(gulp.dest(TMP)));
  
  gulp.task('babel', () =>
    gulp.src([
      `${TMP}/**/*.js`,
    ])
      .pipe(babel(BABELRC))
      .pipe(gulp.dest(DIST)));
  
  gulp.task('clean', () => del([
    TMP,
    DIST,
  ]));
  
  gulp.task('clear', () => del([
    TMP,
  ]));
  
  gulp.task('copy', () => gulp.src([
    `${TMP}/**/*`,
    `!${TMP}/**/*.js`,
  ])
    .pipe(gulp.dest(DIST)));
  
  gulp.task('watch', () => {
    gulp.watch([
      `${SRC}/**/*.ts`,
    ], ['build']);
  });
  
  gulp.task('build', ['clean'], cb => sq(...[
    'ts',
    ['babel', 'copy'],
    'clear',
  ])(cb));
  
  gulp.task('default', ['watch'], sq('build'));
  