Skip to content

Commit

Permalink
fix(chunksorter): webpack2 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Marton committed Jan 29, 2017
1 parent 41dce56 commit bcd9fba
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/chunksorter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

var toposort = require('toposort');
var _ = require('lodash')

/*
Sorts dependencies between chunks by their "parents" attribute.
Expand Down Expand Up @@ -40,7 +41,8 @@ module.exports.dependency = function (chunks) {
if (chunk.parents) {
// Add an edge for each parent (parent -> child)
chunk.parents.forEach(function (parentId) {
var parentChunk = nodeMap[parentId];
// webpack2 chunk.parents are chunks instead of string id(s)
var parentChunk = _.isObject(parentId) ? parentId : nodeMap[parentId];
// If the parent chunk does not exist (e.g. because of an excluded chunk)
// we ignore that parent
if (parentChunk) {
Expand Down

0 comments on commit bcd9fba

Please sign in to comment.