FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(builder): enable reading xml from bundle (#5668) · NativeScript/NativeScript@1e682bf · GitHub

Commit 1e682bf

Browse files
authored andcommitted
feat(builder): enable reading xml from bundle (#5668)
1 parent f1c0b85 commit 1e682bf

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,13 @@ const loadModule = profile("loadModule", (moduleNamePath: string, entry: ViewEnt
8181
const 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

9793
export const createViewFromEntry = profile("createViewFromEntry", (entry: ViewEntry): View => {
@@ -143,8 +139,13 @@ const moduleCreateView = profile("module.createView", (moduleNamePath: string, m
143139
function 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

Comments
 (0)

Back | FazBrowse Home | New Git URL