Created
July 20, 2016 23:23
-
-
Save AndrewRayCode/cee708b05bfd88b7d966a6e73d949a9a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Loop over every module, which looks like | |
// { | |
// id: 1, reasons: [{ moduleId: 3 }] | |
// id: 2, reasons: [{ moduleId: 3 }] | |
// id: 3, reasons: [] | |
// } | |
// and invert it to | |
// { | |
// 3: { dependencies: [ 1, 2 ] } | |
// } | |
const fileDependencies = stats.modules.reduce( ( memo, modjule ) => { | |
return modjule.reasons.reduce( ( memo, reason ) => { | |
const existing = memo[ reason.moduleId ] || []; | |
const newAssign = {}; | |
newAssign[ reason.moduleId ] = existing.concat( modjule.id ); | |
return Object.assign( {}, memo, newAssign ); | |
}, memo ); | |
}, {} ); |
forestbelton
commented
Jul 21, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment