With GWT 2.8 yes. It's been suggested that there could be some regexp (or other kind of pattern) matching added later to whitelist/blacklist some @JsType(isNative=false) that you would/wouldn't want to see exported. In the mean time, don't over-use @JsType without isNative=true (in libraries), better (if possible) separate exported types to a specific "application" project to be compiled to a standalone JS script.
Note that for the java.util.List et al. currently annotated with @JsType, the overhead was deemed small enough (because that's only 4 classes without that many subclasses). My suggestion would be, for GWT 2.8, to only use JsInterop for mapping native objects (i.e. only isNative=true). Google likely uses JsInterop with isNative=false but with -closureFormattedOutput and an additional round of Closure Compiler optimisations that would prune unused code and re-obfuscate the names. On Thursday, September 15, 2016 at 11:01:14 AM UTC+2, Vassilis Virvilis wrote: > > So > What you say is: It is not possible to have a page with: > *** gwtapp + gwtlib + js_export + optimization *** > > What is possible to have is either or > > 1) gwtapp + gwtlib + optimization > > or (xor actually) > > 2) gwtapp + gwtlib + js_export > > right? > > a) We assume gwtlib has @JsType(isNative=false) types > b) Optimization is used in the broad sense for method and properties > renaming, removal and other optimization steps > > Jens, Thomas thanks a lot for the education. > > Vassilis > > > On Thu, Sep 15, 2016 at 11:44 AM, Thomas Broyer wrote: > >> Let me try: without -generateJsInteropExports, GWT acts as if >> @JsType(isNative=false) wasn't there at all. >> Why'd you want this? >> >> - when @JsType(isNative=false) is applied to types you didn't write >> yourself (third-party). For example, java.util.Collection, >> java.util.List, >> java.util.Map, java.util.Set, and java.lang.Enum are annotated with >> @JsType. If you don't use -generateJsInteropExports, their >> non-@JsIgnoreâ‹…d >> public members won't be renamed, and the @JsProperty and >> @JsMethod-specified names won't be honored, so you'll have very short >> (obfuscated) names in your app. If you use -generateJsInteropExports, the >> given js-names will be honored and your code will be slightly bigger, but >> then you can pass a java.util.List to JS and you can call getAtIndex and >> removeAtIndex (for example) on it from JS code. >> - when you want to possibly export your project as a standalone JS >> lib, but have it consumable by GWT apps with all the GWT optimization >> goodness: your types will be annotated with @JsType, apps that use your >> GWT >> library without using -generateJsInteropExports will have >> highly-optimized >> code; but you can use -generateJsInteropExports to export your annotated >> types to create a standalone JS lib. GWT apps consuming your GWT library >> and using -generateJsInteropExports will pay the price for your @JsType >> though (see example above about java.util.List), so you'll probably want >> to >> separate out some of your code into a project specific to exporting your >> JS >> lib (similarly to how GWTUpload/JSUpload did it) >> That was Jens' example. >> >> >> On Thursday, September 15, 2016 at 10:18:55 AM UTC+2, Vassilis Virvilis >> wrote: >>> >>> Jens sorry - one more round if you please >>> >>> > The library exists as GWT library (*.jar file with *.gwt.xml)... >>> >>> This GWT library is source right? That means it is compiled by the >>> compilation session of MyApplication right? >>> >>> Unless.... (light bulb goes on) >>> >>> In some cases you want the library to act as JS library for one Page but >>> for another page you only plan to link it with the GWT MyApplication (and >>> not export is as a JS library) where normal optimization techniques apply. >>> >>> Is that it? If so tricky... >>> >>> >>> Vassilis >>> >>> >>> >>> >>> >>> >>> On Thu, Sep 15, 2016 at 1:54 AM, Jens wrote: >>> >>>> >>>> Is this GWT library exported as JS only? ... >>>>> >>>> So I don't get it. What am I missing? >>>>> >>>> >>>> The library exists as GWT library (*.jar file with *.gwt.xml) so you >>>> can use it right away in your GWT app, but the library is also exported by >>>> the library maintainer to JavaScript so that JavaScript people can also >>>> use >>>> it right away by including a *.js file. >>>> >>>> In that case your app does not want to use -generateJsInteropExports >>>> because it directly uses the GWT library which has @JsType(isNative = >>>> false) all over the place in its Java files. If you would use >>>> -generateJsInteropExport in your app, it would have a negative impact on >>>> your code size because these @JsType classes would not be optimized/pruned >>>> then. Now imagine you have several of such libraries in your app. >>>> >>>> -- J. >>>> >>>> >>> >>> >>> >>> -- >>> Vassilis Virvilis >>> >> >> > > > -- > Vassilis Virvilis > -- You received this message because you are subscribed to the Google Groups "GWT Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/d/optout.
