in src/main/java/org/apache/sling/scripting/esx/services/impl/ScriptSandboxServiceImpl.java [73:103]
protected void activate(ComponentContext context) {
try {
this.slingBabelSource = "//@sourceURL=" + getClass().getCanonicalName() + "\n load( { name : \"" + getClass().getCanonicalName() + "\", script: \""
+ StringEscapeUtils.escapeEcmaScript(new String(IOUtils.toByteArray(
context.getBundleContext().getBundle()
.getEntry(this.SLING_BABEL_SOURCE_CODE).openStream())))
+ "\"} )";
} catch (Exception ex) {
log.error("failed to load babel source", ex);
}
String options = "var config = { "
+ " presets: [\"es2015\"], "
+ " compact: 'true',"
+ " plugins: [[\"transform-react-jsx\", { pragma : \"SlingEsx.createElement\"}]] "
//+ // disabled sandbox plugin for
//" \"plugins\": [\"SlingSandbox, [\"transform-react-jsx\", { \"pragma\" : \"SlingEsx.createElement\"}]] \n" +
+ " }";
NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
this.scriptEngine = factory.getScriptEngine();
try {
log.info("trying to load babel into the system");
this.scriptEngine.eval(options);
this.babelOptions = this.scriptEngine.get("config");
scriptEngine.eval(slingBabelSource);
this.babel = this.scriptEngine.get("SlingBabel");
log.info("Babel loaded");
} catch (ScriptException ex) {
log.error("coudlnt load babel options", ex);
}
}