Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cc18f864ed | |||
| 4694aaadd1 | |||
| a838734f29 |
@@ -150,8 +150,11 @@ function Modular (options) {
|
|||||||
else if (modules.has(name)) {
|
else if (modules.has(name)) {
|
||||||
mod = modules.get(name);
|
mod = modules.get(name);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return require(name);
|
||||||
|
}
|
||||||
|
|
||||||
//If the module as been found
|
//If the module has been found
|
||||||
if (mod) {
|
if (mod) {
|
||||||
if (caller) {
|
if (caller) {
|
||||||
if (mod.childrenOf === undefined) {
|
if (mod.childrenOf === undefined) {
|
||||||
@@ -179,21 +182,22 @@ function Modular (options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loadModule (mod) {
|
function loadModule (mod) {
|
||||||
if (mod.module === undefined) {
|
if (mod.instance === undefined) {
|
||||||
mod.module = require(mod.fullPath);
|
mod.module = require(mod.fullPath);
|
||||||
}
|
|
||||||
|
|
||||||
if (mod.module instanceof Function) {
|
if (mod.module instanceof Function) {
|
||||||
let instanceModule = mod.module(get.bind(undefined,mod));
|
mod.instance = mod.module(get.bind(undefined,mod));
|
||||||
return instanceModule ? instanceModule : mod.module;
|
}
|
||||||
}
|
else if (mod.module.onLoad instanceof Function){
|
||||||
else if (mod.module.onLoad instanceof Function){
|
mod.module.onLoad(get.bind(undefined, mod));
|
||||||
let instanceModule = mod.module.onLoad(get.bind(undefined, mod));
|
mod.instance = mod.module;
|
||||||
return instanceModule ? instanceModule : mod.module;
|
}
|
||||||
}
|
else {
|
||||||
else {
|
mod.instance = mod.module;
|
||||||
return mod.module;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return mod.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -269,6 +273,7 @@ function Modular (options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
opts.module = undefined;
|
opts.module = undefined;
|
||||||
|
opts.instance = undefined;
|
||||||
|
|
||||||
//Clear the cache of the module if exists
|
//Clear the cache of the module if exists
|
||||||
if (require.cache[opts.fullPath]) {
|
if (require.cache[opts.fullPath]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user