Tim
08/25/2022, 9:25 PMbrowserify
to bundle an application, and include it in an html page, which sounded like what I wanted, so I'm trying to do that, but this is also where things have gotten complicated.
I was able to sort out that if I put this code at the top of my d3.charts.js file, it pulls in the correct dependencies.
const d3 = require("d3/dist/d3");
const htl = require("htl/dist/htl");
And I can use browserify
to bundle all those dependencies into a single file.
The charts depend on d3 per above. d3 depends on jquery. But I also use foundation-sites which also depends on jquery. So I figured that it would be a good idea™ to package jquery as one bundle, foundation as a second bundle, and d3 and the charts as a third bundle (so as not to have jquery duplicated, and to not include the chart bundle on pages that don't need it), and that somehow, I'd be able to set it up so that foundation and my chart bundle would be able to reference jquery.
I was able to work out how to exclude jquery from my foundation and chart bundles (browserify -x jquery
), but what I haven't successfully worked out is how to reference jquery in the HTML so that foundation and the charts can see and use it. It seems that browserify --standalone
is involved somehow, because that's what's supposed to make things visible from outside the bundle. But I haven't figured out how to make this work.
I'm not sure what additional code, etc. might be useful, so I'm going to leave it here, but can reply with whatever. Also, if anyone has a completely different approach, I'm also open to that. Like I said at the start -- I just want the chart in the page...Jim Frankowski
08/26/2022, 12:30 AMTim
08/26/2022, 3:49 PMJim Frankowski
08/26/2022, 4:51 PMTim
08/26/2022, 8:19 PM