[英]gwt separate modules with no code sharing
I have to make a web application using GWT. 我必须使用GWT制作一个Web应用程序。 The project has a core module that'll expose a set of apis to be used by other apps;
该项目有一个核心模块,它将公开一组供其他应用程序使用的api。 each of these app are unrelated.
每个应用都不相关。 Each shall be loaded in a separate iframe.
每个都应加载到单独的iframe中。
My idea was to compile core into core.js and each app shall have its own app1.js app2.js and so on... 我的想法是将core编译为core.js,每个应用程序都应具有自己的app1.js app2.js,依此类推...
App1 APP1
script type="text/javascript" src="core.js" ></script>
script type="text/javascript" src="app1.js" ></script>
with this design, due to browser caching, each app load only the app.js which should be smaller ~20kb in size. 使用此设计,由于浏览器缓存,每个应用程序仅加载应小于20kb的app.js。
Making a core module is straightforward but the apps are problematic. 制作核心模块很简单,但是应用程序有问题。 The reason being after compilation, each app contains the entire GWT library - this substantially increases the download size of the complete webapp.
原因是编译后,每个应用程序都包含整个GWT库-这大大增加了整个Web应用程序的下载大小。
Can anyone suggest a way to get around this problem ? 任何人都可以提出解决此问题的方法吗? I've checked similar questions on SO, but failed to find a simple working answer fr the problem.
我在SO上检查了类似的问题,但未能找到该问题的简单工作答案。
It can't be done. 不能做
GWT is meant to be a monolithic compile. GWT旨在成为整体编译。 It will take all your java code, assume that no other code exists other than what was provided to it, and then generate optimized javascript code.
它将使用您所有的Java代码,并假设除了提供给它的内容外没有其他代码,然后生成优化的javascript代码。 While doing so, it will only compile portions of standard GWT library that are actually being used by your program.
这样做时,它将仅编译程序实际使用的标准GWT库的一部分。
Because of the way GWT works, its always going to be inefficient to include multiple GWT modules on the same page. 由于GWT的工作方式,在同一页面上包含多个GWT模块总是很低效。
Instead, here is what I'd recommend - 相反,这是我建议的-
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.