diff --git a/ui/builder/component-builder.ts b/ui/builder/component-builder.ts index 9c2f32bfb..6ffdb2771 100644 --- a/ui/builder/component-builder.ts +++ b/ui/builder/component-builder.ts @@ -79,11 +79,13 @@ export function getComponentModule(elementName: string, namespace: string, attri if (codeFilePath.indexOf("~/") === 0) { codeFilePath = path.join(knownFolders.currentApp().path, codeFilePath.replace("~/", "")); } - try { + + let codeFilePathWithExt = codeFilePath.indexOf(".js") !== -1 ? codeFilePath : `${codeFilePath}.js`; + if (File.exists(codeFilePathWithExt)) { exports = global.loadModule(codeFilePath); (instance).exports = exports; - } catch (ex) { - throw new Error(`Code file with path "${codeFilePath}" cannot be found!`); + } else { + throw new Error(`Code file with path "${codeFilePathWithExt}" cannot be found!`); } } else { throw new Error("Code file atribute is valid only for pages!"); @@ -145,7 +147,7 @@ export function getComponentModule(elementName: string, namespace: string, attri } } - componentModule = {component: instance, exports: instanceModule}; + componentModule = { component: instance, exports: instanceModule }; } return componentModule;