Is this a good architecture to wrap all code in one big object?
Not really in this day and age. Of course this approach reduces your footprint on the global namespace to one single name, like app
. But the same can be accomplished more easily using ES6 modules. It's remarkably easy to shift over. You can continue to write
function Tools() { }
Tools.someFunction = function(arg1, arg2) {
// do something
};
as you were before, but add
export default Tools;
Then, where you want to use this
import Tools from 'tools';
Tools.somefunction();
how can I append that static class to this literal?
With ES6 modules you don't need to, but there are many patterns described in many questions here. Some examples:
IIFE:
var app = {
someController: function() {
var f = function() { };
f.someProp = 42;
return 42;
}(),
Initializer:
var app = {
someController: function() { },
init: function() {
this.someController.someProp = 42;
return this;
}
}.init();
Explicit assignment:
var app = {
someController: function() { }
};
app.someController.someProp = 42;
None of these are very fun to read or write. They have sort of a 2012-era feel about them. Use ES6 modules to avoid this and go back to writing regular old code.