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
Copy file name to clipboardExpand all lines: docs/user/Options.md
+14-3Lines changed: 14 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,10 @@ js -e 'print(1+2);'
19
19
```shell
20
20
js -f myfile.js
21
21
```
22
+
*`--module FILE`: load and execute the provided module file. Note that `.mjs` files are treated as modules by default.
23
+
```shell
24
+
js --module myfile.mjs
25
+
```
22
26
*`--version`: print the version information of GraalVM JavaScript, then exit.
23
27
*`--strict`: execute the engine in JavaScript's _strict mode_.
24
28
@@ -27,21 +31,21 @@ js -f myfile.js
27
31
There are several options to configure the behavior of the GraalVM JavaScript engine.
28
32
Depending on how the engine is started, the options can be passed either to the launcher or programmatically.
29
33
30
-
For a full list of options of the JavaScript engine, pass the `--help:js` flag to the `js` launcher (available from GraalVM 22.1., for older releases use `--help:languages`).
34
+
For a full list of options of the JavaScript engine, pass the `--help:js` flag to the `js` launcher (available from GraalVM 22.1, for older releases use `--help:languages`).
31
35
To include internal options, use `--help:js:internal`.
32
36
Note that those lists both include stable, supported options and experimental options.
33
37
34
38
### Provide Options to the Launcher
35
39
To the launcher, the options are passed with `--js.<option-name>=<value>`:
36
40
```shell
37
-
js --js.ecmascript-version=6
41
+
js --js.ecmascript-version=2015
38
42
```
39
43
40
44
### Provide Options Programmatically Using the Context API
41
45
When started from Java using GraalVM's Polyglot API, the options are passed programmatically to the `Context` object:
42
46
```java
43
47
Context context =Context.newBuilder("js")
44
-
.option("js.ecmascript-version", "6")
48
+
.option("js.ecmascript-version", "2015")
45
49
.build();
46
50
context.eval("js", "42");
47
51
```
@@ -65,6 +69,10 @@ The following stable options are frequently relevant:
65
69
*`--js.intl-402`: enable ECMAScript Internationalization API. Boolean value, default is `true`.
66
70
*`--js.regexp-static-result`: provide static `RegExp` properties containing the results of the last successful match, e.g., `RegExp.$1` (legacy). Boolean value, default is `true`.
67
71
*`--js.strict`: enable strict mode for all scripts. Boolean value, default is `false`.
72
+
*`--js.console`: enable the `console` global property. Boolean value, default is `true`.
73
+
*`--js.allow-eval`: allow the code generation from strings, e.g. using `eval()` or the `Function` constructor. Boolean value, default is `true`.
74
+
*`--js.timer-resolution`: sets the resolution of timing functions, like `Date.now()` and `performance.now()`, in nanoseconds. Default: `1000000` (i.e. 1 ms).
75
+
*`--js.unhandled-rejections`: configure unhandled promise rejection tracking. Accepted values are `none` (default, no tracking), `warn` (print a warning to stderr), `throw` (throw an exception), and `handler` (invoke a custom handler).
68
76
69
77
For a complete list, use `js --help:js:internal`
70
78
@@ -108,3 +116,6 @@ To use them, the `--experimental-options` flag is required or the experimental o
108
116
*`--js.nashorn-compat`: provide compatibility mode with the Nashorn engine. Sets ECMAScript version to 5 by default. Might conflict with newer ECMAScript versions. Boolean value, default is `false`.
109
117
*`--js.timezone`: set the local time zone. String value, default is the system default.
110
118
*`--js.v8-compat`: provide better compatibility with Google's V8 engine. Boolean value, default is `false`.
119
+
*`--js.esm-eval-returns-exports`: `context.eval` of an ES module `Source` returns its exported symbols.
0 commit comments