import { pipeline } from 'stream' ; import { promisify } from 'util' ; import gulpBabel from 'gulp-babel' ; import vfs from 'vinyl-fs' ; import { Task , Build } from '../lib' ; const asyncPipeline = promisify ( pipeline ) ; const transpileWithBabel = async ( srcGlobs , build , presets ) => { const buildRoot = build . resolvePath ( ) ; await asyncPipeline ( vfs . src ( srcGlobs . concat ( [ '!**/*.d.ts' , '!packages/**' , '!**/node_modules/**' , '!**/bower_components/**' , '!**/__tests__/**' , ] ) , { cwd : buildRoot , } ) , gulpBabel ( { babelrc : false , presets , } ) , vfs . dest ( buildRoot ) ) ; } ; export const TranspileBabel = { description : 'Transpiling sources with babel' , async run ( config , log , build ) { await transpileWithBabel ( [ '**/*.{js,ts,tsx}' , '!**/public/**' ] , build , [ require . resolve ( '@kbn/babel-preset/node_preset' ) , ] ) ; await transpileWithBabel ( [ '**/public/**/*.{ts,tsx}' ] , build , [ require . resolve ( '@kbn/babel-preset/webpack_preset' ) , ] ) ; } , } ;