Skip to content

Instantly share code, notes, and snippets.

@adamisntdead
Created July 17, 2018 23:10
Show Gist options
  • Save adamisntdead/74f432b3a8eacf5c68c3eda86d6c0651 to your computer and use it in GitHub Desktop.
Save adamisntdead/74f432b3a8eacf5c68c3eda86d6c0651 to your computer and use it in GitHub Desktop.
function getModules(entry) {
const rootModule = createModuleObject(entry)
const modules = [rootModule]
// Iterate over the modules, even when new
// ones are being added
for (const module of modules) {
module.map = {} // Where we will keep the module maps
module.requires.forEach(dependency => {
const basedir = path.dirname(module.filepath)
const dependencyPath = resolve(dependency, { basedir })
const dependencyObject = createModuleObject(dependencyPath)
module.map[dependency] = dependencyObject.id
modules.push(dependencyObject)
})
}
return modules
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment