enhanced-require icon indicating copy to clipboard operation
enhanced-require copied to clipboard

Fix #6 Now you can also return value from define function like can be done with require.js

Open bitplanets opened this issue 10 years ago • 7 comments

For example

define(function(require, exports, module){

    var logic = {
        a: 3
    }
    return logic;
});

will now work.

But this will continue to work too

define(function(require, exports, module){

    var logic = {
        a: 3
    }
    exports.a= logic.a;
});

bitplanets avatar Dec 05 '14 10:12 bitplanets

@sokra Please merge this and add publish to npm. Thanks

bitplanets avatar Dec 05 '14 10:12 bitplanets

Doesn't it make more sense to check if the return value !== undefined instead of testing for an empty object.

Please write a test case.

sokra avatar Dec 05 '14 11:12 sokra

No because is easier for some function to return something by mistake, than set a property on exports variable. Ok, I will try to make a test (:

bitplanets avatar Dec 05 '14 13:12 bitplanets

@sokra Added the tests

bitplanets avatar Dec 05 '14 14:12 bitplanets

Could add a test that a empty module returns an empty object:

define(function(require, exports, module){
});

should be {}

sokra avatar Dec 05 '14 15:12 sokra

@sokra Added, also allows to return falsy values.

bitplanets avatar Dec 05 '14 16:12 bitplanets

Ok, I've made the changes.

bitplanets avatar Dec 15 '14 12:12 bitplanets