I have a bunch of modules in my application, which is relative to me regarding the current script. The problem with this is, if I want to restructure my application, then I need to change tons of statements require.
So, I started using something like this:
"use strict";
exports.Logger = require('./core/logger');
exports.Module = require('./core/module');
And in my files I use requirelike this:
"use strict";
var Loader = require('../../loader');
var Logger = Loader.Logger;
var logger = new Logger();
So now, if I want to restructure common codes in my application, I have to change the request only in the file loader.js. This is a good decision? What are you using?
Is there a way to make it requirefully automatic if the name of the unique module is unique?
source
share