lib/precompiler.js
function minify(output, sourceMapFile) {
  try {
    // Try to resolve uglify-js in order to see if it does exist
    require.resolve('uglify-js');
  } catch (e) {
    if (e.code !== 'MODULE_NOT_FOUND') {
      // Something else seems to be wrong
      throw e;
    }
    // it does not exist!
    console.error('Code minimization is disabled due to missing uglify-js dependency');
    return output;
  }
  return require('uglify-js').minify(output.code, {
    sourceMap: {
      content: output.map,
      url: sourceMapFile
    }
  });
}
function minify(output, sourceMapFile) {
  try {
    // Try to resolve uglify-js in order to see if it does exist
    require.resolve('uglify-js');
  } catch (e) {
    if (e.code !== 'MODULE_NOT_FOUND') {
      // Something else seems to be wrong
      throw e;
    }
    // it does not exist!
    console.error('Code minimization is disabled due to missing uglify-js dependency');
    return output;
  }
  return require('uglify-js').minify(output.code, {
    sourceMap: {
      content: output.map,
      url: sourceMapFile
    }
  });
}
function minify ( output , sourceMapFile ) { try { // Try to resolve uglify-js in order to see if it does exist require . resolve ( 'uglify-js' ) ; } catch ( e ) { if ( e . code !== 'MODULE_NOT_FOUND' ) { // Something else seems to be wrong throw e ; } // it does not exist! console . error ( 'Code minimization is disabled due to missing uglify-js dependency' ) ; return output ; } return require ( 'uglify-js' ) . minify ( output . code , { sourceMap : { content : output . map , url : sourceMapFile } } ) ; }
Run uglify to minify the compiled template, if uglify exists in the dependencies.

We are using `require` instead of `import` here, because es6-modules do not allow
dynamic imports and uglify-js is an optional dependency. Since we are inside NodeJS here, this
should not be a problem.

@param {string} output the compiled template
@param {string} sourceMapFile the file to write the source map to.
Run uglify to minify the compiled template if uglify exists in the dependencies .