Skip to content

Commit

Permalink
fix(plugin): Remove unnecessary modules
Browse files Browse the repository at this point in the history
Reduces file size, and makes debugging easier.
  • Loading branch information
adam-26 committed Feb 20, 2018
1 parent f744c5d commit 91b31a4
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,25 @@ function buildManifest(compiler, compilation) {
let manifest = {};

compilation.chunks.forEach(chunk => {
chunk.files.forEach(file => {
chunk.forEachModule(module => {
let id = module.id;
let name = typeof module.libIdent === 'function' ? module.libIdent({ context }) : null;
let publicPath = url.resolve(compilation.outputOptions.publicPath || '', file);

let currentModule = module;
if (module.constructor.name === 'ConcatenatedModule') {
currentModule = module.rootModule;
}
if (!manifest[currentModule.rawRequest]) {
manifest[currentModule.rawRequest] = [];
}
if (chunk.name !== 'main') {
chunk.files.forEach(file => {
chunk.forEachModule(module => {
let id = module.id;
let name = typeof module.libIdent === 'function' ? module.libIdent({ context }) : null;
let publicPath = url.resolve(compilation.outputOptions.publicPath || '', file);

manifest[currentModule.rawRequest].push({ id, name, file, publicPath });
let currentModule = module;
if (module.constructor.name === 'ConcatenatedModule') {
currentModule = module.rootModule;
}
if (!manifest[currentModule.rawRequest]) {
manifest[currentModule.rawRequest] = [];
}

manifest[currentModule.rawRequest].push({ id, name, file, publicPath });
});
});
});
}
});

return manifest;
Expand Down

0 comments on commit 91b31a4

Please sign in to comment.