3.2.0 • Public • Published


Version npm License npm Downloads Build Status Dependencies

Utility functions to bundle and generate assets that can be served over the web. The workers and minifiers are used by carpenterd-worker to generate builds for


npm install workers-factory --save


const Factory = require('workers-factory');

// Run a webpack build
Factory.webpack(options, (err, files) => {
  // returns an array of files that were output.

We assume options.content is a path to a fully built (npm installed) tar.gz.


Worker will trigger the factory to go through the following methods in series. The factory line will always have to complete in full for a build to be considered done.

Factory step Execution
unpack Untar the contents of the tarball
init Read package.json and configure factory
exists Check if entry file exists
read Read the entry file
assemble Execute the builder implemented run
minify Minify the content for env={ test, prod }
pack Create a tarball of contents
clean Remove temporary build directory

Note: Factory.assemble will execute the exported run function from each worker. It will callback the next step in the chain with a Buffer of content if it completes without errors.


  • Browserify: Create a bundle using Browserify. Configured through package.json#browserify the content is passed to the browserify.bundle method.
  • Webpack: Will read webpack.config.js from tarball content and execute the bundled Webpack to generate a build of assets.


Based on the file extension one of the following minifiers is available to minify the asset content. Configuration for both JS minifiers can be supplied through wrhs.toml using the minify property.

  • CleanCSS: Minifies CSS using CleanCSS, special comments are removed and a sourcemap is generated by default.
  • Minimize: Minifies HTML using minimize.
  • Uglifyjs: Minify JS using Uglifyjs.
  • Terser: Minify JS (containing ES6) using Terser. Requires opt-in in through [wrhs.toml][wrhs.toml]
    minifier = 'terser'


npm test

Package Sidebar


npm i workers-factory

Weekly Downloads






Unpacked Size

270 kB

Total Files


Last publish


  • mmason2
  • jpina1-godaddy
  • jgowdy
  • ibrandao
  • jpage
  • kinetifex
  • rxmarbles
  • kquerna
  • 3rdeden
  • jcrugzz
  • dcousineau
  • swaagie
  • indexzero
  • bradleymeck
  • decompil3d
  • sivanmehta
  • fritzmonkey