简体   繁体   中英

Distribute GWT module as JavaScript

I have the following requirement:

Produce a GWT module in such a way that it can be used/included in a GWT app without recompiling it (so plug and play). This plug and play module would contain a widget and a some random classes. The GWT apps that use this module should be able to extend some functionality from the module.

It seems to me that the obvious solution would be to simply compile the GWT module to JS, then distribute this JS, and use JSNI to link to it.

I was wondering if there is some sort of standard solution for this.

I would also be interested to know your thoughts on how to ensure browser compatibility (ie how to hook into GWT's bootstrap process, so that we load the corresponding JS file, for the current browser).

To make a long story short, you cannot directly re-use GWT methods if you don't have the Java source. (This is what I call the "Compile time source dependency" of GWT.) So you're already on the right track: You'll have to go via JavaScript.

The project GWT Exporter makes it a lot easier to export GWT methods to JavaScript. It also makes sure, that your methods are not optimized away by the GWT compiler (which it does, if you never call a method from your code).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM