Skip to content

Commit

Permalink
Fix module registration under browserify
Browse files Browse the repository at this point in the history
for reference: 850b897, 113bf9

When bundled with browserify, module was going down the "browser
global" path, not the "commonjs" path.  The reason was that it was
looking for module as "global.module", but browserify supplies it as an
argument, not a global.  History digging shows that "global." was added
to silence jshint warnings, so I adjusted the environment detection not
to use "global.", and adjusted the jshint rules to prevent it from
complaining about those lines.
  • Loading branch information
SeanMcMillan committed Apr 14, 2016
1 parent 9f8e874 commit f03a94b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@
"nonstandard": true,
"worker": true,

"-W078": true
"-W078": true,
"predef": ["define", "module"]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wordcloud",
"version": "1.0.3",
"version": "1.0.4",
"description": "Tag cloud/Wordle presentation on 2D canvas or HTML",
"homepage": "http://timdream.org/wordcloud2.js/",
"author": {
Expand Down
10 changes: 5 additions & 5 deletions src/wordcloud2.js
Original file line number Diff line number Diff line change
Expand Up @@ -1136,12 +1136,12 @@ if (!window.clearImmediate) {
WordCloud.minFontSize = minFontSize;

// Expose the library as an AMD module
if (typeof global.define === 'function' && global.define.amd) {
global.define('wordcloud', [], function() { return WordCloud; });
} else if (typeof global.module !== 'undefined' && global.module.exports) {
global.module.exports = WordCloud;
if (typeof define === 'function' && define.amd) {
define('wordcloud', [], function() { return WordCloud; });
} else if (typeof module !== 'undefined' && module.exports) {
module.exports = WordCloud;
} else {
global.WordCloud = WordCloud;
}

})(window);
})(this); //jshint ignore:line

0 comments on commit f03a94b

Please sign in to comment.