Gulp Dissection

Gulp is a streaming build system written in JavaScript that relies on the power of Node Streams to handle tasks as fast possible, with maximum concurency. Pipeline written in Gulpfiles are easy to follow, especially considering the huge amount of available plugins, but how does the magic really happen?

Under the hood

The main entry point of Gulp (index.js) is surprisingly small : only 40 SLOC, deprecated code included! Each function of the API delegates to a dependency:

This ecosystem is a nice exemple of tiny modules working well together.

Tasks management with Orchestrator

The Gulp constructor inherits from Orchestrator, but just makes an alias to the add() method as task(). Orchestrator takes care of the sequencing and dependencies between tasks.

I/O with Vinyls

src() and dest() handle globs, and return file objects as either Stream or Buffers (default behavior). This way everything is kept in memory during the pipeline ; long disk access are avoided.

Watches for changes through Gaze

Incremental building is a huge convenience to mimic legacy web workflow where a full refresh is only a F5 away. gaze's role is to monitor source changes and notify tasks.