Code Monkey home page Code Monkey logo

eggroll's Introduction

eggroll

Commonjs module bundler that hoists all modules into a single scope so they can be concatenated safely without wrapping them in individual function scopes.

This allows the resulting package to be minified more efficiently and minimizes the extra overhead at runtime from evaluating these modules. See: https://nolanlawson.com/2016/08/15/the-cost-of-small-modules/

How this works

We implement the ideas described in http://www.nonblocking.io/2011/12/experimental-support-for-common-js-and.html that have been implemented in Google's closure compiler.

  1. All local variables are prefixed with a module specific prefix so they don't collide with local variables in other modules when added to the same scope.
  2. module.exports and exports.* are replaced with a module specific global that other modules then reference directly.
  3. require calls are replace with the respective module specific globals.

Running eggroll on the rollup-comparison: with output: https://gist.github.com/ymichael/91ef54ca7c756530635285cf8eb41d6e (318 bytes gzipped).

Installation

npm install -g eggroll

Quick Start

# Outputs a bundle using main.js as the entry point.
$ eggroll bundle --resolve main.js

# Outputs a bundle using public/main.js as the entry point.
$ eggroll bundle --resolve --root ./public ./public/main.js

# Outputs a bundle containing just the given files
$ eggroll bundle --root ./public ./public/foo.js ./public/bar.js

Usage

Usage: eggroll <command> [options]

Commands:
  deps [options]               Output the dependencies found for the given entry
                               point
  bundle [options] <files...>  Bundle the given files

Options:
  -h, --help  Show help                                                [boolean]
$ eggroll bundle -h
bin/cli.js bundle [options] <files...>

Options:
  -h, --help  Show help                                                [boolean]
  --prefix    custom prefix for module variables[string] [default: "$$module$$"]
  --resolve   whether to resolve dependencies         [boolean] [default: false]
  --root      root to resolve module ids
                                             [string] [default: "process.cwd()"]
$ eggroll deps [options]

Options:
  -h, --help  Show help                                                [boolean]
  --entry     module id of bundle entry point                [string] [required]
  --root      root to resolve module ids
                                             [string] [default: "process.cwd()"]

API Example

var eggroll = require('eggroll');
// TODO

Other links

eggroll's People

Contributors

ymichael avatar

Watchers

 avatar  avatar

eggroll's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.