3.2.0 • Published 1 year ago

workers-factory v3.2.0

Weekly downloads
12
License
MIT
Repository
github
Last release
1 year ago

workers-factory

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 Warehouse.ai.

Install

npm install workers-factory --save

Usage

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.

API

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 stepExecution
unpackUntar the contents of the tarball
initRead package.json and configure factory
existsCheck if entry file exists
readRead the entry file
assembleExecute the builder implemented run
minifyMinify the content for env={ test, prod }
packCreate a tarball of contents
cleanRemove 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.

Workers

  • 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.

Minification

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
    [minify]
    minifier = 'terser'

Test

npm test
3.2.0

1 year ago

3.1.0

4 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.7.6

5 years ago

1.7.5

5 years ago

1.7.4

5 years ago

1.7.3

5 years ago

1.7.2

5 years ago

1.7.1

6 years ago

1.7.0

6 years ago

1.6.0

6 years ago

1.5.1

6 years ago

1.5.0

7 years ago

1.4.1

7 years ago

1.4.0

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago