Skip to content

Commit f671f77

Browse files
authored
fix(builder): check for custom components registered at build time (NativeScript#5834)
1 parent 1365f13 commit f671f77

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

tns-core-modules/ui/builder/builder.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ function loadCustomComponent(componentPath: string, componentName?: string, attr
169169

170170
let result: ComponentModule;
171171
componentPath = componentPath.replace("~/", "");
172-
const moduleName = componentPath + "/" + componentName;
172+
const moduleName = `${componentPath}/${componentName}`;
173+
const xmlModuleName = `${moduleName}.xml`;
173174

174175
let fullComponentPathFilePathWithoutExt = componentPath;
175176

@@ -178,8 +179,7 @@ function loadCustomComponent(componentPath: string, componentName?: string, attr
178179
}
179180

180181
const xmlFilePath = resolveFileName(fullComponentPathFilePathWithoutExt, "xml");
181-
182-
if (xmlFilePath) {
182+
if (xmlFilePath || global.moduleExists(xmlModuleName)) {
183183
// Custom components with XML
184184

185185
let subExports = context;
@@ -202,7 +202,9 @@ function loadCustomComponent(componentPath: string, componentName?: string, attr
202202

203203
subExports["_parentPage"] = parentPage;
204204

205-
result = loadInternal(xmlFilePath, subExports);
205+
result = xmlFilePath ?
206+
loadInternal(xmlFilePath, subExports) :
207+
loadInternal(xmlFilePath, subExports, moduleName);
206208

207209
// Attributes will be transfered to the custom component
208210
if (isDefined(result) && isDefined(result.component) && isDefined(attributes)) {

0 commit comments

Comments
 (0)