(function (curl) {
var config = { paths: { jquery: 'assets/js/components/jquery/jquery', curl : 'assets/js/components/curl/src/curl', gritter : { location : 'assets/js/components/gritter/js/jquery.gritter.js', config : { loader : 'curl/loader/legacy', factory : function(){ return $.fn.gritter }, requires: ['jquery'] } }, icanhaz : { location : 'assets/js/libs/icanhaz',
config : { loader : 'curl/loader/legacy', exports : 'ich' } }, templates : 'assets/templates', bootstrap : 'assets/js/components/bootstrap/docs/assets/js/bootstrap' }, packages: [ { name: 'backbone', location : 'assets/js/components/backbone', main:'backbone.js'}, { name: 'lodash', location: 'assets/js/components/lodash/dist', main: 'lodash.js'}, { name: 'underscore', location: 'assets/js/components/lodash/dist', main: 'lodash.js'}, { name: 'marionette', location: 'assets/js/components/marionette/lib/core/amd', main:'backbone.marionette.js'}, { name: 'backbone.wreqr', location : 'assets/js/components/backbone.wreqr/lib/amd', main:'backbone.wreqr.js'}, { name: 'backbone.babysitter', location : 'assets/js/components/backbone.babysitter/lib/amd', main : 'backbone.babysitter.js'}, { name: 'wire', location: 'assets/js/components/wire', main: 'wire' }, { name: 'when', location: 'assets/js/components/when', main: 'when' }, { name: 'meld', location: 'assets/js/components/meld', main: 'meld' }, { name: 'cola', location: 'assets/js/components/cola', main: 'cola' }, { name: 'poly', location: 'assets/js/components/poly', main: 'poly' } ] ,preloads: [ 'jquery', 'icanhaz', 'gritter'// ,'curl/debug' ]
}; curl(config, [ 'jquery' ,'icanhaz' ,'gritter' ,'app/application' ], function(jquery, ich,gritter, application){ console.log('gritter: ', jquery.gritter); // prints out just fine console.log('required gritter: ', gritter); // prints out undefined console.log('application: ', application); // prints out application object
}).then(notify, fail);
function notify() { console.log('loaded'); }
function fail(ex) { console.log('An error occurred while loading.', ex.message); if (ex.stack) console.log(ex.stack); };})(curl);
// #Main Applicationdefine(function(require) { 'use strict'; // Load attached libs and application modules var $ = require('jquery'), _ = require('lodash'), Backbone = require('backbone'), ich = require('icanhaz'), // error comes from here Notify = require('./services/notify');
// Setup templates ich.addTemplate('main', require('text!templates/main.html'));
... rest of module
Hey John,
I added a test to the suite to demonstrate the problem, https://github.com/cujojs/curl/pull/233.
This is actually my first time doing something like this, so please forgive me if i'm doing something wrong process-wise. :) I'd love to try to fix it myself, and will try if i have time, but at least its in your code base now.Yes, I agree on the Marionette problem, its almost not even worth trying to do AMD for it. As for amd-backbone, it looks like they've caught up. They're on 1.0.0, which is the latest base version, and I didn't have to do the bug workaround you mentioned (yay!)
node ../node_modules/cram/cram.js index.html
Parsing index.html for curl configurationFound data-curl-run: config.jswarning: grokking "index.html": Did not inspect code inside `curl()` callback(s).warning: grokking "index.html": Did not inspect code inside `.then()` callback(s).`appRoot` resolved to .`baseUrl` resolved to somedir/client/`output` resolved to config.cram.jsCompiling modulescram failed: ENOENT, open '/fullPath/client/icanhaz.js' icanhaz app/applicationError: ENOENT, open 'fullPath/client/icanhaz.js' icanhaz app/application
<script src="assets/js/components/curl/src/curl.js"></script> <script data-curl-run src="config.js"></script>