Skip to content
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

Closed
DracoBlue opened this issue Mar 3, 2014 · 4 comments
Closed

Fix requirejs integration #18

DracoBlue opened this issue Mar 3, 2014 · 4 comments
Labels

Comments

@DracoBlue
Copy link
Owner

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.

@DracoBlue DracoBlue added the 2.x label Mar 3, 2014
@eberdt
Copy link

eberdt commented Mar 3, 2014

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")
});

@DracoBlue
Copy link
Owner Author

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>

@eberdt
Copy link

eberdt commented Mar 3, 2014

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>

@graste
Copy link

graste commented Mar 3, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants