fix(builder): check for custom components registered at build time (#5834)

This commit is contained in:
Stanimira Vlaeva
2018-05-19 11:41:36 +03:00
committed by GitHub
parent 1365f13594
commit f671f778f3

View File

@ -169,7 +169,8 @@ function loadCustomComponent(componentPath: string, componentName?: string, attr
let result: ComponentModule; let result: ComponentModule;
componentPath = componentPath.replace("~/", ""); componentPath = componentPath.replace("~/", "");
const moduleName = componentPath + "/" + componentName; const moduleName = `${componentPath}/${componentName}`;
const xmlModuleName = `${moduleName}.xml`;
let fullComponentPathFilePathWithoutExt = componentPath; let fullComponentPathFilePathWithoutExt = componentPath;
@ -178,8 +179,7 @@ function loadCustomComponent(componentPath: string, componentName?: string, attr
} }
const xmlFilePath = resolveFileName(fullComponentPathFilePathWithoutExt, "xml"); const xmlFilePath = resolveFileName(fullComponentPathFilePathWithoutExt, "xml");
if (xmlFilePath || global.moduleExists(xmlModuleName)) {
if (xmlFilePath) {
// Custom components with XML // Custom components with XML
let subExports = context; let subExports = context;
@ -202,7 +202,9 @@ function loadCustomComponent(componentPath: string, componentName?: string, attr
subExports["_parentPage"] = parentPage; subExports["_parentPage"] = parentPage;
result = loadInternal(xmlFilePath, subExports); result = xmlFilePath ?
loadInternal(xmlFilePath, subExports) :
loadInternal(xmlFilePath, subExports, moduleName);
// Attributes will be transfered to the custom component // Attributes will be transfered to the custom component
if (isDefined(result) && isDefined(result.component) && isDefined(attributes)) { if (isDefined(result) && isDefined(result.component) && isDefined(attributes)) {