Giter Site home page Giter Site logo

deps-sort's Introduction

deps-sort

sort module-deps output for deterministic browserify bundles

build status

example

command-line

$ for((i=0;i<5;i++)); do module-deps main.js | deps-sort | browser-pack | md5sum; done
e9e630de2c62953140357db0444c3c3a  -
e9e630de2c62953140357db0444c3c3a  -
e9e630de2c62953140357db0444c3c3a  -
e9e630de2c62953140357db0444c3c3a  -
e9e630de2c62953140357db0444c3c3a  -

or using browserify --deps on a voxeljs project:

$ for((i=0;i<5;i++)); do browserify --deps browser.js | deps-sort | browser-pack | md5sum; done
fb418c74b53ba2e4cef7d01808b848e6  -
fb418c74b53ba2e4cef7d01808b848e6  -
fb418c74b53ba2e4cef7d01808b848e6  -
fb418c74b53ba2e4cef7d01808b848e6  -
fb418c74b53ba2e4cef7d01808b848e6  -

api

To use this module programmatically, write streaming object data and read streaming object data:

var sort = require('../')();
var JSONStream = require('JSONStream');
var parse = JSONStream.parse([ true ]);
var stringify = JSONStream.stringify();

process.stdin.pipe(parse).pipe(sort).pipe(stringify).pipe(process.stdout);

methods

var depsSort = require('deps-sort');

var stream = depsSort(opts)

Return a new through stream that should get written module-deps objects and will output sorted objects.

opts can be:

  • opts.index - when true, for each module-deps row, insert row.index with the numeric index and row.indexDeps like row.deps but mapping require strings to row indices

  • opts.expose - array of names or object mapping names to true not to mangle with integer indexes when opts.index is turned on. If opts.expose maps names to strings, those strings will be used to resolve the indexed references.

  • opts.dedupe - set row.dedupe for files that match existing contents. Sets row.dedupeIndex when opts.index is enabled. When row.dedupe is set, row.sameDeps will be set to a boolean of whether the dependencies at the dedupe target match (true) or just the source content (false).

input objects

Input objects are file objects in the module-deps shape. They must at least have these properties:

  • row.id - a unique identifier for the file
  • row.source - the file contents
  • row.deps - dependencies for this file, mapping strings as used in require() to row IDs.

output objects

All the input properties, and:

  • row.index - when opts.index is true, the sorted numeric index of the row
  • row.indexDeps - like row.deps, but mapping to row.index instead of row.id
  • row.dedupe - when opts.dedupe is true, contains the row ID of a file with identical contents
  • row.dedupeIndex - like row.dedupe, but contains the row.index instead of row.id

install

With npm do:

npm install deps-sort

license

MIT

deps-sort's People

Contributors

boblauer avatar chadhietala avatar goto-bus-stop avatar mantoni avatar zertosh avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

deps-sort's Issues

JSONStream or jsonstream?

take a look at this beautiful error message when I run npm install browserify:

npm ERR! Darwin 14.3.0
npm ERR! argv "node" "/usr/local/bin/npm" "i" "browserify"
npm ERR! node v0.12.1
npm ERR! npm  v2.7.4
npm ERR! code ETARGET

npm ERR! notarget No compatible version found: JSONStream@'>=1.0.3 <2.0.0'
npm ERR! notarget Valid install targets:
npm ERR! notarget ["0.0.0","0.1.0","0.1.1","0.1.2","0.1.3","0.2.0","0.2.1","0.2.2","0.2.3","0.3.0","0.3.1","0.3.2","0.3.3","0.4.0","0.4.1","0.4.2","0.4.3","0.4.4","0.5.0","0.6.0","0.6.1","0.6.2","0.6.3","0.6.4","0.7.0","0.7.1","0.8.0","0.7.2","0.7.3","0.7.4","0.8.1","0.8.2","0.8.3","0.8.4","0.9.0","0.10.0"]
npm ERR! notarget 
npm ERR! notarget This is most likely not a problem with npm itself.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget 
npm ERR! notarget It was specified as a dependency of 'deps-sort'
npm ERR! notarget 

npm ERR! Please include the following file with any support request:
npm ERR!     /..../npm-debug.log

I get this running Mac OS X (which is case-insensitive).

I think NPM is confusing JSONSteam with jsonstream. Which, to be fair is a little confusing to myself :)

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.