lib/index.js
function wrapBundle () {
    let wrap = browserify.pipeline.get("wrap");
    let bannerAlreadyAdded = false;
    let banner;

    wrap.push(through(addBannerToBundle));
    if (browserify._options.debug) {
      wrap.push(through(addBannerToSourcemap));
    }

    /**
     * Injects the banner comment block into the Browserify bundle
     */
    function addBannerToBundle (chunk, enc, next) {
      if (!bannerAlreadyAdded) {
        bannerAlreadyAdded = true;
        try {
          banner = getBanner(options);
          this.push(new Buffer(banner));
        }
        catch (e) {
          next(e);
        }
      }
      this.push(chunk);
      next();
    }

    /**
     * Adjusts the sourcemap to account for the banner comment block
     */
    function addBannerToSourcemap (chunk, enc, next) {
      let pushed = false;

      if (banner) {
        // Get the sourcemap, once it exists
        let conv = convertSourcemap.fromSource(chunk.toString("utf8"));
        if (conv) {
          // Offset the sourcemap by the number of lines in the banner
          let offsetMap = offsetSourcemap(conv.toObject(), countLines(banner));
          this.push(new Buffer("\n" + convertSourcemap.fromObject(offsetMap).toComment() + "\n"));
          pushed = true;
        }
      }

      if (!pushed) {
        // This chunk doesn't contain anything for us to modify,
        // so just pass it along as-is
        this.push(chunk);
      }
      next();
    }
  }
function wrapBundle () {
    let wrap = browserify.pipeline.get("wrap");
    let bannerAlreadyAdded = false;
    let banner;

    wrap.push(through(addBannerToBundle));
    if (browserify._options.debug) {
      wrap.push(through(addBannerToSourcemap));
    }

    /**
     * Injects the banner comment block into the Browserify bundle
     */
    function addBannerToBundle (chunk, enc, next) {
      if (!bannerAlreadyAdded) {
        bannerAlreadyAdded = true;
        try {
          banner = getBanner(options);
          this.push(new Buffer(banner));
        }
        catch (e) {
          next(e);
        }
      }
      this.push(chunk);
      next();
    }

    /**
     * Adjusts the sourcemap to account for the banner comment block
     */
    function addBannerToSourcemap (chunk, enc, next) {
      let pushed = false;

      if (banner) {
        // Get the sourcemap, once it exists
        let conv = convertSourcemap.fromSource(chunk.toString("utf8"));
        if (conv) {
          // Offset the sourcemap by the number of lines in the banner
          let offsetMap = offsetSourcemap(conv.toObject(), countLines(banner));
          this.push(new Buffer("\n" + convertSourcemap.fromObject(offsetMap).toComment() + "\n"));
          pushed = true;
        }
      }

      if (!pushed) {
        // This chunk doesn't contain anything for us to modify,
        // so just pass it along as-is
        this.push(chunk);
      }
      next();
    }
  }
function wrapBundle ( ) { let wrap = browserify . pipeline . get ( "wrap" ) ; let bannerAlreadyAdded = false ; let banner ; wrap . push ( through ( addBannerToBundle ) ) ; if ( browserify . _options . debug ) { wrap . push ( through ( addBannerToSourcemap ) ) ; } /**
     * Injects the banner comment block into the Browserify bundle
     */ function addBannerToBundle ( chunk , enc , next ) { if ( ! bannerAlreadyAdded ) { bannerAlreadyAdded = true ; try { banner = getBanner ( options ) ; this . push ( new Buffer ( banner ) ) ; } catch ( e ) { next ( e ) ; } } this . push ( chunk ) ; next ( ) ; } /**
     * Adjusts the sourcemap to account for the banner comment block
     */ function addBannerToSourcemap ( chunk , enc , next ) { let pushed = false ; if ( banner ) { // Get the sourcemap, once it exists let conv = convertSourcemap . fromSource ( chunk . toString ( "utf8" ) ) ; if ( conv ) { // Offset the sourcemap by the number of lines in the banner let offsetMap = offsetSourcemap ( conv . toObject ( ) , countLines ( banner ) ) ; this . push ( new Buffer ( "\n" + convertSourcemap . fromObject ( offsetMap ) . toComment ( ) + "\n" ) ) ; pushed = true ; } } if ( ! pushed ) { // This chunk doesn't contain anything for us to modify, // so just pass it along as-is this . push ( chunk ) ; } next ( ) ; } }
Adds transforms to the Browserify "wrap" pipeline
Adds transforms to the Browserify wrap pipeline