heavysixer / d4

A friendly reusable charts DSL for D3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Publish on npm

jefffriesen opened this issue · comments

We've completely moved our client-side dependencies from Bower to npm and use Browserify for dependency management. Browserify allows you to include npm modules on the client. It's great.

There are ways to include Bower modules within Browserify. Debowerify works sometimes but can cause conflicts depending on what other transforms you have.

For reference for others coming here, this is a way to get d4 workings within Browserify:

package.json:
  "browser": {
    "bootstrap": "./src/javascript/vendor/bootstrap.js",
    "d4": "./src/javascript/vendor/d4.js",
  },
  "browserify": {
    "transform": [
      "browserify-shim",
      "coffeeify",
    ]
  },
  "browserify-shim": {
    "bootstrap": {
      "exports": "bootstrap",
      "depends": [
        "jquery:$"
      ]
    },
    "d4": {
      "exports": "d4",
      "depends": [
        "d3:d3"
      ]
    },

Then you can require it in your modules:

d4 = require('d4')

But it's really nice to just be able to do this and be done:

npm install d4 --save

Feel free to submit a pull request and a means of testing and I am happy to merge this into the project.

sweet. Testing things on my end now.

Was looking at this with @jefffriesen, looks like this won't quite do it, since each of the files in src refer to d4 as though it's a global... if you'd consider it, we could look at moving a few things around so it refers to the correct d4 object when built.

@tgriesser @jefffriesen that sounds great to me as long as the composabilty of the library remains. Honestly, I'd like to refactor base.js into a series of smaller modules at some point too so maybe this would be a good first step. So consider this +1 from me!

Any progress on this? I'm hoping to use d4 with browserify in a project.

@nsonnad happy to consider pull requests for this feature, but i've been working on other aspects of d4 at the moment.

Cool, I'm hoping to prepare a PR for this. Do you have some guidance as to how to refactor base.js (or modularize other parts of d4)? In trying to remove the dependency on d4 as a global I'm having to pull things apart quite a bit, but I want to make sure I'm following what you envisioned.

@nsonnad sorry for the late reply I wanted to think it over before responding. In general the only thing I'd like to ensure is that at some point we can pull the requisite parts away from base.js and make it a plugin style model. Right now d4 is a ball of features and parsers but as things grow i expect users will want to just choose the charts they are interested in. This was my main approach in claiming a global namespace early on. If you can continue to support this long term goal with the reorganization needed to make it work inside browserify I am all for it! Please let me know if you need any help, or have questions about the codebase I am more than happy to ride shotgun on this with you.

I've made a browserify branch now off of master https://github.com/heavysixer/d4/tree/browserify
I plan on working on this now. @nsonnad if you have anything you've been working on that you'd like to contribute let me know.

Thanks @heavysixer. I did plan on working on it at some point in the next couple of weeks. I've done some initial work but it was mainly just me orienting myself with the library, nothing too helpful.

I'll keep an eye on the progress in that branch and suggest ways I can help out as you go. How does that sound?

@nsonnad this sounds perfect, thanks for doing that.