loadable-components/src/componentTracker.js
Greg Bergé 10318b042e fix: fix module resolving
This issue fixes #59

It is possible to create a configuration which will result into a wrong state but it should not happen in 99.99% cases.
2018-05-12 16:09:44 +02:00

18 lines
396 B
JavaScript

let components = {}
export const track = (component, modules, index = 0) => {
let id = modules.join('-')
if (index) id += `-${index}`
if (components[id]) {
return track(component, modules, index + 1)
}
components[id] = component
return id
}
export const get = id => components[id]
export const getAll = () => ({ ...components })
export const reset = () => {
components = {}
}