Skip to content

Conversation

@jjoos
Copy link

@jjoos jjoos commented Dec 8, 2015

Saw you reverted the module.exports, agree that that was probably the best to do, since it didn't support all use cases.

This pull request adds an umd wrapper, that should work with bower/amd/commonjs, more information in http://bob.yexley.net/umd-javascript-that-runs-anywhere/ .

I also added a standardized way to create the minified file, since it wasn't documented how to generate that file.

Github doesn't handle whitespace changes very smartly, so this is the actual diff to the radar-chart.js file, reproducible with this command: git diff --ignore-all-space dc53d2cb1682c37a35c6751a6363c08d244b4148

diff --git a/src/radar-chart.js b/src/radar-chart.js
index 33c71e7..f8291ee 100644
--- a/src/radar-chart.js
+++ b/src/radar-chart.js
@@ -1,3 +1,12 @@
+(function (root, factory) {
+    if (typeof define === "function" && define.amd) {
+        define(["d3"], factory);
+    } else if (typeof exports === "object") {
+        module.exports = factory(require("d3"));
+    } else {
+        root.RadarChart = factory(root.d3);
+    }
+}(this, function (d3) {
   var RadarChart = {
     defaultConfig: {
       containerClass: 'radar-chart',
@@ -372,3 +381,6 @@ var RadarChart = {
         .call(chart);
     }
   };
+
+  return RadarChart;
+}));

Minifying now works by running npm install && npm run minify.

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