Comparing version 1.1.0 to 1.1.1
@@ -29,14 +29,25 @@ var inherits = require( 'inherits' ); | ||
Parcel.prototype.calcSortedDependencies = function() { | ||
var visited = []; | ||
var packagesWithDependencies = []; | ||
function getEdgesForPackageDependencyGraph( thisPackage ) { | ||
visited.push( thisPackage ); | ||
function getEdgesForPackageDependencyGraph( thisPackage, thisTreeLevel, packageTreeLevels ) { | ||
if( _.isUndefined( thisTreeLevel ) ) thisTreeLevel = 0; | ||
if( _.isUndefined( packageTreeLevels ) ) packageTreeLevels = {}; | ||
if( ! packageTreeLevels[ thisPackage.path ] ) packageTreeLevels[ thisPackage.path ] = thisTreeLevel; | ||
return thisPackage.dependencies.reduce( function( memo, thisDependentPackage ) { | ||
if( _.contains( visited, thisDependentPackage ) ) return memo; // avoid cycles | ||
// these conditionals are to avoid cycles and infinite recursion. | ||
// first, we only traverse each node once to avoid infinite recursion. | ||
if( _.isUndefined( packageTreeLevels[ thisDependentPackage.path ] ) ) { | ||
memo = memo.concat( getEdgesForPackageDependencyGraph( thisDependentPackage, thisTreeLevel + 1, packageTreeLevels ) ); | ||
} | ||
var edges = memo.concat( [ [ thisPackage, thisDependentPackage ] ] ); | ||
edges = edges.concat( getEdgesForPackageDependencyGraph( thisDependentPackage ) ); | ||
// second, we keep track of the levels of the nodes in the dependency tree (where | ||
// level 0 is the root node i.e. the parcel itself). nodes can only have dependencies | ||
// on other nodes with a level equal to or greater than their own. done. | ||
if( packageTreeLevels[ thisDependentPackage.path ] >= packageTreeLevels[ thisPackage.path ] ) { | ||
memo = memo.concat( [ [ thisPackage, thisDependentPackage ] ] ); | ||
} | ||
return edges; | ||
return memo; | ||
}, [] ); | ||
@@ -43,0 +54,0 @@ } |
{ | ||
"name": "parcelify", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Create css bundles from npm packages using the browserify dependency graph.", | ||
@@ -19,3 +19,3 @@ "main": "index.js", | ||
"resolve": "~0.6.1", | ||
"shasum": "~1.0.0", | ||
"shasum": "~1.0.1", | ||
"stream-combiner": "0.0.4", | ||
@@ -22,0 +22,0 @@ "through2": "~0.6.3", |
@@ -67,2 +67,3 @@ # Parcelify | ||
``` | ||
--cssBundle, -o Path of the destination css bundle. | ||
@@ -77,2 +78,3 @@ | ||
--loglevel -l Set the verbosity of npmlog, eg. "silent", "error", "warn", "info", "verbose" | ||
``` | ||
@@ -79,0 +81,0 @@ ## Transforms |
@@ -190,2 +190,34 @@ var test = require('tape'); | ||
} ); | ||
} ); | ||
// ordering | ||
test( 'page7', function( t ) { | ||
t.plan( 2 ); | ||
var mainPath = __dirname + '/page7/main.js'; | ||
var dstDir = path.resolve( tmpdir, 'parcelify-test-' + Math.random() ); | ||
var options = { | ||
bundles : { | ||
style : path.join( dstDir, 'bundle.css' ) | ||
} | ||
}; | ||
mkdirp.sync( dstDir ); | ||
var b = browserify( mainPath ); | ||
var p = parcelify( b, options ); | ||
b.bundle(); | ||
p.on( 'done', function() { | ||
t.deepEqual( | ||
fs.readdirSync( dstDir ).sort(), | ||
[ 'bundle.css' ] | ||
); | ||
t.deepEqual( fs.readFileSync( options.bundles.style, 'utf8' ), 'p {\n\tcolor: red;\n}p.header {\n\tcolor: blue;\n}p.footer {\n\tcolor: green;\n}div.beep {\n\tcolor : green;\n}' ); | ||
} ); | ||
} ); |
61671
43
891
185
Updatedshasum@~1.0.1