Options

Running JavaScript on GraalVM can be configured with several options.

GraalVM JavaScript Launcher Options

These options are to control the behaviour of the js launcher:

GraalVM JavaScript Engine Options

These options are to configure the behavior of the GraalVM JavaScript engine. Depending on how the engine is started, the options can be passed either to the launcher or programmatically.

Note that most of these options are experimental and require an --experimental-options flag.

To the Launcher

To the launcher, the options are passed with --js.<option-name>=<value>:

js --js.ecmascript-version=6

The following options are currently available:

Programmatically

When started from Java via GraalVM’s Polyglot feature, the options are passed programmatically to the Context object:

Context context = Context.newBuilder("js")
                         .option("js.ecmascript-version", "6")
                         .build();
context.eval("js", "42");

See the Polyglot Programming reference for information on how to set options programmatically.

Stable and Experimental Options

The available options are distinguished in stable and experimental options. If an experimental option is used, an extra flag has to be provided upfront.

In the native launchers (js and node), --experimental-options has to be passed before all experimental options. When using a Context, the option allowExperimentalOptions(true) has to be called on the Context.Builder. See ScriptEngine Implementation on how to use experimental options with a ScriptEngine.

ECMAScript Version

This option provides compatibility to a specific version of the ECMAScript specification. It expects an integer value, where both the counting version numbers (5 to 11) and the publication years (starting from 2015) are supported. The default in the development version of GraalVM is the current draft of the specification, currently the ECMAScript 2021 draft specification. Thus, starting with GraalVM 21.0.0, the default will move to the draft ECMAScript 2021 specification. GraalVM JavaScript implements some features of the future draft specification and of open proposals, if you explicitly select that version and/or enable specific experimental flags. For production settings, it is recommended to set the ecmascript-version to an existing, finalized version of the specification.

Available versions are:

intl-402

This option enables ECMAScript’s Internationalization API. It expects a Boolean value and the default is false.

Strict Mode

This option enables JavaScript’s strict mode for all scripts. It expects a Boolean value and the default is false.