Skip to content

Commit

Permalink
Improve code of getExternalModules function
Browse files Browse the repository at this point in the history
  • Loading branch information
emilien.escalle committed Apr 23, 2019
1 parent 29f4fc4 commit a6d536c
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions lib/packExternalModules.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,28 +153,26 @@ function findExternalOrigin(issuer) {
}

function getExternalModules(stats) {
if (stats.compilation.chunks) {
const externals = new Set();
for (const chunk of stats.compilation.chunks) {
if (!chunk.modulesIterable) {
continue;
}
if (!stats.compilation.chunks) {
return [];
}
const externals = new Set();
for (const chunk of stats.compilation.chunks) {
if (!chunk.modulesIterable) {
continue;
}

// Explore each module within the chunk (built inputs):
for (const module of chunk.modulesIterable) {
if (isExternalModule(module)) {
externals.add({
origin: _.get(findExternalOrigin(module.issuer), 'rawRequest'),
external: getExternalModuleName(module)
});
}
// Explore each module within the chunk (built inputs):
for (const module of chunk.modulesIterable) {
if (isExternalModule(module)) {
externals.add({
origin: _.get(findExternalOrigin(module.issuer), 'rawRequest'),
external: getExternalModuleName(module)
});
}
}

return Array.from(externals);
}

return [];
return Array.from(externals);
}

module.exports = {
Expand Down

0 comments on commit a6d536c

Please sign in to comment.