github-tools / github

A higher-level wrapper around the Github API. Intended for the browser.
BSD 3-Clause "New" or "Revised" License
3.6k stars 759 forks source link

How to import Github? #307

Closed janbaer closed 8 years ago

janbaer commented 8 years ago

I'm trying to use your Github api in a ES6 environment with webpack and gulp.

When I'm trying to import the Github function with the following code

import { Github } from 'github-api';

I'm just getting these error: _githubApi.Github is not a constructor"

janbaer commented 8 years ago

I just tried to use the function with require and this worked. But I would prefer to use it in the ES6 module way... Thanks!

AurelioDeRosa commented 8 years ago

Since we're not using ES2015 yet, you should import it as

import * as Github from 'github-api';

Can you try it and let me know?

janbaer commented 8 years ago

Thanks for the tip. When I try this, I'm getting the following error message:

Github is not a constructor

This of ok, since I import Github not as class from which I can create an instance. But when I use Github.getRepo without creating an instance of Github before I'm getting another error:

Github.Repository is not a constructor"
janbaer commented 8 years ago

It would be nice to use it also in the way how to import modules in the ES2015 way, but I can live with the commonjs syntax since webpack is supporting both

clayreimann commented 8 years ago

@janbaer Thanks for the feedback. ES2015 imports should be available in the forthcoming v1.0.0

clayreimann commented 8 years ago

@janbaer v1.0.0 is out, are you still affected?