ryanve / response.js

Responsive design toolkit
http://responsejs.com
Other
801 stars 123 forks source link

Modularize Response's methods #19

Open ryanve opened 11 years ago

ryanve commented 11 years ago

Response's methods fit into two categories:

The current homepage is focused on the breakpoint-swapping feature. After the 0.3 changes (when several methods were made public) I started working on a new version of the docs here. Yet I hesitated to put that on the homepage in fear of documenting any methods that might soon change.

Putting general-purpose methods public can be useful. But once they're documented then they are expected to be supported—regardless of whether or not it is internally needed. In retrospect I might not have made the object utilities or the dataset methods public because they are not internally needed.

In an effort to better modularize the code, I want to better separate the general-purpose methods from the response-specific ones. This will greatly improve maintainability. Support multiple libraries jQuery/Zepto/ender complicates the issue. I'm trying to figure out the most practical way to go about it.

ryanve commented 10 years ago

NPM modules that use UMD (like verge) could be added as devDependencies and bundled via grunt into this pattern:

!function(root, name, make, bundle) {
    make = make.call(root, bundle);
    if (typeof module != 'undefined' && module['exports']) module['exports'] = make;
    else root[name] = make;
}(this, 'Response', function(bundle) {
    // Make export here with private access to bundle.
    return {}; // Return export with properties/methods.
}, function(module, define) {
    // Dependencies (inserted via grunt) run in controlled scope.
}.call({}));
ryanve commented 10 years ago

An alternative to bundling is require the needed modules as dependencies but not bundle them. Devs would need to do bundle via browserify, ender, or otherwise. How are most of you are consuming Response? My guess is that many are using jQuery and separate <script> tags, but using build tools is better. What build tools do you prefer to use?