Kendo UI AMD/RequireJS integration

2 posts, 0 answers
  1. Berry
    Berry avatar
    2 posts
    Member since:
    May 2014

    Posted 10 Nov 2014 Link to this post

    Dear Telerik Developers,

    I've made a grunt task that collects all my javascript files and calculates it's dependencies according to the YUIDoc output which works great. I'm building an IDE upon Kendo and for now I'm including "kendo.all" in my minified version but that kills my browser (the minified version is 2.3 MB). So I want to include only the components of Kendo that I use, but then I'm running into the problem that my grunt task collides with the AMD usage of Kendo itself. The solution would be to remove the first three lines in every file in "src/js":

    (function(f, define){
    define([ "./kendo.core" ], f);
    })(function(){

    Or the define needs a name translation as requirejs provides it the "paths" section. If the "./" is not ommited it could make a difference (I think) but testing that would require a lot of work with a huge possibility that it would fail.

    Could someone give me a solution or a tip how to resolve this? 
  2. Mihai
    Admin
    Mihai avatar
    153 posts

    Posted 11 Nov 2014 Link to this post

    Hi,

    It was decided to add AMD wrappers to original sources, so that original sources themselves can be loaded with RequireJS.  I personally voted against this, because it badly complicates the build scripts, but still it was done and it's here to stay.

    One possibility would be to use our own build script to get minified code for only components that you use.  Please see kendo-meta.js from Kendo UI Core.  That's used in our Grunt task.

    Kendo-meta can be used separately, for instance if you clone the kendo-ui-core repo and run npm install, the following should work:

    node build/kendo-meta.js --full --all-deps --min kendo.menu.js kendo.window.js

    and it outputs the complete code required to use just the Menu and Window widgets.

    Alternatively, you can try using RequireJS's optimizer.  That should work, but we didn't test it and we can't officially support it.

    Hope this helps.

    Regards,
    Mihai
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top