All Projects → indutny → Common Shake

indutny / Common Shake

CommonJS Tree Shaker API

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Common Shake

Webpack Common Shake
CommonJS Tree Shaker plugin for WebPack
Stars: ✭ 875 (+503.45%)
Mutual labels:  commonjs, tree-shaking
Common Shakeify
browserify tree shaking plugin using `common-shake`
Stars: ✭ 101 (-30.34%)
Mutual labels:  commonjs, tree-shaking
That React App You Want
That react app you always wanted: [email protected], [email protected], postCSS, purifycss, dll's and code splitting examples, bregh. Highly opinionated but you better like it.
Stars: ✭ 27 (-81.38%)
Mutual labels:  tree-shaking
Node Blockly
Blockly for Node.js and Browser via CommonJS module
Stars: ✭ 117 (-19.31%)
Mutual labels:  commonjs
Typescript Restful Starter
Node.js + ExpressJS + Joi + Typeorm + Typescript + JWT + ES2015 + Clustering + Tslint + Mocha + Chai
Stars: ✭ 97 (-33.1%)
Mutual labels:  commonjs
Units Converter
A simple utility library to measure and convert between units
Stars: ✭ 31 (-78.62%)
Mutual labels:  commonjs
Tarp.require
A lightweight & asynchronous JavaScript loader for CommonJS and NodeJS modules.
Stars: ✭ 117 (-19.31%)
Mutual labels:  commonjs
Browserify Rails
Browserify + Rails = a great way to modularize your legacy JavaScript
Stars: ✭ 701 (+383.45%)
Mutual labels:  commonjs
Bootstrap.native
If you are looking for Bootstrap without jQuery, this is it.
Stars: ✭ 1,693 (+1067.59%)
Mutual labels:  commonjs
Webpack Core Usage
webpack2完整系列课程,欢迎阅读。同时欢迎移步我的react全家桶文章全集: https://github.com/liangklfangl/react-article-bucket
Stars: ✭ 94 (-35.17%)
Mutual labels:  tree-shaking
Cjstoesm
A tool that can transform CommonJS to ESM
Stars: ✭ 109 (-24.83%)
Mutual labels:  commonjs
Serverless Plugin Webpack
Serverless Plugin Webpack
Stars: ✭ 72 (-50.34%)
Mutual labels:  tree-shaking
Babel Plugin Import Fix
alter import module to certain module file path for smaller bundle and better performance
Stars: ✭ 34 (-76.55%)
Mutual labels:  tree-shaking
Babel Plugin Global Require
A simple plugin that allows you to require globally
Stars: ✭ 102 (-29.66%)
Mutual labels:  commonjs
Neuron.js
A Full Feature CommonJS Module Manager, Dependency Graph Handler and Loader for Browsers
Stars: ✭ 66 (-54.48%)
Mutual labels:  commonjs
Bonsai
Understand the tree of dependencies inside your webpack bundles, and trim away the excess.
Stars: ✭ 732 (+404.83%)
Mutual labels:  commonjs
Steal
Gets JavaScript
Stars: ✭ 1,353 (+833.1%)
Mutual labels:  commonjs
Typescript Webpack Tree Shaking
Tree-shaking example with Typescript and Webpack
Stars: ✭ 144 (-0.69%)
Mutual labels:  tree-shaking
Awesome Bundle Size
📝 An awesome list of tools and techniques to make your web bundle size smaller and your web apps load faster.
Stars: ✭ 118 (-18.62%)
Mutual labels:  tree-shaking
Parcel
The zero configuration build tool for the web. 📦🚀
Stars: ✭ 39,670 (+27258.62%)
Mutual labels:  commonjs

CommonJS Tree Shaker

NPM version Build Status

See webpack-common-shake for webpack plugin.

Usage

const acorn = require('acorn');
const Analyzer = require('common-shake').Analyzer;

const a = new Analyzer();

a.run(acorn.parse(`
  'use strict';
  const lib = require('./a.js');
  exports.a = lib.a;
`, { locations: true }), 'index.js');

a.run(acorn.parse(`
  'use strict';
  exports.a = 42;
`, { locations: true }), 'a.js');

a.resolve('index.js', './a.js', 'a.js');
console.log(a.isSuccess(), a.bailouts);
// true false

console.log(a.getModule('index.js').getInfo());
// { bailouts: false, declarations: [ 'a' ], uses: [] }

console.log(a.getModule('a.js').getInfo());
// { bailouts: false, declarations: [ 'a' ], uses: [ 'a' ] }

const module = a.getModule('a.js');
a.getDeclarations().forEach((decl) => {
  console.log(module.isUsed(decl.name) ? 'used' : 'not used');
  console.log(decl.name, decl.ast);
});

// If you want to mark all exported values of module as used:
a.getModule('root').forceExport();

Graphviz

For debugging and inspection purposes a graph in dot format may be generated from the modules hierarchy using following API:

const Graph = require('common-shake').Graph;
const graph = new Graph('/path/to/working/dir');

console.log(graph.generate(analyzer.getModules()));

LICENSE

This software is licensed under the MIT License.

Copyright Fedor Indutny, 2017.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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