Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add support for modules that redefine module.exports #8

Open
wants to merge 3 commits into from

1 participant

Daniel Dickison
Daniel Dickison

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 some commits
Daniel Dickison danieldickison 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)
612fcd5
Daniel Dickison danieldickison Bump version to 0.3.1 to distinguish from the npm-published version. 5dfe092
John Conomikes Fixed eval depreciation 12791ef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 24, 2011
  1. Daniel Dickison

    Add support for modules that redefine module.exports which is common …

    danieldickison authored
    …with node libraries.
    
    For example, if the module does:
        module.exports = function () {...}
    Then the client code can do:
        require('foo')(args)
Commits on Sep 7, 2011
  1. Daniel Dickison
Commits on Oct 14, 2011
  1. Fixed eval depreciation

    John Conomikes authored
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 3 deletions.
  1. +2 −2 lib/yabble.js
  2. +1 −1  package.json
4 lib/yabble.js
View
@@ -213,7 +213,7 @@
module.factory.apply(null, args);
}
- return module.exports;
+ return module.module.exports || module.exports;
};
require.ensure = function(deps, cb) {
@@ -562,5 +562,5 @@
// Export to the require global
window.require = Yabble;
})(function(code) {
- return (window.eval || eval)(code, null);
+ return (window.eval || eval)(code);
});
2  package.json
View
@@ -1,7 +1,7 @@
{
"name": "yabble",
"description": "A general purpose browser-side CommonJS module loader",
- "version": "0.3.0",
+ "version": "0.3.1",
"keywords": [
"loader",
"browser"
Something went wrong with that request. Please try again.