mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Merge pull request #1684 from NativeScript/codefile
Loading of codeFile should not mask exceptions
This commit is contained in:
@ -79,11 +79,13 @@ export function getComponentModule(elementName: string, namespace: string, attri
|
|||||||
if (codeFilePath.indexOf("~/") === 0) {
|
if (codeFilePath.indexOf("~/") === 0) {
|
||||||
codeFilePath = path.join(knownFolders.currentApp().path, codeFilePath.replace("~/", ""));
|
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);
|
exports = global.loadModule(codeFilePath);
|
||||||
(<any>instance).exports = exports;
|
(<any>instance).exports = exports;
|
||||||
} catch (ex) {
|
} else {
|
||||||
throw new Error(`Code file with path "${codeFilePath}" cannot be found!`);
|
throw new Error(`Code file with path "${codeFilePathWithExt}" cannot be found!`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Code file atribute is valid only for pages!");
|
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;
|
return componentModule;
|
||||||
|
Reference in New Issue
Block a user