New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix requirejs integration #18
Comments
i believe we hasn't this situation that we load each other like this and we have no problems atm. Configuration: requirejs.config({
jquery: 'lib/jquery-1.9.1.min',
JsBehaviourToolkit: 'lib/JsBehaviourToolkit-1.7.0',
shim: {
JsBehaviourToolkit: {
exports: 'jsb'
},
jquery: {
exports: 'jQuery'
},
}
}
define([ 'jqueryUI', 'JsBehaviourToolkit', 'JsbEvents'], function() {
console.log("loading libs")
}); |
I use this at the moment (to be sure that jquery is first one!): <script src="./static/bower_components/requirejs/require.js"></script>
<script>
requirejs.config({
baseUrl: './static/js/',
urlArgs: "cb=" + (new Date()).getTime(),
paths: {
jquery: './../bower_components/jquery/jquery',
jsb: './../bower_components/jsb/JsBehaviourToolkit'
}
});
requirejs(['jquery'], function() {
require(['jsb'], function() {
jsb.applyBehaviour(document.body);
});
});
</script> |
this should solve it atm: <script src="./static/bower_components/requirejs/require.js"></script>
<script>
requirejs.config({
baseUrl: './static/js/',
urlArgs: "cb=" + (new Date()).getTime(),
paths: {
jquery: './../bower_components/jquery/jquery',
jsb: './../bower_components/jsb/JsBehaviourToolkit'
},
shim: {
jsb: {
exports: 'jsb'
deps: ['jquery']
},
jquery: {
exports: 'jQuery'
},
}
});
requirejs(['jquery', 'jsb'], function() {
jsb.applyBehaviour(document.body);
});
</script> |
I'm too using shims like @eberdt suggested. Works fine, but we should probably aim for being Node, AMD and browser globals compatible by using one pattern of the https://github.com/umdjs/umd repository. E.g. this one: https://github.com/umdjs/umd/blob/master/returnExportsGlobal.js Also see my remarks in #14 and perhaps close that ticket or merge it into this. |
The current requirejs integration, does not work 100% like a common AMD module.
At the moment, you have to include jquery (if required) and jsb right after each other in synchronous script-tags to make sure, that jsb works properly.
@graste had some other issues with the current requirejs, which shall be fixed with this issue, too.
The text was updated successfully, but these errors were encountered: