I'm working with requirejs and I have a working application but on running the r.js optimiser I find it impossible to not return any undefined errors in the compiled script.
The errors are all on load and are similar to:
Uncaught TypeError: undefined is not a function
Before optimising I have 0 errors and everything works as expected, but on running r.js with the following build file I get an undefined js error on loading the file.
Is there something I am doing wrong in my build file? I am using a couple of plugins in my application but as the shim is configured and working before optimisation I am pretty confused as to why this would break.
One side note is that r.js was not including require.js which was causing an issue, to resolve I included require.js manually before the main script was called which looked to fix the problem but in all honestly it's pretty hard to tell what the issue is!
Thanks for taking a look! :)
main.js:
require.config({
baseUrl: "*my base url*",
shim: {
jquery: {
exports: 'jQuery'
},
parsley: {
deps: ["jquery"]
},
marquee: {
deps: ["jquery"]
},
'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
});
requirejs(['jquery', 'modules/log', 'modules/util', 'modules/youtube/youtube', 'modules/ticker', 'parsley', 'modules/fb'
], function ($, log, util) {
*app stuff*
});
build configuration:
({
appDir: './',
baseUrl: './',
dir: './dist',
modules: [
{
name: 'main',
}
],
fileExclusionRegExp: /^(r|build)\.js$/,
optimizeCss: 'none',
optimize: "none",
removeCombined: true,
paths: {
jquery: "empty:",
facebook: "empty:"
},
shim: {
jquery: {
exports: 'jQuery'
},
'facebook' : {
exports: 'FB'
}
}
})