Hi, I would like to run some server side react.js components in Sling. I was experimenting with the esx engine [1] which works like a NodeJs loader and allows you to load any valid Node module. I am able to run the demo examples that come with that bundle. So, I installed react npm module and it’s dependencies under /libs/esx/node_modules. But when I try to load react based script in sling I get an exception at [2]. I see “process” properties declared in SlingBabel.js and when I debug I see that the transpile step works for my initial script (one sling:resourceType points to).
I know this esx engine is considered experimental according to JIRA ticket [3]. But I was still curious if anyone else has tried this or can help out. If I can successfully load react I would like to work on some tests suggested in JIRA and see if I can contribute to this module. Therefor I thought it appropriate to send this to dev list. I apologize in advance for spam if that’s not correct. Regards, Henry [1] https://github.com/apache/sling/tree/trunk/contrib/scripting/esx <https://github.com/apache/sling/tree/trunk/contrib/scripting/esx> [2] jdk.nashorn.internal.runtime.ECMAException: ReferenceError: "process" is not defined at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57) at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:319) at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:291) at jdk.nashorn.internal.objects.Global.__noSuchProperty__(Global.java:1441) at jdk.nashorn.internal.scripts.Script$Recompilation$39714$173AAAAAAAAAA$warning.L:2(/libs/esx/node_modules/fbjs/lib/warning.js:25) at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:651) at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494) at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393) at jdk.nashorn.api.scripting.ScriptObjectMirror.call(ScriptObjectMirror.java:117) at org.apache.sling.scripting.esx.Module.runScript(Module.java:249) at org.apache.sling.scripting.esx.Module.require(Module.java:670) at jdk.nashorn.internal.scripts.Script$Recompilation$39711$349A$ReactNoopUpdateQueue.L:2#require(/libs/esx/node_modules/react/lib/ReactNoopUpdateQueue.js:2) at jdk.nashorn.internal.scripts.Script$Recompilation$39710$187AAAAAAAAAA$ReactNoopUpdateQueue.L:2(/libs/esx/node_modules/react/lib/ReactNoopUpdateQueue.js:14) at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:651) at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494) at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393) at jdk.nashorn.api.scripting.ScriptObjectMirror.call(ScriptObjectMirror.java:117) at org.apache.sling.scripting.esx.Module.runScript(Module.java:249) at org.apache.sling.scripting.esx.Module.require(Module.java:670) at jdk.nashorn.internal.scripts.Script$Recompilation$39704$345A$ReactBaseClasses.L:2#require(/libs/esx/node_modules/react/lib/ReactBaseClasses.js:2) at jdk.nashorn.internal.scripts.Script$Recompilation$39703$183AAAAAAAAAA$ReactBaseClasses.L:2(/libs/esx/node_modules/react/lib/ReactBaseClasses.js:17) at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627) at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:651) at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494) at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393) at jdk.nashorn.api.scripting.ScriptObjectMirror.call(ScriptObjectMirror.java:117) at org.apache.sling.scripting.esx.Module.runScript(Module.java:249) at org.apache.sling.scripting.esx.Module.require(Module.java:670) at jdk.nashorn.internal.scripts.Script$Recompilation$39696$334A$React.L:2#require(/libs/esx/node_modules/react/lib/React.js:2) at jdk.nashorn.internal.scripts.Script$Recompilation$39695$172AAAAAAAAAA$React.L:2(/libs/esx/node_modules/react/lib/React.js:16) [3] https://issues.apache.org/jira/browse/SLING-6680 <https://issues.apache.org/jira/browse/SLING-6680>