Okay, I've just gotten dropped into a project I have several different modules written in AMD format. I need to get these javascript files that are loosely related into one javascript file, that will then be referenced as yet another AMD module across different projects (probably from a CDN).
The problem I'm facing is when I run r.js against these files and get them into one file, when I pull that combined file into another project it just gets spit out as undefined.
To give an idea of what I'm talking about
words.spelling.js
define(['jquery', 'some.other.class'], function($, foo){
...
}
words.grammar.js
define(['jquery', 'some.other.class'], function($, foo){
...
}
words.translation.js
define(['jquery', 'some.other.class'], function($, foo){
...
}
Run through r.js into words.min.js
Then say I pull it into app.js as
require(['jquery', 'app/main/main', 'words.min'], function($, main, words) {
$(document).ready(function() {
console.log(words);
}
words just shows up as undefined.
Just concatenating them all doesn't do anything as that just gives me a bunch of define statements one after another.
I tried creating a fake class that has
define(['word.grammar', 'word.translation', 'word.spelling'], function( g, t, s){
return {
grammar: g,
translation: t,
spelling: s
};
});
and running that through r.js, but no dice there either. Am I missing something here or am I going to have re-write these in non-AMD format so I can concatenate them together and return one giant object? Keep in mind, words.min.js is going to have to be hosted on a CDN and cached as it'll be shared throughout a number of projects so I need that as a separate file.