How to do code splitting in latest GWT SDK?

102 views
Skip to first unread message

David

unread,
Oct 4, 2024, 10:18:56 PM10/4/24
to GWT Users
In gwt-core-1.0.0-RC1.jar, I see "Pick either GWT2 split point or Closure-Compiler chunks". Where can I find a code splitting SDK?


David

David

unread,
Oct 4, 2024, 10:24:54 PM10/4/24
to GWT Users
I use GWT 2.10.

David

Colin Alworth

unread,
Oct 4, 2024, 10:26:52 PM10/4/24
to GWT Users
While gwt-core and the other refactored modules are intended to be both gwt-compatible and j2cl-compatible, there are a small handful of classes and methods in those refactored modules that, in their original form, were somehow specific to the GWT compiler itself.

The com.google.gwt.core.client.GWT class is one such class that mostly consists of "magic", where there is no java or js implementation of many of its members, but those members exist to allow the compiler to rewrite certain calls with specific behavior. As such, org.gwtproject.core.client.GWT cannot correctly implement all of those methods, and throws exceptions where it must fail.

In a case like this, you must call the original method on the com.google.gwt class while you still use GWT. If you migrate to j2cl and closure, you must find another solution there - j2cl has no split points, and closure-compiler doesn't even think of split points in the same way that GWT does. So, as long as you continue to use GWT 2, call the runAsync() method on the com.google.gwt.core.client.GWT class, and refer to https://www.gwtproject.org/doc/latest/DevGuideCodeSplitting.html for more guidance.

David

unread,
Oct 5, 2024, 7:05:58 AM10/5/24
to GWT Users
Thank Colin very much. I am following the above url to do code splitting. I found initial download size is very big. Left over code only takes 1%. 75 org.gwtproject.i18n.shared.cldr.impl.CurrencyList_XX are generated. Each has 10741 bytes in size. I don't need all CurrencyList files. How do I reduce  CurrencyList files?

Thanks,

David

Colin Alworth

unread,
Oct 7, 2024, 1:23:32 PM10/7/24
to GWT Users
Without seeing your code, it will be hard to guess what is happening here. Did you enable each of those locales in your app (i.e. in a .gwt.xml file)? That, combined with your usage of the currency data in some widget/class should be the only way that those classes are included in your output.

Additionally, you might be ending up with every single locale in a single permutation because <collapse-all-properties /> or <collapse-properties .../> was specified in the .gwt.xml, indicating that more than one locale should be combined into a single output.

Absent specifics of your application and how it is set up, it is hard to guess beyond that.
Reply all
Reply to author
Forward
0 new messages