Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amd module with return doesn't get populated on node.js #6

Open
bitplanets opened this issue Dec 3, 2014 · 1 comment
Open

Amd module with return doesn't get populated on node.js #6

bitplanets opened this issue Dec 3, 2014 · 1 comment

Comments

@bitplanets
Copy link

A module like this will return {}

define(function(require, exports, module){

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

Here is the index.js

var myRequire2 = require('enhanced-require')(module);
console.log(myRequire2('./test'))

This will output {} instead of {logic: 3}. Why is this happening and how to fix it?

I can't change all the define(function(require, exports, module){ files to make them work with module.exports = logic. (The module.exports works ok)

On the client side with webpack works perfectly fine.

Thanks

@bitplanets
Copy link
Author

Here https://github.com/webpack/enhanced-require/blob/master/lib/RequireContext.js#L344 instead of:

fn(reqFn, parent.exports, parent);

should be

parent.exports = fn(reqFn, parent.exports, parent);

Or something more specific, like only replacing if no value is set in parent.exports.

bitplanets added a commit to bitplanets/enhanced-require that referenced this issue Dec 5, 2014
bitplanets added a commit to bitplanets/enhanced-require that referenced this issue Dec 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant