fix(chunksorter): webpack2 compatible (#569)
This commit is contained in:
parent
cbbb4a9aec
commit
9d7aa21377
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue