@@ -81,17 +81,13 @@ const loadModule = profile("loadModule", (moduleNamePath: string, entry: ViewEnt
8181const viewFromBuilder = profile ( "viewFromBuilder" , ( moduleNamePath : string , moduleExports : any ) : View => {
8282 // Possible XML file path.
8383 const fileName = resolveFileName ( moduleNamePath , "xml" ) ;
84- if ( fileName ) {
85- // Or check if the file exists in the app modules and load the page from XML.
86- return loadPage ( moduleNamePath , fileName , moduleExports ) ;
87- }
8884
8985 // Attempts to implement https://github.com/NativeScript/NativeScript/issues/1311
9086 // if (page && fileName === `${moduleNamePath}.port.xml` || fileName === `${moduleNamePath}.land.xml`){
9187 // page["isBiOrientational"] = true;
92- // }
88+ // };
9389
94- return null ;
90+ return loadPage ( moduleNamePath , fileName , moduleExports ) ;
9591} )
9692
9793export const createViewFromEntry = profile ( "createViewFromEntry" , ( entry : ViewEntry ) : View => {
@@ -143,8 +139,13 @@ const moduleCreateView = profile("module.createView", (moduleNamePath: string, m
143139function loadInternal ( fileName : string , context ?: any , moduleNamePath ?: string ) : ComponentModule {
144140 let componentModule : ComponentModule ;
145141
146- // Check if the XML file exists.
147- if ( File . exists ( fileName ) ) {
142+ const appPath = knownFolders . currentApp ( ) . path ;
143+ const filePathRelativeToApp = ( moduleNamePath && moduleNamePath . startsWith ( appPath ) ? "./" + moduleNamePath . substr ( appPath . length + 1 ) : moduleNamePath ) + ".xml" ;
144+
145+ if ( global . moduleExists ( filePathRelativeToApp ) ) {
146+ var text = global . loadModule ( filePathRelativeToApp ) ;
147+ componentModule = parseInternal ( text , context , fileName , moduleNamePath ) ;
148+ } else if ( fileName && File . exists ( fileName ) ) {
148149 const file = File . fromPath ( fileName ) ;
149150 const text = file . readTextSync ( ( error ) => { throw new Error ( "Error loading file " + fileName + " :" + error . message ) } ) ;
150151 componentModule = parseInternal ( text , context , fileName , moduleNamePath ) ;
0 commit comments