From d64827acc4a599cfcbaf9136ca6ba1835547d7f2 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 c8479d4..5b61037 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(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) {