From 4987856a46fc348118313d4d74822bfb2695cdc3 Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Thu, 3 Mar 2011 14:14:10 -0500 Subject: [PATCH] Combine process now wraps using module rather than only exports - This will allow us to overwrite the 'exports' object --- tools/combine | 5 +++-- tools/combine-test.tpl | 8 ++++---- tools/combine.tpl | 12 ++++++------ 3 files changed, 13 insertions(+), 12 deletions(-) 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 );