Code Monkey home page Code Monkey logo

stitchup's Introduction

Browser-side require(), minifier & packager for CommonJS modules

Easily use Javascript & Coffeescript CommonJS modules in the browser using this handy commandline tool, even for non-NodeJS projects.

A directory of CommonJS modules is minified into a single javascript file, and each module can be exposed on demand in the browser via synchronous require().

StitchUp wraps the amazing stitch library https://github.com/sstephenson/stitch Thanks heaps sstephenson.

Minification is provided by the uglify library https://github.com/mishoo/UglifyJS/

Installation

$ npm install -g stitchup

Usage

Stitch up CommonJS modules located in app to public/bundle.js

$ stitchup -o public/bundle.js app

Compile in development (uncompressed) mode

$ stitchup -o public/bundle.js -m DEVELOPMENT app

Load modules via synchronous require()

# Stitch up modules in the ./app directory as ./public/bundle.js:          
$ stitchup -o ./public/bundle.js ./app     
      
# Load the bundle on your website:
<script src="/bundle.js"></script>
<script>
    $(function() {
        var app = require('controllers/app');
        app.init();
    })
</script>

# Use require() to reference modules from modules:
module.exports = {
    init: function() {
        var myCar = require('models/cars');
        myCar.drive();
    }
}

Run the provided example:

$ git clone git://github.com/secoif/StitchUp.git
Cloning into StitchUp...
$ cd StitchUp
$ cd example
$ stitchup -o ./public/app.js ./app
Compiled ./public/app.js.
$ cd public/
$ python -m "SimpleHTTPServer"
Serving HTTP on 0.0.0.0 port 8000 ...
Navigate to 0.0.0.0:8000 via your web browser and you should see that stitchup is working

Future

  • Ability to watch a directory and automatically recompile

stitchup's People

Contributors

timoxley avatar twe4ked avatar

Stargazers

Quang Van avatar Philippe Rigovanov avatar Yi Wang avatar  avatar  avatar Sam Stephenson avatar

Watchers

 avatar James Cloos avatar  avatar

stitchup's Issues

Problem installing async

I get:

> [email protected] preinstall /usr/local/lib/node_modules/stitchup/node_modules/stitch/node_modules/async
> make clean

rm -rf dist

> [email protected] install /usr/local/lib/node_modules/stitchup/node_modules/stitch/node_modules/async
> make build

mkdir -p dist
/usr/local/lib/node_modules/stitchup/node_modules/stitch/node_modules/async/node_modules/uglify-js/bin/uglifyjs lib/async.js > dist/async.min.js
/bin/sh: /usr/local/lib/node_modules/stitchup/node_modules/stitch/node_modules/async/node_modules/uglify-js/bin/uglifyjs: No such file or directory
make: *** [build] Error 127
npm ERR! error installing [email protected]
npm ERR! error installing [email protected]
npm ERR! error installing [email protected]

npm ERR! [email protected] install: `make build`
npm ERR! `sh "-c" "make build"` failed with 2
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the async package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     make build
npm ERR! You can get their info via:
npm ERR!     npm owner ls async
npm ERR! There is likely additional logging output above.
npm ERR! 
npm ERR! System Darwin 12.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /usr/src/extras/stitchup
npm ERR! node -v v0.6.11
npm ERR! npm -v 1.1.2
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] install: `make build`
npm ERR! message `sh "-c" "make build"` failed with 2
npm ERR! errno {}
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     

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.