Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make it work with browserify #261

Closed

Conversation

jamestalmage
Copy link

The main issue preventing browserify usage was computed paths
in require statements: require("./" + someVariable). Those have
all been eliminated.

This patch only adds browser support for v3.0.0 (see the throwing
code in /index.js where it states exactly that to understand why).
Hint: it's related to computed paths again.

There were also a number of issues in browserify-http, and
browserify-https that I needed to code around to get things working:

The main issue preventing browserify usage was computed paths
in require statements: `require("./" + someVariable)`. Those have
all been eliminated.

This patch only adds browser support for `v3.0.0` (see the throwing
code in `/index.js` where it states exactly that to understand why).
Hint: it's related to computed paths again.

There were also a number of issues in `browserify-http`, and
`browserify-https` that I needed to code around to get things working:

  - https://github.com/substack/https-browserify/pull/1
  - browserify/http-browserify#90
  - browserify/http-browserify#21
  - browserify/http-browserify#10
@@ -19,7 +19,7 @@ var error = require("./../../error");

var GithubHandler = module.exports = function(client) {
this.client = client;
this.routes = JSON.parse(Fs.readFileSync(__dirname + "/routes.json", "utf8"));
this.routes = require("./routes.json");
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading a file via the fs module is not well supported in browserify without a special transform.
Fortunately for json files we can just require() them and it works across platforms.

@jamestalmage
Copy link
Author

Anyone wishing to use my patched version can install it with the following command:

npm install --save jamestalmage/node-github#browserify-compatibility

You can then use it like you normally would server side. (you still just require("github")).

@olivierbeaulieu
Copy link

@mikedeboer Any chance we can get this work re-started? I would love Browserify support for this package. Any reason why this was never merged? I don't mind doing the work to make it mergeable again.

@kaizensoze
Copy link

Yeah I've been backlogged with stuff, but it's on my radar.

@kaizensoze kaizensoze closed this Oct 7, 2016
@jamestalmage jamestalmage deleted the browserify-compatibility branch January 1, 2017 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants