+
Skip to content

Browserify compatibility #126

Closed
Closed
@rattrayalex

Description

@rattrayalex

Hey,

I'd love to be able to use this library from the client through browserify. There are a few issues currently preventing that from working. First and foremost, browserify cannot detect dynamic require()s, so child libraries aren't loaded.
Eg;

var cls = require("./api/v" + this.version);

needs to be replaced with an if statement, with each branch explicitly requireing its version.

Similarly, in v3.0.0/index.js, the fancy forEach at the bottom has to be replaced with

Util.extend(proto, require("./gists"));
Util.extend(proto, require("./gitdata"));
Util.extend(proto, require("./issues"));
Util.extend(proto, require("./authorization"));
Util.extend(proto, require("./orgs"));
Util.extend(proto, require("./statuses"));
Util.extend(proto, require("./pullRequests"));
Util.extend(proto, require("./repos"));
Util.extend(proto, require("./user"));
Util.extend(proto, require("./events"));
Util.extend(proto, require("./releases"));
Util.extend(proto, require("./search"));
Util.extend(proto, require("./markdown"));
Util.extend(proto, require("./gitignore"));
Util.extend(proto, require("./misc"));

Uglier code, perhaps, but it would work on Browserify. Well, that's the first step - use of fs to read JSON would need to be replaced with requireing instead. I didn't make it past that =)

Would be understandable to not support this as well, of course. But would be pretty cool to have.

Cheers!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载