I'm using RequireJS in my project, which includes a script that traces out dependencies between modules, and combines them into a single JavaScript file. Optionally, it can also minify the combined js file with the Google Closure compiler. Once it's in this form, where all dependencies are included in a single js file, the file can be easily compiled using jsc.
Here's a segment of my ant script which I use to create the single combined js file, compile it to a class file, and then create an executable JAR:
<target name="compile-single-js">
<mkdir dir="${build-js}"/>
<java classname="org.mozilla.javascript.tools.shell.Main">
<classpath>
<path refid="rhino-classpath"/>
<path refid="closure-classpath"/>
</classpath>
<arg value="${js-build-script}"/>
<arg value="${js-build-dir}"/>
<arg value="name=${build-js-main-rhino-frontend-module}"/>
<arg value="out=${build-js-main}"/>
<arg value="baseUrl=."/>
<arg value="includeRequire=true"/>
<arg value="inlineText=true"/>
<arg value="optimize=none"/>
</java>
</target>
<target name="compile-single-class" depends="compile-single-js">
<mkdir dir="${build-class}"/>
<!-- TODO: set -opt -->
<java classname="org.mozilla.javascript.tools.jsc.Main">
<classpath>
<path refid="rhino-classpath"/>
</classpath>
<arg value="-o"/>
<arg value="${build-class-main-name}.class"/>
<arg value="${build-js-main}"/>
</java>
<move file="${build-js}/${build-class-main-name}.class" todir="${build-class}"/>
</target>
<target name="jar-single-class" depends="compile-single-class">
<mkdir dir="${build-jar}"/>
<jar destfile="${build-jar-main}"
basedir="${build-class}"
includes="${build-class-main-name}.class">
<manifest>
<attribute name="Main-Class" value="${build-class-main-name}" />
</manifest>
</jar>
</target>
The complete build script can be found here.