tasks/middleware/makeDebugBuild.js
function MakeDebugBuildMiddleware (context)
{
  var options = context.options.debugBuild;
  /** @type {string[]} */
  var traceOutput = [];

  //--------------------------------------------------------------------------------------------------------------------
  // EVENTS
  //--------------------------------------------------------------------------------------------------------------------

  context.listen (ContextEvent.ON_AFTER_ANALYZE, function ()
  {
    if (options.enabled) {
      var space = context.verbose ? NL : '';
      writeln ('%Generating the <cyan>debug</cyan> build...%', space, space);
    }
  });

  //--------------------------------------------------------------------------------------------------------------------
  // PUBLIC API
  //--------------------------------------------------------------------------------------------------------------------

  this.analyze = function (filesArray)
  {
    /* jshint unused: vars */
    // Do nothing
  };

  this.trace = function (/*ModuleDef*/ module)
  {
    if (!options.enabled) return;

    var rep = options.rebaseDebugUrls;
    module.filePaths ().forEach (function (path)
    {
      if (context.outputtedFiles[path] && context.outputtedFiles[path] !== module.name)
        return;
      context.outputtedFiles[path] = true;
      if (rep)
        for (var i = 0, m = rep.length; i < m; ++i)
          path = path.replace (rep[i].match, rep[i].replaceWith);
      if (path) // Ignore empty path; it means that this middleware should not output a script tag.
        traceOutput.push (util.sprintf ('<script src=\"%\"></script>', path));
    });
  };

  this.build = function (targetScript)
  {
    /* jshint unused: vars */

    if (!options.enabled) return;

    /** @type {string[]} */
    var output = ['document.write (\''];

    if (context.prependOutput)
      output.push (context.prependOutput);

    // Output the modules (if any).
    util.arrayAppend (output, traceOutput);

    if (context.appendOutput)
      output.push (context.appendOutput);

    output.push ('\');');
    util.writeFile (targetScript, output.join ('\\\n'));
  };
}
function MakeDebugBuildMiddleware (context)
{
  var options = context.options.debugBuild;
  /** @type {string[]} */
  var traceOutput = [];

  //--------------------------------------------------------------------------------------------------------------------
  // EVENTS
  //--------------------------------------------------------------------------------------------------------------------

  context.listen (ContextEvent.ON_AFTER_ANALYZE, function ()
  {
    if (options.enabled) {
      var space = context.verbose ? NL : '';
      writeln ('%Generating the <cyan>debug</cyan> build...%', space, space);
    }
  });

  //--------------------------------------------------------------------------------------------------------------------
  // PUBLIC API
  //--------------------------------------------------------------------------------------------------------------------

  this.analyze = function (filesArray)
  {
    /* jshint unused: vars */
    // Do nothing
  };

  this.trace = function (/*ModuleDef*/ module)
  {
    if (!options.enabled) return;

    var rep = options.rebaseDebugUrls;
    module.filePaths ().forEach (function (path)
    {
      if (context.outputtedFiles[path] && context.outputtedFiles[path] !== module.name)
        return;
      context.outputtedFiles[path] = true;
      if (rep)
        for (var i = 0, m = rep.length; i < m; ++i)
          path = path.replace (rep[i].match, rep[i].replaceWith);
      if (path) // Ignore empty path; it means that this middleware should not output a script tag.
        traceOutput.push (util.sprintf ('<script src=\"%\"></script>', path));
    });
  };

  this.build = function (targetScript)
  {
    /* jshint unused: vars */

    if (!options.enabled) return;

    /** @type {string[]} */
    var output = ['document.write (\''];

    if (context.prependOutput)
      output.push (context.prependOutput);

    // Output the modules (if any).
    util.arrayAppend (output, traceOutput);

    if (context.appendOutput)
      output.push (context.appendOutput);

    output.push ('\');');
    util.writeFile (targetScript, output.join ('\\\n'));
  };
}
function MakeDebugBuildMiddleware ( context ) { var options = context . options . debugBuild ; /** @type {string[]} */ var traceOutput = [ ] ; //-------------------------------------------------------------------------------------------------------------------- // EVENTS //-------------------------------------------------------------------------------------------------------------------- context . listen ( ContextEvent . ON_AFTER_ANALYZE , function ( ) { if ( options . enabled ) { var space = context . verbose ? NL : '' ; writeln ( '%Generating the <cyan>debug</cyan> build...%' , space , space ) ; } } ) ; //-------------------------------------------------------------------------------------------------------------------- // PUBLIC API //-------------------------------------------------------------------------------------------------------------------- this . analyze = function ( filesArray ) { /* jshint unused: vars */ // Do nothing } ; this . trace = function ( /*ModuleDef*/ module ) { if ( ! options . enabled ) return ; var rep = options . rebaseDebugUrls ; module . filePaths ( ) . forEach ( function ( path ) { if ( context . outputtedFiles [ path ] && context . outputtedFiles [ path ] !== module . name ) return ; context . outputtedFiles [ path ] = true ; if ( rep ) for ( var i = 0 , m = rep . length ; i < m ; ++ i ) path = path . replace ( rep [ i ] . match , rep [ i ] . replaceWith ) ; if ( path ) // Ignore empty path; it means that this middleware should not output a script tag. traceOutput . push ( util . sprintf ( '<script src=\"%\"></script>' , path ) ) ; } ) ; } ; this . build = function ( targetScript ) { /* jshint unused: vars */ if ( ! options . enabled ) return ; /** @type {string[]} */ var output = [ 'document.write (\'' ] ; if ( context . prependOutput ) output . push ( context . prependOutput ) ; // Output the modules (if any). util . arrayAppend ( output , traceOutput ) ; if ( context . appendOutput ) output . push ( context . appendOutput ) ; output . push ( '\');' ) ; util . writeFile ( targetScript , output . join ( '\\\n' ) ) ; } ; }
Generates a script file that inserts SCRIPT tags to the head of the html document, which will load the original
source scripts in the correct order. This is used on debug builds.
@constructor
@implements {MiddlewareInterface}
@param {Context} context The execution context for the middleware stack.
Generates a script file that inserts SCRIPT tags to the head of the html document which will load the original source scripts in the correct order . This is used on debug builds .