From 9d7aa213771555f03a404a13b409ede9f12d6f11 Mon Sep 17 00:00:00 2001 From: Peter Marton Date: Sun, 29 Jan 2017 14:34:25 +0100 Subject: [PATCH] fix(chunksorter): webpack2 compatible (#569) --- lib/chunksorter.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/chunksorter.js b/lib/chunksorter.js index 8c5faf1..584e01c 100644 --- a/lib/chunksorter.js +++ b/lib/chunksorter.js @@ -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) {