in modularity/module-manager.js [42:79]
register(componentInfo) {
if (!utils.isObject(componentInfo)) {
throw new Error("componentInfo must be an object");
}
if (!utils.isString(componentInfo.name)) {
throw new Error("componentInfo.name must be supplied.");
}
if (!utils.isFunction(componentInfo.descriptor)) {
throw new Error("componentInfo.descriptor must be a function.");
}
if (!utils.isNullOrUndefined(componentInfo.deps)
&& !Array.isArray(componentInfo.deps)) {
throw new Error(`The deps of component "${componentInfo.name}" should be an array of string.`);
}
if (this.componentType && this.componentType !== componentInfo.type) {
return this;
}
if (Array.isArray(componentInfo.deps)) {
for (const depName of componentInfo.deps) {
if (!utils.isString(depName)) {
throw new Error(`The deps of component "${componentInfo.name}" should be an array of string.`);
}
}
}
if (componentInfo.name in this.components) {
throw new Error(`The component is already taken: ${componentInfo.name}`)
}
this.components[componentInfo.name] = componentInfo;
return this;
}