graaljs
graaljs copied to clipboard
Run code before launching REPL
On Node.js, I can run JavaScript code before the interactive is launched by using --i
in conjunction with --eval
. If such a feature is not already available with the GraalVM JavaScript shell, then it should be added.
Hi @Melab. Do you mean like this?
xxx@xxx-mac ~ % java -version
openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment GraalVM CE 21.3.0 (build 11.0.13+7-jvmci-21.3-b05)
OpenJDK 64-Bit Server VM GraalVM CE 21.3.0 (build 11.0.13+7-jvmci-21.3-b05, mixed mode, sharing)
xxx@xxx-mac ~ % node -v
v14.17.6
xxx@xxx-mac ~ % node -i --eval="console.log('hello')"
Welcome to Node.js v14.17.6.
Type ".help" for more information.
> hello
>
>
(To exit, press Ctrl+C again or Ctrl+D or type .exit)
>
If that is the case, please double check you cannot access that feature, and share the graalvm version and OS you are using. Otherwise, please elaborate more of what are you expecting.
Hi @Melab. Do you mean like this?
xxx@xxx-mac ~ % java -version openjdk version "11.0.13" 2021-10-19 OpenJDK Runtime Environment GraalVM CE 21.3.0 (build 11.0.13+7-jvmci-21.3-b05) OpenJDK 64-Bit Server VM GraalVM CE 21.3.0 (build 11.0.13+7-jvmci-21.3-b05, mixed mode, sharing) xxx@xxx-mac ~ % node -v v14.17.6 xxx@xxx-mac ~ % node -i --eval="console.log('hello')" Welcome to Node.js v14.17.6. Type ".help" for more information. > hello > > (To exit, press Ctrl+C again or Ctrl+D or type .exit) >
If that is the case, please double check you cannot access that feature, and share the graalvm version and OS you are using. Otherwise, please elaborate more of what are you expecting.
Yes, @rodrigar-mx, like that. I am not using Graal-Node.
Hi,
I assume you mean we should add the --i
flag to the graalvm/bin/js
binary and allow to use --eval
and the interactive REPL in collaboration?
That sounds like a reasonable addition to the codebase. However, improvements to the js
REPL are pretty low on our priorities list - if you need that feature, you can always just use the node
binary, right?
-- Christian
Hi,
I assume you mean we should add the
--i
flag to thegraalvm/bin/js
binary and allow to use--eval
and the interactive REPL in collaboration?That sounds like a reasonable addition to the codebase. However, improvements to the
js
REPL are pretty low on our priorities list - if you need that feature, you can always just use thenode
binary, right?-- Christian
Yes. A way to execute script code before launching the REPL. Node offers command line options for:
- preloading modules (in the case of GraalVM JavaScript, it should be expanded to non-module files) before running a file or launching the REPL.
- evaluating code passed a command line parameter prior to launching the REPL (ideally, GraalVM JavaScript would also allow this to be done before running a file, not just the REPL).