Last active
December 4, 2018 22:19
-
-
Save kirmorozov/8a94f3afc33f693d133077ca3b028360 to your computer and use it in GitHub Desktop.
Collect Magento 2 JS dependencies as directed graph
This file contains 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
// Compatible with requirejs/alameda | |
let dependencies = Object.values(require.contexts._.deferreds).map((m) => { | |
if (m.hasOwnProperty('deps')) { | |
return m.deps.map((d) => { | |
return [m.map.id, d.id]; | |
}); | |
} else { | |
return []; | |
} | |
}).filter((x) => {return x.length > 0;} ); | |
let merged = [].concat.apply([], dependencies); | |
let modules = [].concat.apply([], merged).filter((v, i, a) => a.indexOf(v) === i); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment