timdream / wordcloud2.js

Tag cloud/Wordle presentation on 2D canvas or HTML
https://wordcloud2-js.timdream.org/
MIT License
2.36k stars 511 forks source link

Expose WordCloud on the global object to prevent errors with RequireJS #74

Closed stefan-it closed 8 years ago

stefan-it commented 8 years ago

Hi,

this PR exposes WordCloud on the global object to get this awesome library working with the (latest) RequireJS version.

It simply exposes WordCloud before the define('wordcloud', [], function() { return WordCloud; }); call.

Notice: As it uses a named AMD module called wordcloud the RequireJS configuration should look like:

requirejs.config({
  baseUrl: 'bower_components',
  paths: {
    "wordcloud"            : "wordcloud2.js/src/wordcloud2",
  }
});

Then the WordCloud module is available. I did testings with:

and wordcloud2 in version 1.0.5 and master, Final output of grunt test is:

Took 2102ms to run 23 tests. 23 passed, 0 failed.

Done, without errors.

What do you think about merging this PR?

timdream commented 8 years ago

I've never used RequireJS with this library actually so if this works I am fine with merging it. Thanks for the PR!