Skip to content

Add support for modules that redefine module.exports - #8

Open
danieldickison wants to merge 3 commits into
jbrantly:masterfrom
CarnegieLearning:master
Open

Add support for modules that redefine module.exports#8
danieldickison wants to merge 3 commits into
jbrantly:masterfrom
CarnegieLearning:master

Conversation

@danieldickison

Copy link
Copy Markdown

Add support for modules that redefine module.exports which is common with node libraries.
For example, if the module does:

module.exports = function () {...}

Then the client code can do:

require('foo')(args)

For example, here's a UUID library that uses this idiom: https://github.com/broofa/node-uuid

I believe pull request 6 is trying to achieve the same effect, but it breaks compatibility with CommonJS Modules/1.1 as the module object doesn't have the url or id properties.

This patch maintains compatibility with Modules/1.1, although it still breaks the requirement that "modules must use the "exports" object as the only means of exporting." (emphasis added).

danieldickison and others added 3 commits August 24, 2011 14:04
…with node libraries.

For example, if the module does:
    module.exports = function () {...}
Then the client code can do:
    require('foo')(args)
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

Successfully merging this pull request may close these issues.

1 participant