JS-Interpreter
JS-Interpreter copied to clipboard
acorn_interpreter.js acorn
Using the require system in BlocklyCraft/ScriptCraft, which runs in the JVM via Nashorn (OpenJDK 1.8), I can place acorn.js and interpreter.js in src/main/js/modules/, add the line var acorn = require('acorn'); to L25 of interpreter.js, and everything works like a charm. I can require('interpreter'); elsewhere and things work well.
However, if I attempt to place acorn_interpreter.js in the modules directory and then attempt to require that, I get an acorn is not defined error (as per the stacktrace below) when I create a new interpreter object. The error does not replicate in browsers, where acorn_interpreter.js works fine. So I'm curious as to what could cause this! Any ideas?
This issue is not at all important, so feel free to ignore it unless you're also curious.
[15:41:52 WARN]: [scriptcraft] Task #6 for scriptcraft v3.2.0-2016-06-28 generated an exception
jdk.nashorn.internal.runtime.ECMAException: ReferenceError: "acorn" is not defined
at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:319) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:291) ~[nashorn.jar:?]
at jdk.nashorn.internal.objects.Global.__noSuchProperty__(Global.java:1428) ~[nashorn.jar:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$399$29046AA$\^eval\_.L:1$Interpreter(<eval>:41) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$398$742A$\^eval\_.L:1$get_interpreter(<eval>:25) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$386$573A$\^eval\_.L:1$run_scripts(<eval>:20) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$385$409A$\^eval\_.L:1$L:13(<eval>:15) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$384$3676A$\^eval\_.L:1$fileWatcher(<eval>:152) ~[?:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$200$4801$\^eval\_.L:1$monitorDirAndFiles(<eval>:184) ~[?:?]
at jdk.nashorn.javaadapters.java.lang.Runnable.run(Unknown Source) ~[?:?]