Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

The JSX resource converter

Chuck Dumont edited this page Jun 25, 2015 · 15 revisions

The JSX resource converter is an implementation of an Aggregator extension which implements the com.ibm.jaggr.service.resourceconverter extension point. It converts JSX files to JavaScript files. To use this resource converter in your application, you would add the following markup to the plugin.xml of the bundle that instantiates the Aggregator:

<extension
    id="converter.jsxResourceConverter" 
    point="com.ibm.jaggr.service.resourceconverter">
    <converter class="com.ibm.jaggr.core.impl.resource.JsxResourceConverter"/>
</extension>

And add the resourceconverters init-param to the <servlet> tag for the Aggregator:

<init-param name="resourceconverters" value="converter.jsxResourceConverter"/>

The JSX resource converter works as follows: Any request for a JavaScript resource (.js extension) that cannot be satisfied because the JavaScript resource does not exist, but for which there is a JSX resource (.jsx extension) with the same base name in the same directory, will be satisfied by converting the content of the JSX resource to JavaScript and providing the converted content as the content of the missing JavaScript resource. Note that the converter does not 'create' the missing JavaScript resource in the source location, but it does cache the converted content so that it can be provided more efficiently on subsequent requests for the same resource.

The JSX resource converter uses a browserified packaging of the JSXTransformer running in Rhino on the server to perform the JSX to JavaScript conversion.