New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added capability to wrap d3 as an AMD module. #745
Conversation
To generate a wrapped d3, do: $ make MODULE_TYPE=amd The wrapped d3 will be found in d3-amd.v2.js and d3-amd.v2.min.js.
Should this go into the 2.9.8 branch instead? |
Thank you for this improvement. I hope to find it in main d3.js distro soon. |
Any update on this? |
+1 on having d3 utilize the amdWeb pattern in the default build. I'd go further and suggest that d3 itself might benefit from a transition to AMD modules internally (with r.js or similar to build the output file). |
Check the component user @ github: https://github.com/component Plus, after loading all your components, creating a single minified file becomes simple to do. Brandon Myers On Monday, January 28, 2013 at 12:45 PM, S. Andrew Sheppard wrote:
|
Thanks for the link, though it appears that the referenced components (including the D3 component) are based on CommonJS rather than AMD. As I understand it, a key benefit of AMD over CommonJS is the ability to use & debug individual module files directly within the browser before building the singled minified file for deployment. |
I believe that this system supports just that. The minified version is the additional benefit (with all dependencies) that this system provides. Brandon Myers On Monday, January 28, 2013 at 2:20 PM, S. Andrew Sheppard wrote:
|
To clarify - given its dependency on the CommonJS module syntax, it seems unlikely that Component can automatically load source modules directly into the browser as-is, a key feature of AMD. AMD was created specifically to address the lack of asynchronous module loading in CommonJS, and thus requires a different module definition syntax (see http://requirejs.org/docs/whyamd.html for more information). More to the point, since the AMD module format is not directly compatible with CommonJS, Component is not a useful option for those of us who are already using AMD. FWIW, a number of libraries (jQuery Mobile and Dojo being two prominent examples) have already or are in the process of migrating to AMD. In order to use d3 in their projects, AMD developers have three main options:
The amdWeb pattern provides a nice compromise between AMD and the traditional "browser global" approach. The nice thing is that it should not break any existing functionality. @gregsymons and others, would you be interested in updating this pull request (or creating a new one) with an amdWeb-based solution? |
This is fixed in 3.4 |
Yep, fixed. |
To generate a wrapped d3, do:
The wrapped d3 will be found in d3-amd.v2.js and d3-amd.v2.min.js.