All Projects → browserify → Common Shakeify

browserify / Common Shakeify

Licence: mit
browserify tree shaking plugin using `common-shake`

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Common Shakeify

Common Shake
CommonJS Tree Shaker API
Stars: ✭ 145 (+43.56%)
Mutual labels:  commonjs, tree-shaking
Tinyify
a browserify plugin that runs various optimizations, so you don't have to install them all manually. makes your bundles tiny!
Stars: ✭ 392 (+288.12%)
Mutual labels:  browserify, tree-shaking
Minipack
📦 A simplified example of a modern module bundler written in JavaScript
Stars: ✭ 2,625 (+2499.01%)
Mutual labels:  browserify, commonjs
Browserify Rails
Browserify + Rails = a great way to modularize your legacy JavaScript
Stars: ✭ 701 (+594.06%)
Mutual labels:  browserify, commonjs
titaniumifier
Get a Titanium™ SDK CommonJS module out of a Node package!
Stars: ✭ 95 (-5.94%)
Mutual labels:  browserify, commonjs
Webpack Common Shake
CommonJS Tree Shaker plugin for WebPack
Stars: ✭ 875 (+766.34%)
Mutual labels:  commonjs, tree-shaking
Phaser Node Kit
Rapid Game Development with PhaserJS and Node for Modern Browsers
Stars: ✭ 39 (-61.39%)
Mutual labels:  browserify
Serverless Plugin Webpack
Serverless Plugin Webpack
Stars: ✭ 72 (-28.71%)
Mutual labels:  tree-shaking
Simplifyify
A simplified Browserify and Watchify CLI
Stars: ✭ 37 (-63.37%)
Mutual labels:  browserify
Budgeting
Budgeting - React + Redux + Webpack (tree shaking) Sample App
Stars: ✭ 971 (+861.39%)
Mutual labels:  tree-shaking
React Tsx Starter
Universal/Isomorphic React TypeScript Starter Project
Stars: ✭ 97 (-3.96%)
Mutual labels:  browserify
Npm Pipeline Rails
Use npm as part of your Rails asset pipeline
Stars: ✭ 93 (-7.92%)
Mutual labels:  browserify
Neuron.js
A Full Feature CommonJS Module Manager, Dependency Graph Handler and Loader for Browsers
Stars: ✭ 66 (-34.65%)
Mutual labels:  commonjs
Conditioner
💆🏻 Frizz free, context-aware, JavaScript modules
Stars: ✭ 1,053 (+942.57%)
Mutual labels:  browserify
String To Stream
Convert a string into a stream (streams2)
Stars: ✭ 75 (-25.74%)
Mutual labels:  browserify
Dough
React/Redux + SASS + Gulp/Browserify/Babel skeleton codebase with demo application.
Stars: ✭ 38 (-62.38%)
Mutual labels:  browserify
Webpack Core Usage
webpack2完整系列课程,欢迎阅读。同时欢迎移步我的react全家桶文章全集: https://github.com/liangklfangl/react-article-bucket
Stars: ✭ 94 (-6.93%)
Mutual labels:  tree-shaking
React Pivot
React-Pivot is a data-grid component with pivot-table-like functionality for data display, filtering, and exploration.
Stars: ✭ 981 (+871.29%)
Mutual labels:  browserify
Connectivity
Detect if the network is up (do we have connectivity?)
Stars: ✭ 58 (-42.57%)
Mutual labels:  browserify
Npm Rails
NPM support for Rails with Bundler-like DSL
Stars: ✭ 81 (-19.8%)
Mutual labels:  browserify

common-shakeify

browserify tree shaking plugin based on common-shake, the CommonJS tree shaker originally by @indutny.

Comments out unused exports from CommonJS modules.

With input files:

// math.js
exports.min = function (a, b) { return a < b ? a : b }
exports.max = function (a, b) { return a < b ? b : a }

// app.js
var math = require('./math')
console.log(math.max(10, 20))

This plugin will rewrite the files to:

// math.js
/* common-shake removed: exports.min = */ void function (a, b) { return a < b ? a : b }
exports.max = function (a, b) { return a < b ? b : a }

// app.js
var math = require('./math')
console.log(math.max(10, 20))

Use a minifier on the output to remove the exports entirely.

Install

npm install --save-dev common-shakeify

Usage

With the browserify cli:

browserify -p common-shakeify /my/app.js > bundle.js
# Minify
uglify-js bundle.js --compress > bundle.min.js

With the browserify Node API:

var commonShake = require('common-shakeify')

var b = browserify({ entries: '/my/app.js' })
  .plugin(commonShake, { /* options */ })
  .bundle()

// Minify & save
var uglify = require('minify-stream')
b
  .pipe(uglify())
  .pipe(fs.createWriteStream('bundle.min.js'))

Note that using a minifier transform like uglifyify doesn't eliminate the commented-out exports. Transforms run before common-shakeify, so you have to use a minifier on the final bundle to remove the unused exports.

Options

verbose, v

When true, print messages to stderr when exports are deleted, or the tree-shaker bails out on a module. Default false. The verbose flag only works when no custom handlers are passed, so if you're using eg. a custom onExportDelete you have to print these messages manually.

$ browserify -p [ common-shakeify -v ] app.js > bundle.js
common-shake: removed `decode` in node_modules/vlq/dist/vlq.js:10:7
common-shake: bailed out: `module.exports` assignment in node_modules/process-nextick-args/index.js:20:3

onExportDelete(filename, exportName)

Handler called for every exported identifier that is being removed. filename is the path to the file that exports the identifier. exportName is the name of the identifier. Return false to bail and keep the identifier.

onModuleBailout(module, reasons)

Handler called when a module cannot be tree-shaked for some reason. module is the Module object from common-shake. reasons is an array of reasons that caused this module to be deoptimised.

onGlobalBailout(reasons)

Handler called when tree-shaking is skipped entirely, usually because there is a dynamic require call in the source. reasons is an array of reasons for skipping tree-shaking.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].