Skip to content

Instantly share code, notes, and snippets.

@unscriptable
Last active December 21, 2015 13:09
Show Gist options
  • Save unscriptable/6310612 to your computer and use it in GitHub Desktop.
Save unscriptable/6310612 to your computer and use it in GitHub Desktop.
possible way to specify legacy exports and dependencies
paths: {
curl: '../src/curl',
// you can use a path
test1: {
location: 'stuff/plain_old.js',
config: {
loader: 'curl/loader/legacy',
exports: 'testDomain.foo.bar' // required!
}
}
},
packages: [
// or a package
{
name: 'test2',
location: 'stuff',
main: 'plain_old_2',
config: {
loader: 'curl/loader/legacy',
exports: 'testDomain.awesome', // required!
requires: ['test1']
}
}
]
curl([test2], function (test2) {
// test2 is available here, test1 was loaded in advance
});
@unscriptable
Copy link
Author

More examples:

/**
 * @example Backbone
 *
 * This backbone example uses a function call to return the exports.  If
 * the code to return the exports is any more sophisticated than this, you
 * should consider using a `factory` option instead of `exports` since
 * factory functions can be tested.
 *
 * curl.config({
 *     paths: {
 *         backbone: {
 *             location: 'modules/backbone-1.3.1/backbone.js',
 *             config: {
 *                 loader: 'curl/loader/legacy',
 *                 exports: 'Backbone.noConflict()',
 *                 requires: ['jquery', 'lodash']
 *             }
 *         }
 *     }
 * });
 *
 * @example jQuery UI
 *
 * This jQuery UI example uses the `factory` option to return the correct
 * jQuery UI widget from a concatenated collection of widgets in a
 * jqueryui.js file.
 *
 * curl.config({
 *     packages: {
 *         jqueryui: {
 *             location: 'modules/jquery-1.6.3/jqueryui.js#',
 *             config: {
 *                 loader: 'curl/loader/legacy',
 *                 factory: function (fullId) {
 *                     var id = fullId.replace('jqueryui/', '');
 *                     return $.fn[id];
 *                 }
 *                 requires: ['jquery', 'css!jqueryui.css']
 *             }
 *         }
 *     }
 * });
 */

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment