+
Skip to content

New build infrastructure + modularize codebase #264

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

Closed
wants to merge 5 commits into from

Conversation

clayreimann
Copy link
Member

Major Changes:

  • Modules Moved the individual APIs into their own modules
    • Made modules more like ES6 classes (there should be a pretty direct parallel between the new code and how it will look in ES6)
    • Modules share a base class Requestable to replace the prior global functions _request and _requestAllPages
  • Axios Added axios as the HTTP abstraction
  • Webpack Moved to webpack as a bundler/minifier
  • Testing Tests now run in Chrome due to limitations of Phantom (though I think this can be changed with a minimal tweak to Requestable)
    • Tests should now fail instead of timing out thanks to helper callbackWithError

Not Addressed:

  • ES6 while it would have been more or less simple to rewrite this as ES6 as part of this move things like code coverage get less fun (you need isparta to supplement istanbul)
  • Documentation I found most of the documentation comments to be just noise. There is value to adding JSDoc so that we can get better API documentation but I haven't done that here. I also haven't
  • Code coverage the way we measure code coverage is rather opaque. There is no real information being generated beyond the number of lines/statements/branches being covered. Work is needed to produce useful code coverage results

clayreimann and others added 4 commits December 6, 2015 19:27
* add new dependencies
* Build with webpack
* Bundle dependencies
* Split the library into separate files based on API
PhantomJS appears not to support the full XHR2 spec. Test pass in
Chrome but in PhantomJS they with DOM Exception 12 on the line where
axios sets `XHR.responseType`
Errors thrown in the callbacks don’t bubble up to the calling test and
make the tests timeout instead of fail.
@clayreimann clayreimann force-pushed the add-webpack branch 6 times, most recently from bd2a8f4 to 6ffc765 Compare December 9, 2015 21:50
…l faster.

* add new dev dependencies
* reformat test names in test.user
@AurelioDeRosa
Copy link
Member

I'm against introducing a new tool (i.e. WebPack), especially for UMD. In the next version we'll use Babel and to address UMD there's a specific plugin: ES2015 modules to UMD transform.

@clayreimann
Copy link
Member Author

I would agree with you if the UMD wrapper was only benefit gained by adding webpack to the build chain, but webpack actually serves many purposes. (And it's easy to add babel to webpack)

  • It provides the UMD wrapper
  • It allows our dependencies (such as axios and js-base64) to be easily packaged for the web (or not they can be marked as external and then users can provide them if they want).
  • It allows the library to be cleanly decomposed into smaller modules.
  • It isolates the modules from: 1) 3rd party code 2) the each other

Decomposing the library results in more understandable code and a codebase that is easier to search.

  • All of the API objects now subclass Requestable to get their http behavior instead of using the random function _request() which is defined way above as var _request = Github._request = function _request
  • You don't have to skim through one source file to find Repository you can just go to lib/Repository.js

@clayreimann clayreimann changed the title Re-tool build infrastructure + Re-architect codebase New build infrastructure + modularize codebase Dec 10, 2015
@AurelioDeRosa
Copy link
Member

Hi @clayreimann. Thank you for your reply.

  • It provides the UMD wrapper
    Doable with Babel

It allows our dependencies (such as axios and js-base64) to be easily packaged for the web (or not they can be marked as external and then users can provide them if they want).

If you mean to create a package containing everything needed, we aren't doing this. Personally I'd be against it but I'd love to have some thoughts from @Aendrew and @alexcanessa. By the way, this could be done with Browserify and its standalone property.

  • It allows the library to be cleanly decomposed into smaller modules.

ES6 allows that

  • It isolates the modules from: 1) 3rd party code 2) the each other

ES6 allows that

Decomposing the library results in more understandable code and a codebase that is easier to search.

  • All of the API objects now subclass Requestable to get their http behavior instead of using the random function _request() which is defined way above as var _request = Github._request = function _request
  • You don't have to skim through one source file to find Repository you can just go to lib/Repository.js

Totally agree on that. I'm working on a project that extends the functionality of this library and it's a bit of a PITA. I had to create some weird workarounds. Said that, all this modularity can be achieved with ES6 natively.

In conclusion I still don't see the need for a complete new build tool (we've still Gulp in place) for such simple project but I'm open to further this discuss this.

@clayreimann
Copy link
Member Author

@AurelioDeRosa Maybe we're talking past each other, so let me lay out the assumptions that I'm working under and what I thought the goals are.

I thought:

  1. The desired result of the build process was to produce a file github.min.js that can be used as-is in the browser, node, or a require environment.
  2. Babel didn't have a polyfill for the module loader yet

In regards to your assertion:

If you mean to create a package containing everything needed, we aren't doing this.

This actually is the current state of affairs if you look at lines 17-37 you can see that where applicable the missing bits are getting requireed into the core library.

That being said it would appear that Babel does have a polyfill for module loader and as such I'll investigate that. If it looks like it will do what we need (namely get all the objects from lib/ into github.js then great. Otherwise I still think we need something like webpack or browserify to produce a web-compatible output. (corollary if we need webpack or it's ilk we'll probably also want to add a browser property to package.json)

@clayreimann clayreimann mentioned this pull request Mar 9, 2016
1 task
@clayreimann clayreimann closed this Apr 2, 2016
@clayreimann clayreimann deleted the add-webpack branch April 2, 2016 14:56
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.

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