Skip to content

Commit

Permalink
Ensure dependencies of mainRows are added in deterministic order (#23)
Browse files Browse the repository at this point in the history
The `row.deps` object contains dependency IDs in the order that they were loaded in by module-deps. That's done concurrently so the order isn't always the same. This patch sorts the list of dependencies before adding them to the bundle.
  • Loading branch information
goto-bus-stop authored Dec 14, 2018
1 parent 1e980de commit 80a4e8b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"flush-write-stream": "^1.0.2",
"labeled-stream-splicer": "^2.0.0",
"object-delete-value": "^1.0.0",
"object-values": "^1.0.0",
"outpipe": "^1.1.1",
"resolve": "^1.5.0",
"run-parallel": "^1.1.6",
Expand Down
7 changes: 4 additions & 3 deletions plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ var splicer = require('labeled-stream-splicer')
var pack = require('browser-pack')
var runParallel = require('run-parallel')
var deleteValue = require('object-delete-value')
var values = require('object-values')
var isRequire = require('estree-is-require')
var outpipe = require('outpipe')
var dash = require('dash-ast')
Expand Down Expand Up @@ -309,10 +308,12 @@ function createSplitter (b, opts) {
}

function gatherDependencyIds (row, arr) {
var deps = values(row.deps)
var sortedDeps = Object.keys(row.deps).sort().map(function (key) {
return row.deps[key]
})
arr = arr || []

deps.forEach(function (id) {
sortedDeps.forEach(function (id) {
var dep = rowsById[id]
if (!dep || arr.indexOf(dep.id) !== -1) {
return
Expand Down

0 comments on commit 80a4e8b

Please sign in to comment.