Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A rose by any other name…

A rose by any other name…

Browserify's core concepts, based on "Webpack: Core Concepts" by Sean Larkin. Presented at NodeSource: Webpack Edition meetup.

Terin Stock

March 15, 2017
Tweet

More Decks by Terin Stock

Other Decks in Technology

Transcript

  1. A rose by any other name would smell as sweet

    Juliet, Romeo and Juliet, Act II, Scene II
  2. Task Runners? Let you run pre-defined tasks, and usually with

    some amount of chaining and parallelism Have no concept of dependencies, other than those that you define They are not JavaScript bundlers
  3. Browserify CLI $> browserify app/index.js > dist/app.js $> browserify app/index.js

    | uglifyjs --compress --mangle - > dist/app.min.js $> browserify –e app/index.js –o dist/app.js
  4. Browserify API var browserify = require('browserify'); var bundle = browserify({

    // configuration options }); b.add('./app/index.js'); b.bundle() // return a Node.js stream .pipe(process.stdout); See also: Browserify Handbook
  5. Node Streams Allow us to pipe() together small components, much

    like pipes on a Unix shell allow us to stitch together small programs. See also: Streams Handbook
  6. Concept: Entry The beginning of your application, the module that’s

    loaded first in your browser. index.js component.js utility.js react lodash
  7. Everything is a Stream Browserify is built atop a labeled

    pipeline, configurable a runtime, that is a stream. From entry to output, files are represented as rows streamed on this pipeline. This pipeline is also how plugins can modify Browserify behavior.
  8. I was going to tell you I built a prototype

    of this idea here, but life got in the way and I didn’t finish. [ ]