Hot deploy for javascript files not works

Hi Team,

Hot deploy for javascript seems not works, i’m writing a javascript component, the files layout like this:
image

The ocr-connector.js can’t be deployed ,although the console have printout the hot deploy messages:
image

To load changed javascript file, must restart the application.

Environment: Studio 12,windows10 ,idea 2019.1.4

Hot deploy mechanism does not work for all files in a project, only for a subset of them.

Please see: Hot Deploy - CUBA Platform. Developer’s Manual

Regards,
Paolo

Hi Paolo,

Tanks for your reply.

But what the output in console means ?:
image

And i think the hot deploy for javascript files is very important for Studio. If every time made changes for javascript ,we must restart application ,it will be very ineffective.

Regards,
Ray

I suppose that’s the listener that tracks filesystem changes, and triggers the hot deploy. The fact that the hot deploy has been triggered does not mean that your specific changes are included in what is being hot-deployed. But for this you need an official response from the cuba team…

Based on my personal experience, the hot deploy feature is designed for the “everyday” cuba users, and that users do not have (or are willing to) deal with javascript files…
What I mean is that the ability to tweak the html/css/js of screens is something that is considered advanced (or exceptional) usage of the platform. For example, I tend to relegate that kind of code (custom js components, or similar things) in add-ons that are then simply “consumed” by target applications. In that regard, I never felt the need for hot-reload when developing such add-ons.

Regards,
Paolo

Hi Paolo,

Thanks for your explain.

Regarding the hot deploy for javascript ,let us wait an official response.
Did you develop a javascript component that described in 使用 JavaScript 库 - CUBA 框架开发者手册. Is there a way make the browser load the changed javascript and don’t need restart the application?

I developed several JS integrations in my addons, the most complex one is: JavaScript Scheduler | DayPilot for JavaScript - HTML5 Calendar, Scheduler and Gantt Chart Web Components
A bit more than the sample you pointed out… :wink:

I don’t know if yours is a developer side use case (compile time), or a business/feature requirement (runtime).

That is, if the reloading of a dynamic or external JS file is part of your frontend business logic (at runtime), then there are several solutions to this, all of them outside the scope of this discussion (and not related to CUBA in any way).

If you refer to the compile time experience, that is hot reloading JS files that you change in the IDE, there’s no solution at the moment, or at least nothing that I’m aware of…

Regards
Paolo

1 Like

Hi!
Hot deploy of js is not supported yet. @pfurini is right, saying that triggering the hot deploy does not mean that the changes will be handled by CUBA. We will think about the support of javascript hot deploy.

1 Like

Hi Alexander,

Thanks .
Is there a workaround for that?

Yes, you can manually put js file to tomcat/webapps/app/VAADIN directory or to tomcat/webapps/app/WEB-INF/classes/com/skd... (full package path).

Just remember: files hot-deployed in a such way will not be erased on the next deploy (so you should delete them manually or trigger gradlew undeploy)

Hi Vlad ,

Thanks for your explain, I will try.

Ray,
Regards

Hi Vlad,

The approach works fine.
I used the FileWatcher plugin of IDEA and Ant script to sync changed files automatically.

The ant script:

<project name="StaticResourceSync" default="syncResource" basedir="." >
    <echo>sync</echo>
	<dirname property="antfile.dir" file="${ant.file}"/>

	<fileset id="resourceDir" dir="${basedir}/modules/web/src">
        <include name="**/*.js" />
        <include name="**/*.css" />
	     <modified>
	     	<param name="update" value="false"/>
		</modified> 
    </fileset>

	<target name="syncResource" description="Sync Local Package Src">
		<copy todir="${basedir}/deploy/tomcat/webapps/xxxCmp/VAADIN" flatten="true">
			<fileset refid="resourceDir"></fileset>
		</copy>
        <copy todir="${basedir}/deploy/tomcat/webapps/xxxCmp/WEB-INF/classes">
            <fileset refid="resourceDir"></fileset>
        </copy>
		<echo>sync complete</echo>
	</target>
</project>

The setting for filewatcher plugin :
image

Hopes be helpful for others.

2 Likes