fix(chunksorter): webpack2 compatible (#569)

This commit is contained in:
Peter Marton 2017-01-29 14:34:25 +01:00 committed by Jan Nicklas
parent cbbb4a9aec
commit 9d7aa21377
1 changed files with 3 additions and 1 deletions

View File

@ -1,6 +1,7 @@
'use strict';
var toposort = require('toposort');
var _ = require('lodash');
/*
Sorts dependencies between chunks by their "parents" attribute.
@ -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) {