Giter Site home page Giter Site logo

sardines's Introduction

Sardines is no longer maintained. Use Webpack, or browserify instead.

What is it?

Combine all node.js scripts into one file. Run it as a single executable, or online.

Features

  • Combine all scripts into one (shrinkwrap method)
  • Asynchronously load all scripts (browserify method)
  • express middleware

JS Example

var sardines = require("sardines"),
fs = require("fs");

sardines.shrinkwrap({
	entry: __filename
}, function(err, content) {
	fs.writeFile(__dirname + "/shrinkwrapped.js", content);
});

Express example

var server = require("express").createServer();
server.use(require("sardines").middleware({
	directory: __dirname + "/public"
}));
server.listen(8080);

In your browser, load a script and append one of the following query arguments: shrinkwrap, browserify, or wrap.

Like so:

http://localhost:8080/js/app.js?browserify # asynchronously loads ALL scripts vs loading into one
http://localhost:8080/js/app.js?shrinkwrap # loads all scripts into one
http://localhost:8080/js/app.js?wrap # wraps the script in a function so it doesn't pollute the global namespace

Terminal Usage

Usage: sardines [include] -e [entry] -o [output] -p [port] -d -s

Options:
  -s, --server     run the http server             
  -d, --directory  public directory for http server  [default: cwd]
  -p, --port                                         [default: 8080]
  -m  --method                                       [default: "shrinkwrap"]

Terminal Examples

sardines -e app.js -o app.shrinkwrap.js -m shrinkwrap # shrinkwrap the app
sardines -s # start the server

sardines's People

Contributors

jedi4ever avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sardines's Issues

look for platform "main" scripts

for example, in package.json:

"webMain" : "./lib/web/index.js"

then provide a flag, such as: sardines -i script -o script -p web

console.log UTF-8 characters

I'm running Linux (Ubuntu 15.04) and nexe version 0.4.1.
When compiling and running this piece of code the utf8 characters are not printed to the terminal.

console.log('Some utf8 chars █ ◾ ▌');

Output:

Some utf8 char   

script.part.js

doesn't include all the dependencies for sardines - removes redundancy (see bean.js)

utf8 characters are converted during writing

It seems if your code contains unicodes , sardines will convert them due to writing them as a UTF-8 stream . for example:

'a': '\u2592', will be replaced by 'a': '▒'

This causes a problem with nexe as the node compilation process will complain about non-ansi characters in the *.js files and won't build.

does not keep track of variable scope

issue in this case:

var middleware = require('./middleware');

function()
{
var middleware = 'test';
console.log(middleware);// replaced with another variable
}

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.