Closed jcollum closed 11 years ago
Looks like changing the define
call to define(name, [], definition);
is getting me closer. It doesn't error but I don't get a mod object out of:
Hey @jcollum!
If you're just targeting AMD and CJSM, then you could try one of these. I recommend the top one in curl.js.
I can't explain why that's failing, atm. Hmmm...
-- John
The minification is making it hard to see what's going on.
Hey @jcollum, I copied your mod.js and tried to load it using a minified curl.js and it works fine for me. o_O -- J
Yeah, I tried using the unminified curl.js but it failed in a big way so I don't think that'll work. As an end user it'd be helpful if there was a curl.js and curl-min.js in the dist folder.
I'll try your suggestions out tomorrow. Thanks for the help.
I believe this is resolved, too? If not, please reopen it and let us know. -- John
This issue looks pretty close to something that is happening to me. On the Dev branch, when I include lodash and run a cram build on my project, it is exiting with this error. It seems that because lodash defines the anonymous AMD module inside its closure, it doesn't get assigned an identifier to be used by the built code, so curl doesn't know where to grab it. Everything works in a non-built version, and if I change
define(function() {
return _;
});
to
define('lodash', function() {
return _;
});
inside of lodash, the build works.
If this isn't related, I can open a new issue, just let me know.
Oh, and here is my config:
curl({
baseUrl: './',
pluginPath: 'curl/plugin',
paths: {
'jquery': 'deps/jquery',
'lodash': 'deps/lodash',
'tmpl': 'js/lodash-template'
},
packages: [
{
name: 'flight',
location: 'deps/flight'
},
{
name: 'curl',
location: 'deps/curl/src/curl'
},
{
name: 'app',
location: 'js'
}
],
preloads: ['jquery']
}, ['app/Stickers']).then(function(Stickers){
console.log('Loaded');
Stickers.attachTo('.js-attach-stickers');
}, function(err){
console.log('Error in loader:', err);
});
hey @phated, this is likely a problem in cram.js. I just published a new cram.js release (0.7.1) that fixed a problem that may be the cause of the lodash issue. try it. if it still fails, I'll set up a lodash test. - John
Looks like it is still failing.
I'm trying to write my js to be more AMD/CommonJS compatible and be usable with Curl. Grabbed a chunk of code off of SO here: http://stackoverflow.com/questions/13673346/supporting-both-commonjs-and-amd
It looks like so: (mod.js)
I'm calling it from the console with:
curl(['mod'], function(mod) {mod.sayHi('Hi unscriptable!'); });
It's failing. Looks like: