Could not load requirejs optimizer in jquery

I am optimizing my requirejs application along with the base and jquerymobile, the following file structure:

/application /app /models /views /collections /scripts main.js text.js /assets backbone.js /libs /jquery /jquery.js /jquery-mobile.js app.js r.js /public /css /style.css 

In the console, I tried to execute the ff command:

 node ../r.js -o name=main out=../build.js baseUrl=. paths.models=../app/models paths.app=../app 

I made sure that the paths are well defined and work correctly, except for this error (this is what I get when I run the command):

 Tracing dependencies for: main Error: Module loading did not complete for: jquery at Function.traceDependencies (/home/dunhak/public_html/my_path/etc/application/r.js:15117:19) 

Thank you very much!

+4
source share
1 answer

Some of them will depend on the loading order of your scripts. Is jQuery loading up to require.js or vice versa?

The last few lines of jQuery may contain the key to the solution:

 if ( typeof define === "function" && define.amd && define.amd.jQuery ) { define( "jquery", [], function () { return jQuery; } ); } 

I assume you are doing something like:

 var $ = require('jquery'); //lower-case Q 

personally, I did:

 var $ = require('jQuery'); //upper-case Q 

all of this may depend on your require.config - I use something like:

 require.config({ baseUrl: "/js", paths : { jQuery: 'lib/jquery-1.7.1.min' //, etc... } }) 

Another thing to think about: you may not want jQuery to be included as part of your optimized output — instead, download a pre-modified version from the CDN (etc.). In this case, you need to exclude the jquery module as described here: http://requirejs.org/docs/jquery.html

 modules: [ { name: "main", exclude: ["jquery"] } ] 
+4
source

All Articles