factor-bundle
Advanced tools
Comparing version 2.2.3 to 2.2.4
var browserify = require('browserify'); | ||
var fs = require('fs'); | ||
var files = [ __dirname + '/files/x.js', __dirname + '/files/y.js' ]; | ||
var files = [ './files/x.js', './files/y.js' ]; | ||
var b = browserify(files); | ||
b.plugin('../', { o: [ 'bundle/x.js', 'bundle/y.js' ] }); | ||
b.bundle().pipe(fs.createWriteStream('bundle/common.js')); |
@@ -31,2 +31,3 @@ var Transform = require('stream').Transform; | ||
var cwd = defined(opts.basedir, b._options.basedir, process.cwd()); | ||
b.pipeline.get('record').push(through.obj(function(row, enc, next) { | ||
@@ -38,3 +39,2 @@ if (needRecords) { | ||
}, function(next) { | ||
var cwd = defined(opts.basedir, b._options.basedir, process.cwd()); | ||
var fileMap = files.reduce(function (acc, x, ix) { | ||
@@ -67,3 +67,3 @@ acc[path.resolve(cwd, x)] = opts.o[ix]; | ||
b.pipeline.get('label').push(through.obj(function(row, enc, next) { | ||
opts.rmap[row.id] = row.file; | ||
opts.rmap[row.id] = path.resolve(cwd, row.file); | ||
next(null, row); | ||
@@ -70,0 +70,0 @@ })); |
{ | ||
"name": "factor-bundle", | ||
"version": "2.2.3", | ||
"version": "2.2.4", | ||
"description": "factor browser-pack bundles into common shared bundles", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -99,3 +99,3 @@ var test = require('tape'); | ||
common: [], | ||
't.js': [ | ||
't.js': sortRows([ | ||
read('t.js', { | ||
@@ -109,3 +109,3 @@ entry: true, | ||
read('a.js') | ||
] | ||
]) | ||
}; | ||
@@ -165,3 +165,3 @@ | ||
], | ||
't.js': [ | ||
't.js': sortRows([ | ||
read('t.js', { | ||
@@ -175,4 +175,4 @@ entry: true, | ||
read('a.js') | ||
], | ||
'y.js': [ | ||
]), | ||
'y.js': sortRows([ | ||
read('y.js', { | ||
@@ -183,3 +183,3 @@ entry: true, | ||
read('a.js') | ||
] | ||
]) | ||
}; | ||
@@ -321,5 +321,11 @@ | ||
function write (row) { rows.push(row) } | ||
function end () { cb(rows) } | ||
function end () { cb(sortRows(rows)) } | ||
} | ||
function sortRows (rows) { | ||
return rows.sort(function (a, b) { | ||
return a.id < b.id ? 1 : -1; | ||
}); | ||
} | ||
function read (name, ref) { | ||
@@ -326,0 +332,0 @@ if (!ref) ref = {}; |
Sorry, the diff of this file is not supported yet
36447
40
915
15