Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

chickendinosaur-footprint

JohnPittman47MIT0.1.8

Consolidates redundant code to reduce file size footprint based on the selected transform.

shrink, footprint, consolidate, babel, babelify, es6, require, module, browserify, minify, compressor, harmony, usestrict, compression, transformer, transofrming

readme

Footprint

Working with ES6, Babel/Babelify, Browserify? This is for you!

  • Node module for reorganizing redundant code. Each Transform is just a method that takes in a text string and can be used by itself.
  • Wrote this so I can be at peace migrating to ES6 early and using Browserify and because being bloated bugs me cough jQuery.
  • Minimizes the footprint on Babel concatinated files like a Browserify bundle.
  • Works on minified (minified with uglify) and non-minified code against any style formatting! (the output is kept in original form for debuggin purposes so even though it will rip against uglified code, you will need to re-uglify after which uglifying should always be done last in the build process anyway)

Development

Requirements

  • nodejs
  • npm install -g gulp
  • npm install

Test

gulp test

Usage

Installation

npm install chickendinosaur-footprint

How to use...

Transform types

  • footprint.Transform.usestrict
  • footprint.Transform.babel (uses footprint.Transform.usestrict)

Using the transformer in debug

var footprint = require('chickendinosaur-footprint');

footprint.Transformer({
        debug:true
    })
    .src('./test/mock/babelMock.dirty.js')
    .transform(footprint.Transform.babel)
    .dest('./dist/babelMock.transformed.js');

Using a transform as standalone

var footprint = require('chickendinosaur-footprint');
var fs = require('fs');

var text = fs.readFileSync('./test/mock/babelMock.dirty.js', 'utf-8');

var output = footprint.Transform.babel(text);

Chaining Transforms

var footprint = require('chickendinosaur-footprint');

footprint.Transformer({
    debug:true
})
.src('./test/mock/babelMock.dirty.js')
.transform(footprint.Transform.babel)
.transform(footprint.Transform.usestrict)
.dest('./dist/babelMock.transformed.js')

Chaining multiple input/outputs

var footprint = require('chickendinosaur-footprint');

footprint.Transformer({
    debug:true
})
.src('./test/mock/usestrictMock.dirty.js')
.transform(footprint.Transform.usestrict)
.dest('./dist/usestrictMock.transformed.js')
.src('./test/mock/babelMock.dirty.js')
.transform(footprint.Transform.babel)
.dest('./dist/babelMock.transformed.js');

Example

Using the footprint.Transform.usestrict Transform

var footprint = require('chickendinosaur-footprint');

gulp.task('footprint', function() {
    footprint.Transformer({
        debug:true
    })
    .src('./test/mock/usestrictMock.dirty.js')
    .transform(footprint.Transform.usestrict)
    .dest('./dist/usestrictMock.transformed.js');
});

Before

'use strict' "use strict" 'use strict'; "use strict";

After

"use strict";

Results


Input:

  • ./test/mock/usestrictMock.dirty.js
  • 0.0560 KB

Transform:

  • usestrict

Difference:

  • 0.0430 KB
  • 76.7857 %

Output:

  • ./dist/usestrictMock.transformed.js
  • 0.0130 KB

Release Notes

v0.1.6

  • Added consolidatoin for require/_interopRequireDefault statements.
  • Changed all output to original form instead of uglified version since you will have to uglify after anyway.