You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it currently possible to instrument ES6 code using mx? I know both NodeProf and GraalJS support ES6, but I'm not sure how to actually achieve this with mx.
Here's an example:
one.js
import{add}from"./two";console.log(add(1,2));
two.js
functionadd(x,y){returnx+y;}export{add};
Execution
❯ mx jalangi --analysis ./src/ch.usi.inf.nodeprof/js/analysis/trivial/emptyTemplate.js one.js
<function>:1
import { add } from "./two";
^
SyntaxError: Expected an operand but found import
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.<anonymous> (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function._load (internal/modules/cjs/loader.js:585:3)
at Function.runMain (internal/modules/cjs/loader.js:831:12)
at Object.<anonymous> (/home/mwaldrich/tmp/19-06-27-nodeprof-expr/19-02-21-clean/workspace-nodeprof/nodeprof.js/src/ch.usi.inf.nodeprof/js/jalangi.js:251:19)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.<anonymous> (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
GraalJS argument
I also found this page in the GraalJS docs that show the js.ecmascript-version argument. I tried using this with mx, but it didn't help.
❯ mx jalangi --analysis ./src/ch.usi.inf.nodeprof/js/analysis/trivial/emptyTemplate.js one.js --js.ecmascript-version=6
<function>:1
import { add } from "./two";
^
SyntaxError: Expected an operand but found import
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.<anonymous> (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function._load (internal/modules/cjs/loader.js:585:3)
at Function.runMain (internal/modules/cjs/loader.js:831:12)
at Object.<anonymous> (/home/mwaldrich/tmp/19-06-27-nodeprof-expr/19-02-21-clean/workspace-nodeprof/nodeprof.js/src/ch.usi.inf.nodeprof/js/jalangi.js:251:19)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.<anonymous> (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
The text was updated successfully, but these errors were encountered:
mx jalangi uses node as the entrypoint for execution (note there is a difference in GraalVM between running pure JS mx js and Node mx node), thus you need to enable experimental support for ES modules in Node.js with an option (also in Node 10.x files must end with .mjs): https://nodejs.org/docs/latest-v10.x/api/esm.html
mx jalangi currently does not pass through node command line options, but you can inject them yourself.
To see what's happening under the hood run mx -v jalangi --analysis foo.js bar.mjs
You'll see the last line starts with env:
Is it currently possible to instrument ES6 code using
mx
? I know both NodeProf and GraalJS support ES6, but I'm not sure how to actually achieve this withmx
.Here's an example:
one.js
two.js
Execution
GraalJS argument
I also found this page in the GraalJS docs that show the
js.ecmascript-version
argument. I tried using this withmx
, but it didn't help.The text was updated successfully, but these errors were encountered: