dagrejs / graphlib

A directed multi-graph library for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Separate the local `lib/lodash.js` file to require individual lodash packages

basicdays opened this issue · comments

So I just started trying to optimize the size of the webpack bundle I'm shipping over the wire, and lodash is one giant block of what's getting included. Would you be open to accepting a PR that would have the lib/lodash.js file require the individual lodash packages instead of all of lodash? I'm proposing something like this:

if (typeof require === "function") {
  try {
    lodash = {
        has: require('lodash.has'),
        //etc...
    }
  } catch (e) {}
}

Definitely open to other ideas too. :)

I've run into something similar. Basically, by adding graphlib to my bower.json, my standalone builds went from 431Kb to 1.9Mb. I'm in the process of tracking this down and I'll report what I find. (@basicdays is right, cherry-picking lodash features is the best way to clean things up from a size perspective, but there are also other ways to do this but they are builder specific.)

All this time, I wasn't aware you could directly import individual lodash features, ha. I've been installing them all as separate packages. I'd imagine a change like this would be neither breaking nor difficult. At my current schedule, looks like I'll be able to fork this and see if it works sometime in mid May. If you get to it first if you decide to take it up, I'd certainly be willing to test it out.

Lodash is no longer a dependency.