default main/gapp as a dependency for all files forcing it to the top

This commit is contained in:
Stewart Allen 2021-12-29 16:31:17 -05:00
commit b5ad39ee08
7 changed files with 20 additions and 21 deletions

27
app.js
View file

@ -47,12 +47,12 @@ function init(mod) {
let depcache = {};
function find_deps(path, seen = []) {
function find_deps(path) {
let cached = depcache[path];
if (cached) {
return cached;
}
let deps = [];
let deps = [ "main/gapp" ];
let lines = fs.readFileSync(`${dir}/src/${path}.js`)
.toString()
.split('\n');
@ -60,21 +60,17 @@ function init(mod) {
let dpos = line.indexOf('// dep:');
if (dpos >= 0) {
let dep = line.substring(dpos+7).trim().replace('.','/');
if (seen.indexOf(dep) >= 0) {
dbug.warn(`circular ${dep} from ${path}`);
continue;
}
if (deps.indexOf(dep) < 0) {
deps.push(dep);
}
let deep = find_deps(dep, seen);
if (deep) {
// deeper dependencies go first
deps = [...deep, ...deps];
}
let deep = find_deps(dep);
deps = deps.filter(p => deep.indexOf(p) < 0);
// deeper dependencies go first
deps = [...deep, ...deps];
}
}
return deps.length ? deps : undefined;
depcache[path] = deps;
return deps;
}
// process script dependencies, expand paths
@ -94,7 +90,6 @@ function init(mod) {
let deps = find_deps(path);
if (deps) {
// remove deps already in list
// todo: promote filtered deps order in path array
deps = deps.filter(p => nval.indexOf(p) < 0);
let ppos = nval.indexOf(path);
if (ppos < 0) {
@ -479,18 +474,12 @@ const script = {
"main/meta",
],
mesh : [
"main/gapp",
"moto/license",
"&main/mesh"
],
mesh_work : [
"main/gapp",
"moto/license",
"&mesh/work"
],
mesh_pool : [
"main/gapp",
"moto/license",
"&mesh/pool"
]
};

View file

@ -4,6 +4,7 @@
(function() {
// dep: ext.three
gapp.register('add.three');
var MP = THREE.Mesh.prototype,

View file

@ -10,6 +10,10 @@ if (typeof(self) === 'undefined') {
(function () {
/** satisfy earcut, tween, etc **/
if (!self.module) self.module = { exports: {} };
/** debug and logging **/
let mark = Date.now();

View file

@ -99,10 +99,11 @@ document.onreadystatechange = function() {
// finalize modules
gapp.finalize("main.mesh", [
"moto.license", // dep: moto.license
"moto.webui", // dep: moto.webui
"moto.client", // dep: moto.client
"moto.broker", // dep: moto.broker
"moto.space" // dep: moto.space
"moto.space", // dep: moto.space
]);
})();

View file

@ -5,6 +5,7 @@
(function() {
gapp.finalize("mesh.pool", [
"moto.license", // dep: moto.license
"moto.worker" // dep: moto.worker
]);

View file

@ -10,6 +10,7 @@
// dep: ext.three
// dep: ext.three-bgu
gapp.finalize("mesh.work", [
"moto.license", // dep: moto.license
"moto.client" // dep: moto.client
]);

View file

@ -16,8 +16,10 @@
app.license = terms.LICENSE;
app.version = terms.VERSION;
app.copyright = terms.COPYRIGHT;
// satisfy resolver
gapp.register('moto.license');
// for earcut and other modules
self.module = { exports: terms };
(self.module = self.module || {}).exports = terms;
}
})();