Reputation: 23
I'm having some issue trying to get my Phonegap app written using RequireJS, BackboneJS and various over libraries to work after using r.js.
Everything works fine before optimization however afterwards I'm getting the following error in my main-build.js
Uncaught TypeError: Cannot read property 'View'
Below is my require config
require.config({
baseUrl: 'lib',
paths: {
domReady : 'require/domReady',
text : 'require/text',
async : 'require/async',
jquery : 'jquery/jquery',
jqmconfig : 'jqm/jqm-config',
jqm : 'jqm/jquery.mobile',
underscore : 'underscore/underscore',
backbone : 'backbone/backbone',
jqmaps : 'google/jquery.ui.map',
router : '../app/router',
models : '../app/models',
collections : '../app/collections',
views : '../app/views',
templates : '../app/templates',
app : '../app/app'
},
shim: {
underscore: {
exports : '_'
},
backbone: {
deps : ['jquery', 'jqmconfig', 'jqm', 'underscore'],
exports : 'Backbone'
},
jqmconfig : ['jquery'],
jqm : ['jquery','jqmconfig'],
jqmaps : ['jqm']
}});
this is my bootstrap
require(
[
'app', 'domReady', 'jqmconfig'
],
function(app, domReady){
domReady(function() {
// On device ready initialize the app code
});
});
and here is my build.js
({
baseUrl: 'lib',
paths: {
domReady : 'require/domReady',
text : 'require/text',
async : 'require/async',
jquery : 'jquery/jquery',
jqmconfig : 'jqm/jqm-config',
jqm : 'jqm/jquery.mobile',
underscore : 'underscore/underscore',
backbone : 'backbone/backbone',
jqmaps : 'google/jquery.ui.map',
router : '../app/router',
models : '../app/models',
collections : '../app/collections',
views : '../app/views',
templates : '../app/templates',
app : '../app/app',
main : '../app/main',
},
name: 'main',
out: 'app/main-build.js'})
Anything glaringly obvious?
Thank you for your time.
Upvotes: 2
Views: 1950
Reputation: 1288
The shim-config should be dublicated in build.js
file, so r.js
can properly include shim dependencies into app/main-build.js
. You can simply duplicate your shim in build.js
or better specify mainConfigFile option, so your paths
and shim
could only be listed in one place.
Upvotes: 1