@polylith/builder 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/App.js +27 -0
- package/ConfigApp.js +8 -0
- package/package.json +1 -1
package/App.js
CHANGED
|
@@ -38,6 +38,7 @@ export default class App {
|
|
|
38
38
|
constructor(name, root, index, dest) {
|
|
39
39
|
root = forceToPosix(root);
|
|
40
40
|
this.root = root;
|
|
41
|
+
this.routerRoot = name;
|
|
41
42
|
|
|
42
43
|
var filename = path.posix.join(root, index);
|
|
43
44
|
this.sourcePath = path.posix.dirname(filename);
|
|
@@ -75,6 +76,32 @@ export default class App {
|
|
|
75
76
|
this.ns = ns;
|
|
76
77
|
}
|
|
77
78
|
|
|
79
|
+
getRouterRoot() {
|
|
80
|
+
return routerRoot;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
setRouterRoot(root) {
|
|
84
|
+
this.routerRoot = root;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
setRouterModule(modulePath) {
|
|
88
|
+
this.modulePath = path.join(this.root, modulePath);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async router(appRouter) {
|
|
92
|
+
if (!this.modulePath) return;
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
let module = await import(this.modulePath)
|
|
96
|
+
let router = module.default;
|
|
97
|
+
await router(appRouter);
|
|
98
|
+
return true;
|
|
99
|
+
} catch(e) {
|
|
100
|
+
console.error('error while building router', this.modulePath);
|
|
101
|
+
console.log(e);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
78
105
|
/**
|
|
79
106
|
* Call this method to add a code variable to the output html file. This
|
|
80
107
|
* variable will be added the namsespace for the app.
|
package/ConfigApp.js
CHANGED
|
@@ -43,5 +43,13 @@ export default class ConfigApp extends App {
|
|
|
43
43
|
this.addCodeVariable(name, config.variables[name]);
|
|
44
44
|
}, this)
|
|
45
45
|
}
|
|
46
|
+
|
|
47
|
+
if (config.routerRoot) {
|
|
48
|
+
this.setRouterRoot(config.routerRoot);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (config.router) {
|
|
52
|
+
this.setRouterModule(config.router);
|
|
53
|
+
}
|
|
46
54
|
}
|
|
47
55
|
}
|