diff --git a/tools/combine b/tools/combine index a48949e..49c756d 100755 --- a/tools/combine +++ b/tools/combine @@ -84,13 +84,14 @@ for module in $CAT_MODULES; do # each module must be enclosed in a closure to emulate a module echo "/** $module **/" - echo "( function( exports )" + echo "( function( module )" echo "{" + echo " var exports = module.exports = {};" # add the module, removing trailing commas cat $filename | $RMTRAIL - echo "} )( exports['$module'] = {} );" + echo "} )( module['$module'] = {} );" done # include tests? diff --git a/tools/combine-test.tpl b/tools/combine-test.tpl index b49c9c3..561c8be 100644 --- a/tools/combine-test.tpl +++ b/tools/combine-test.tpl @@ -18,12 +18,12 @@ # along with this program. If not, see . # # -exports.common = { +module.common = { exports: { require: function ( id ) { return require( id ); } -}; +} }; function failAssertion( err ) @@ -37,7 +37,7 @@ function failAssertion( err ) * * This contains only the used assertions */ -exports.assert = { +module.assert = { exports: { equal: function ( val, cmp, err ) { if ( val !== cmp ) @@ -101,5 +101,5 @@ exports.assert = { } } }, -}; +} }; diff --git a/tools/combine.tpl b/tools/combine.tpl index 95c57ac..d664266 100644 --- a/tools/combine.tpl +++ b/tools/combine.tpl @@ -51,7 +51,7 @@ var easejs = {}; * * @type {Object.} */ - var exports = {}; + var module = {}; /** * Returns the requested module @@ -71,19 +71,19 @@ var easejs = {}; var id_clean = module_id.replace( /^.\//, '' ); // attempt to retrieve the module - var module = exports[ id_clean ]; - if ( module === undefined ) + var mod = module[ id_clean ]; + if ( mod === undefined ) { throw "[ease.js] Undefined module: " + module_id; } - return module; + return mod.exports; }; /**{CONTENT}**/ // the following should match the exports of /index.js - ns_exports.Class = exports['class']; - ns_exports.Interface = exports['interface']; + ns_exports.Class = module['class'].exports; + ns_exports.Interface = module['interface'].exports; } )( easejs );