lib/WebModule.js
function(moduleName,      // @arg ModuleNameString
                      moduleClosure) { // @arg JavaScriptCodeString
                                       // @ret ModuleObject
        var wm = this; // GLOBAL.WebModule

        // https://github.com/uupaa/WebModule/wiki/SwitchModulePattern
        var alias = wm[moduleName] ? (moduleName + "_") : moduleName;

        if (!wm[alias]) { // secondary module already exported -> skip
            wm[alias] = moduleClosure(GLOBAL, wm, wm.VERIFY, wm.VERBOSE); // evaluate the module entity.
            wm.CODE[alias] = moduleClosure + ""; // store to the container.

            if (wm.PUBLISH && !GLOBAL[alias]) {
                GLOBAL[alias] = wm[alias]; // module publish to global namespace.
            }
        }
        return wm[alias];
    }
function(moduleName,      // @arg ModuleNameString
                      moduleClosure) { // @arg JavaScriptCodeString
                                       // @ret ModuleObject
        var wm = this; // GLOBAL.WebModule

        // https://github.com/uupaa/WebModule/wiki/SwitchModulePattern
        var alias = wm[moduleName] ? (moduleName + "_") : moduleName;

        if (!wm[alias]) { // secondary module already exported -> skip
            wm[alias] = moduleClosure(GLOBAL, wm, wm.VERIFY, wm.VERBOSE); // evaluate the module entity.
            wm.CODE[alias] = moduleClosure + ""; // store to the container.

            if (wm.PUBLISH && !GLOBAL[alias]) {
                GLOBAL[alias] = wm[alias]; // module publish to global namespace.
            }
        }
        return wm[alias];
    }
function ( moduleName , // @arg ModuleNameString moduleClosure ) { // @arg JavaScriptCodeString // @ret ModuleObject var wm = this ; // GLOBAL.WebModule // https://github.com/uupaa/WebModule/wiki/SwitchModulePattern var alias = wm [ moduleName ] ? ( moduleName + "_" ) : moduleName ; if ( ! wm [ alias ] ) { // secondary module already exported -> skip wm [ alias ] = moduleClosure ( GLOBAL , wm , wm . VERIFY , wm . VERBOSE ) ; // evaluate the module entity. wm . CODE [ alias ] = moduleClosure + "" ; // store to the container. if ( wm . PUBLISH && ! GLOBAL [ alias ] ) { GLOBAL [ alias ] = wm [ alias ] ; // module publish to global namespace. } } return wm [ alias ] ; }
publish flag, module publish to global namespace.
publish flag module publish to global namespace .