d3.js - NVD3 + D3 + Require Optimizer: Any Clean Solution? -
i'm trying use 2 libraries:
- d3 (a javascript graphics library)
- nvd3 (a graph-specific d3 extension)
i'm trying use require optimizer, , that's things rough. d3 amd-compliant, if detects you're using require define module , not export global d3 variable. nvd3 has no amd support, require has "shims" case.
however, if "shim" nvd3 , give shim dependency of d3, doesn't work, because nvd3 expects there global d3 variable, d3 won't make in require environment. so, around issue made new module (d3shim), requires d3, registers global variable:
define(['d3'], function(d3) { return window.d3 = d3; }); i made nvd3 depend on d3shim, , worked ... in normal require-land. when tried use require-optimizer merge in single file found nvd3 started breaking again, because of lack of d3 variable.
it turns out optimizer shims:
*shimmed code here* define(*shim path*, [], function(){}); so, doesn't matter dependencies have, nvd3 code run before d3shim module can magic.
my question is, there way can use these 2 libraries require optimizer, without having alter either file? if necessary can edit nvd3's code make amd module, obvious reasons it's bad practice edit 3rd party libraries, i'd prefer non-editing solution.
Comments
Post a Comment