I am currently faced with quite a challenging issue related to GWT codesplitting and was hoping for some help.
I currently work on a large legacy GWT application (pre-MVP days) and I am looking to code split this application based on the modules that the "portlets" (what we call the various composite widgets that we build our pages up with) are part of.
Currently our modules are just identified by the package that the portlet falls into but I am open to changing this to better suit a sound generic codesplitting design.
Any ideas on how I can design this code to indicate that a portlet / composite belongs to a specific "module" and then split the code so that the first time any portlet / composite within module X is loaded, the whole of module X is loaded?
Thanks
Hmm ... normally, it's quite simple but I guess that's not your real problem ...
Simply use this:
GWT.runAsync(new RunAsyncCallback() {
public void onFailure(Throwable reason) {
...
}
public void onSuccess() {
...
}
});
Everything within the onSuccess method will then be splitted in another javascript file which will then be loaded on demand.
In case you want to seperate composites from the rest of your code, simply put the creation of your composite inside this onSuccess method.
You also can nest GWT.runAsync methods, so you can split the part again in different parts, e.g. first GWT.runAsync loads module X, in constructor of module X you could do another runAsync which then loads your composize.
Of couse, there could be some dependencies between the part which make it difficult for the compiler to split but I have tested it with one of my projects (about 40k lines of code) and it worked like a charm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With