Tuesday, 6 August 2013

How to handle dependencies with requireJS

How to handle dependencies with requireJS

This is what my config.js file looks like:
require.config({
baseUrl: '../',
paths: {
jQuery: 'js/jquery-1.10.2.min',
SyntaxHighlighter: 'js/syntaxhighlighter/scripts/shCore',
shXml: 'js/syntaxhighlighter/scripts/shBrushXml'
},
shim: {
jQuery: {
exports: '$'
}
}
});
require(['js/main']);
Then my main.js looks like this:
define(['require', 'jQuery', 'SyntaxHighlighter'], function(require, $){
require('shXml');
});
I think the problem is that there is no define(...) wrapper around my
shXml file... I am wondering if I can make this work without having to use
that wrapper. Maybe an export shim would do it.
As it stands now, i get this error every time.

No comments:

Post a Comment