Notice: The Monaca & Onsen UI Community Forum is shutting down.

For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.

Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.

Is it possible to use Require.js in Onsen ?



  • hi,
    I like to use Require.js in my app. is it possible to use it ?



  • @meisam3322 @IliaSky answered you here: http://stackoverflow.com/questions/38551128/is-it-possible-to-use-require-js-in-onsen-ui-framework

    It shouldn’t be a problem to use require.js in an Onsen UI project. Onsen UI is just a library after all.

    Just note that Onsen UI includes not only javascript, but also css styles, which you will need to add in order for it to work.

    If all else fails you can also just load Onsen UI via a script tag and then use require.js for the rest of the project.

    Anyway it should be possible - if you run into any trouble feel free to make a question about the specific problem at hand. :)



  • Hi, maybe I’m too late but I found this solution.
    create an AMD module like this (named onseninit.js)

    define([‘require’],function(require){

    window.setImmediate = window.setTimeout;
    

    });

    then in your config file put something like this

    requirejs.config({
    baseUrl: ’ ',
    paths:{
    onseninit : ‘/path/onseninit’,
    onsen: ‘/path/onsenui.min’
    },
    shim:{
    ‘onsen’:{
    deps: [‘onseninit’],
    exports: ‘ons’
    }
    }

    });

    requirejs([‘onsen’],
    function(ons){

    });

    It seems to work fine…