javascript - Davis.js as AMD module? -


can use davisjs amd module requirejs? tried, maybe forgot in require config?

requirejs([    "jquery",    "davis" ], function   ($, routing) {     var app = routing(function () {         this.get('/welcome/:name', function (req) {             alert("hello " + req.params['name']);         });     }); } 

this works:

var app = davis(function () {..}); 

sounds has case of missing shim. need configure requirejs adapt non-amd-compatible library amd module this:

requirejs.config({   paths: {     davis: 'script/davis'   },   shim: {     davis: {       exports: 'davis'     }   } });  require([   "davis" ], function (davis) {   console.log("davis?", davis); }); 

more info in requirejs documentation


invoking davis() directly works since it's available in global scope; it's not "registered" amd module: why it's undefined when requested requirejs.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -