Solution:
Thanks to Louis I was able to resolve my undefined issues. There were a number of problems:
- I had a shim for jquery 1.9.1 which was not required as Louis pointed out
- I had an incomplete deploy file, using the mainConfigFile property to duplicate my main.js configuration was a nice easy way to sort that.
- I had two plugins which were causing issues, one was AMD compliant and the other was not.
To resolve the deploy script issues I just needed to remove the shim for jquery and parsley as they are both compliant so do not need a shim and match the main.js config using mainConfigFile.
This will cause a error when you run r.js in terminal / cmd as jquery is located from a CDN. To fix that issue just add 'jquery' : 'empty:' to your paths property in your build.js. This will override the main.js config allowing r.js to continue.
To resolve the plugin errors I just needed to wrap both plugins with a define method as you would your own modules, no need to return anything, just make sure you have listed the dependencies.
Final source:
main.js
require.config({
baseUrl: "*my base url*",
shim: {
'facebook' : {
exports: 'FB'
}
},
paths: {
jquery: [
"//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min",
"vendor/jquery"
],
parsley: "vendor/parsley",
marquee: "vendor/jquery.marquee.min",
'facebook': '//connect.facebook.net/en_US/all'
},
waitSeconds: 0
});
build.js
({
appDir: './',
baseUrl: './',
dir: './dist',
modules: [
{
name: 'main',
}
],
fileExclusionRegExp: /^(r|build)\.js$/,
optimizeCss: 'none',
removeCombined: true,
mainConfigFile: './main.js',
paths: {
"jquery": "empty:"
}
})
plugin example:
define(['jquery'], function (jQuery) {
*some jquery plugin code*
});