build-system/tasks/helpers.js
/**
 * Bundles (max) or compiles (min) a given JavaScript file entry point.
 *
 * @param {string} srcDir Path to the src directory
 * @param {string} srcFilename Name of the JS source file
 * @param {string} destDir Destination folder for output script
 * @param {?Object} options
 * @return {!Promise}
 */
Bundles (max) or compiles (min) a given JavaScript file entry point.
Bundles ( max ) or compiles ( min ) a given JavaScript file entry point .
async function compileJs(srcDir, srcFilename, destDir, options) {
  options = options || {};
  const entryPoint = path.join(srcDir, srcFilename);
  if (watchedEntryPoints.has(entryPoint)) {
    return;
  }
  if (options.watch) {
    watchedEntryPoints.add(entryPoint);
    const deps = await getDependencies(entryPoint, options);
    const watchFunc = async () => {
      await doCompileJs({...options, continueOnError: true});
    };
    watch(deps).on('change', debounce(watchFunc, watchDebounceDelay));
  }
  async function doCompileJs(options) {
    const buildResult =
      options.minify && shouldUseClosure()
        ? compileMinifiedJs(srcDir, srcFilename, destDir, options)
        : esbuildCompile(srcDir, srcFilename, destDir, options);
    if (options.onWatchBuild) {
      options.onWatchBuild(buildResult);
    }
    await buildResult;
  }
  await doCompileJs(options);
}
async function compileJs ( srcDir , srcFilename , destDir , options ) { options = options || { } ; const entryPoint = path . join ( srcDir , srcFilename ) ; if ( watchedEntryPoints . has ( entryPoint ) ) { return ; } if ( options . watch ) { watchedEntryPoints . add ( entryPoint ) ; const deps = await getDependencies ( entryPoint , options ) ; const watchFunc = async ( ) => { await doCompileJs ( { ... options , continueOnError : true } ) ; } ; watch ( deps ) . on ( 'change' , debounce ( watchFunc , watchDebounceDelay ) ) ; } async function doCompileJs ( options ) { const buildResult = options . minify && shouldUseClosure ( ) ? compileMinifiedJs ( srcDir , srcFilename , destDir , options ) : esbuildCompile ( srcDir , srcFilename , destDir , options ) ; if ( options . onWatchBuild ) { options . onWatchBuild ( buildResult ) ; } await buildResult ; } await doCompileJs ( options ) ; }
Bundles (max) or compiles (min) a given JavaScript file entry point.
Bundles ( max ) or compiles ( min ) a given JavaScript file entry point .
/**
   * Actually performs the steps to compile the entry point.
   * @param {Object} options
   * @return {Promise<void>}
   */