org.graalvm.js:js-scriptengine

Graal JavaScript ScriptEngine


Keywords
graalvm, java, javascript, nodejs
Licenses
UPL-1.0/SSPL-1.0

Documentation

https://graalvm.slack.com

A high performance implementation of the JavaScript programming language. Built on the GraalVM by Oracle Labs.

The goals of GraalVM JavaScript are:

Getting Started

The preferred way to run GraalVM JavaScript (a.k.a. GraalJS) is from a GraalVM. As of GraalVM for JDK 21, (23.1), GraalVM JavaScript and Node.js runtimes are available as standalone distributions and Maven artifacts (but no longer as GraalVM components). See the documentation on the GraalVM website for more information on how to set up GraalVM JavaScript.

Standalone Distribution

To install GraalVM JavaScript using the [standalone distribution], simply download and extract the desired archive from the GitHub Releases page. The standalone archives for the JavaScript and Node.js distributions are named graaljs[-community][-jvm]-<version>-<os>-<arch>.tar.gz and graalnodejs[-community][-jvm]-<version>-<os>-<arch>.tar.gz, respectively. Four different available configurations are available for each component and platform combination:

Runtime License Archive Infix
Native GFTC none
JVM GFTC -jvm
Native UPL -community
JVM UPL -community-jvm

After installation, the js or node executable in the bin subdirectory can be used to run JavaScript files or Node modules, respectively. If no file is provided on the command line, an interactive shell (REPL) will be spawned.

Maven Artifact

All required artifacts for embedding GraalVM JavaScript can be found in the Maven dependency group org.graalvm.polyglot.

Here is a minimal Maven dependency setup that you can copy into your pom.xml:

<dependency>
	<groupId>org.graalvm.polyglot</groupId>
	<artifactId>polyglot</artifactId>
	<version>23.1.0</version>
</dependency>
<dependency>
	<groupId>org.graalvm.polyglot</groupId>
	<artifactId>js</artifactId>
	<version>23.1.0</version>
	<type>pom</type>
</dependency>
<!-- add additional languages and tools, if needed -->

See the polyglot embedding demonstration on GitHub for a complete runnable example.

Language and tool dependencies use the GraalVM Free Terms and Conditions (GFTC) license by default. To use community-licensed versions instead, add the -community suffix to each language and tool dependency, e.g.:

<dependency>
	<groupId>org.graalvm.polyglot</groupId>
	<artifactId>js-community</artifactId>
	<version>23.1.0</version>
	<type>pom</type>
</dependency>

To access polyglot isolate artifacts (GFTC only), use the -isolate suffix instead (e.g. js-isolate).

If you prefer running it on a stock JVM, please have a look at the documentation in RunOnJDK.md. Note that in this mode many features and optimizations of GraalVM are not available. Due to those limitations, running on a stock JVM is not a supported feature - please use a GraalVM instead.

Documentation

Extensive documentation is available on graalvm.org: see Getting Started and the more extensive JavaScript and Node.js Reference Manual. In addition, there is documentation in the source code repository in the docs directory, for users and contributors.

For contributors, a guide how to build GraalVM JavaScript from source code can be found in Building.md.

Current Status

GraalVM JavaScript is compatible with the ECMAScript 2023 specification. New features, e.g. ECMAScript proposals scheduled to land in future editions, are added frequently and are accessible behind a flag. See the CHANGELOG.md for the proposals already adopted.

In addition, some popular extensions of other engines are supported, see JavaScriptCompatibility.md.

Node.js support

GraalVM JavaScript can execute Node.js applications. It provides high compatibility with existing npm packages, with high likelihood that your application will run out of the box. This includes npm packages with native implementations. Note that some npm modules will require to be re-compiled from source with GraalVM JavaScript if they ship with binaries that have been compiled for Node.js based on V8. Node.js is a separate standalone distribution.

Compatibility on Operating Systems

The core JavaScript engine is a Java application and is thus in principle compatible with every operating system that provides a compatible JVM, see RunOnJDK.md. We provide binary distributions and fully support GraalVM JavaScript on Linux (AMD64, AArch64), MacOS (AMD64, AArch64), and Windows (AMD64), currently.

GraalVM JavaScript Reference Manual

A reference manual for GraalVM JavaScript is available on the GraalVM website.

Stay connected with the community

See graalvm.org/community on how to stay connected with the development community. The channel graaljs on graalvm.slack.com is a good way to get in touch with us. Please report JavaScript-specific issues on the oracle/graaljs GitHub repository.

License

GraalVM JavaScript source code and community distributions are available under the following license:

Non-community artifacts are provided under the following license: