This is a migrated thread and some comments may be shown as answers.

Kendo UI AMD/RequireJS integration

1 Answer 251 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Berry
Top achievements
Rank 1
Berry asked on 10 Nov 2014, 09:39 AM
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? 

1 Answer, 1 is accepted

Sort by
0
Mihai
Telerik team
answered on 11 Nov 2014, 08:30 AM
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!
 
Tags
General Discussions
Asked by
Berry
Top achievements
Rank 1
Answers by
Mihai
Telerik team
Share this question
or