No description
  • Rust 94.1%
  • JavaScript 5.9%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
gjz010's OpenCode agent 6941b95918
Add source Module Evaluate activity hook
Expose Context::is_source_module_evaluation_active(), a read-only query for
whether a source-text Module Evaluate call has not yet returned. A
Context-owned Rc<Cell<bool>> plus an RAII guard sets the flag at the real
SourceTextModule::evaluate entry and clears it on ordinary, error, early,
pending and unwind exits, without borrowing Context across JavaScript.

Also discard the temporary module link frame's operand/register stack region
after the frame is popped, since linking runs no bytecode and therefore no VM
return opcode releases it. This keeps a suspended native JS caller intact when
module linking is triggered from a callback.

Independent of Lepko's tree; this is a complete fork of boa-dev/boa at
337a3668a0. See LEPKO-SOURCE.md.
2026-10-30 21:58:16 +08:00
.cargo Remove js-related bindings for non-js wasm builds (#4528) 2025-11-09 22:15:51 +00:00
.config Cleanup and speed-up CI (#2376) 2022-10-25 11:16:52 +00:00
.github chore(deps): bump the ci-dependencies group across 1 directory with 3 updates (#5486) 2026-08-27 22:57:05 +00:00
.husky Modify boa_runtime's timers to use native timeout tracking and cancellation (#5289) 2026-05-01 01:14:32 +00:00
.vscode Cleanup CLI to use eyre + refactor patterns (#4108) 2025-01-07 03:36:57 +00:00
assets Using different logos depending on theme (#3720) 2024-03-06 17:27:30 +00:00
benches perf: use mimalloc as the global allocator on macOS (#5431) 2026-07-21 23:22:02 +00:00
cli fix(cli): return non-zero exit code on uncaught runtime exceptions (#5465) 2026-08-04 18:32:07 +00:00
core Add source Module Evaluate activity hook 2026-10-30 21:58:16 +08:00
docs docs: add NativeObject design document (#5061) 2026-03-16 23:49:57 +00:00
examples Update repo with new lints from rustc 1.97.0 and cargo update (#5427) 2026-07-16 00:30:30 +00:00
ffi/wasm Do not pull default engine features into runtime (#4879) 2026-03-06 01:24:08 +00:00
make Add minimal CI task to cargo-make (#4448) 2025-09-29 17:36:50 +00:00
tests Bump dependencies to their latest versions (#5491) 2026-08-27 21:03:49 +00:00
tools Bump ICU4X dependencies to 2.3 (#5490) 2026-08-27 17:20:32 +00:00
utils feat: add boa_wintertc crate skeleton for WinterTC compliance (#5105) 2026-03-18 13:57:07 +00:00
.editorconfig Editorconfig: specify indentation and dont overrule Makefile (#4446) 2025-09-26 16:55:14 +00:00
.gitattributes New lexer (#559) 2020-08-27 20:30:10 +02:00
.gitignore Correctly throw when DateTimeFormat receives a NaN timestamp (#4588) 2026-01-23 19:46:11 +00:00
.prettierignore Add v8 benchmarks to the criterion benches (#4569) 2025-12-19 18:59:30 +00:00
ABOUT.md feat: add boa_wintertc crate skeleton for WinterTC compliance (#5105) 2026-03-18 13:57:07 +00:00
Cargo.lock Prepare for release v0.22.0 (#5494) 2026-08-28 03:55:51 +00:00
Cargo.toml Prepare for release v0.22.0 (#5494) 2026-08-28 03:55:51 +00:00
CHANGELOG.md Prepare for release v0.22.0 (#5494) 2026-08-28 03:55:51 +00:00
clippy.toml Use cow-utils instead (#4133) 2025-01-18 17:56:24 +00:00
CODE_OF_CONDUCT.md Cleanup README.md and contributor documentation (#3909) 2024-07-10 13:31:17 +00:00
CODEOWNERS Add CODEOWNERS file (#4714) 2026-02-25 06:43:33 +00:00
CONTRIBUTING.md Allow tester to compare directories (#4544) 2025-11-25 17:15:58 +00:00
flake.lock Extend Response API (#4905) 2026-03-16 19:33:42 +00:00
flake.nix Add Nix flake (#4381) 2025-08-26 01:45:41 +00:00
LEPKO-SOURCE.md Add source Module Evaluate activity hook 2026-10-30 21:58:16 +08:00
LICENSE-MIT Added license files (#77) 2019-07-11 10:09:14 +01:00
LICENSE-UNLICENSE Added license files (#77) 2019-07-11 10:09:14 +01:00
Makefile.toml Add bytecode snapshot tests using insta crate (#4921) 2026-03-08 01:29:23 +00:00
package.json Implement JsValueStore for SharedArrayBuffer and postMessage (#4417) 2025-09-22 18:09:29 +00:00
README.md Support running test262 using boa cli (#5234) 2026-04-07 02:09:19 +00:00
SECURITY.md Cleanup README.md and contributor documentation (#3909) 2024-07-10 13:31:17 +00:00
test262_config.toml Bump dependencies to their latest versions (#5491) 2026-08-27 21:03:49 +00:00
test_wpt_config.toml Add WPT as optional tests for boa_runtime (#4008) 2025-07-07 18:20:00 +00:00
typos.toml chore(deps): bump crate-ci/typos from 1.44.0 to 1.45.0 in the ci-dependencies group (#5293) 2026-04-05 20:28:46 +00:00

Boa

Boa logo

Boa is an experimental JavaScript lexer, parser and interpreter written in Rust 🦀, it has support for more than 90% of the latest ECMAScript specification. We continuously improve the conformance to keep up with the ever-evolving standard.

Build Status codecov Crates.io Docs.rs Discord Matrix

⚡️ Live Demo (Wasm)

Try out the engine now at the live Wasm playground here!

Prefer a CLI? Feel free to try out boa_cli!

📦 Crates

Boa currently publishes and actively maintains the following crates:

  • boa_ast - Boa's ECMAScript Abstract Syntax Tree
  • boa_cli - Boa's CLI && REPL implementation
  • boa_engine - Boa's implementation of ECMAScript builtin objects and execution
  • boa_gc - Boa's garbage collector
  • boa_interner - Boa's string interner
  • boa_parser - Boa's lexer and parser
  • boa_icu_provider - Boa's ICU4X data provider
  • boa_runtime - Boa's WebAPI features
  • boa_string - Boa's ECMAScript string implementation.
  • tag_ptr - Utility library that enables a pointer to be associated with a tag of type usize.

Note

The Boa and boa_unicode crates are deprecated.

🚀 Example

To start using Boa simply add the boa_engine crate to your Cargo.toml:

[dependencies]
boa_engine = "0.21.0"

Then in main.rs, copy the below:

use boa_engine::{Context, Source, JsResult};

fn main() -> JsResult<()> {
  let js_code = r#"
      let two = 1 + 1;
      let definitely_not_four = two + "2";

      definitely_not_four
  "#;

  // Instantiate the execution context
  let mut context = Context::default();

  // Parse the source code
  let result = context.eval(Source::from_bytes(js_code))?;

  println!("{}", result.display());

  Ok(())
}

Now, all that's left to do is cargo run.

Congrats! You've executed your first JavaScript code using Boa!

🔎 Documentation

For more information on Boa's API, feel free to check out our documentation.

API Documentation

🏅 Conformance

To know more details about Boa's conformance surrounding the ECMAScript specification, you can check out our ECMAScript Test262 test suite results here.

🪚 Contributing

Please, check the CONTRIBUTING.md file to know how to contribute in the project. You will need Rust installed and an editor. We have some configurations ready for VSCode.

🐛 Debugging

Check debugging.md for more info on debugging.

🕸 Web Assembly

Important

This only applies to wasm32-unknown-unknown target, WASI and Emscripten target variants are handled automatically.

  • Enable the js feature flag.
  • Set RUSTFLAGS='--cfg getrandom_backend="wasm_js"'

The rustflags can also be set by adding a .cargo/config.toml file in the project root directory:

[target.wasm32-unknown-unknown]
rustflags = '--cfg getrandom_backend="wasm_js"'

For more information see: getrandom WebAssembly Support

⚙️ Usage

  • Clone this repo.
  • Run with cargo run -- test.js in the project root directory where test.js is a path to an existing JS file with any valid JS code.
  • If any JS doesn't work then it's a bug. Please raise an issue!

Example

Example

Command-line Options

Usage: boa [OPTIONS] [FILE]...

Arguments:
  [FILE]...  The JavaScript file(s) to be evaluated

Options:
      --strict                        Run in strict mode
  -a, --dump-ast [<FORMAT>]           Dump the AST to stdout with the given format [possible values: debug, json, json-pretty]
  -t, --trace                         Dump the AST to stdout with the given format
      --vi                            Use vi mode in the REPL
  -O, --optimize
      --optimizer-statistics
      --flowgraph [<FORMAT>]          Generate instruction flowgraph. Default is Graphviz [possible values: graphviz, mermaid]
      --flowgraph-direction <FORMAT>  Specifies the direction of the flowgraph. Default is top-top-bottom [possible values: top-to-bottom, bottom-to-top, left-to-right, right-to-left]
      --debug-object                  Inject debugging object `$boa`
      --test262-object                Inject the test262 host object `$262`
  -m, --module                        Treats the input files as modules
  -r, --root <ROOT>                   Root path from where the module resolver will try to load the modules [default: .]
  -h, --help                          Print help (see more with '--help')
  -V, --version                       Print version

🧭 Roadmap

See Milestones.

📊 Benchmarks

The current benchmarks are taken from v8's benchmark that you can find here. You can also view the results of nightly benchmark runs comparing Boa with other JavaScript engines here.

If you wish to run the benchmarks locally, then run Boa in release using the combined.js script which contains all the sub-benchmarks in the bench-v8 directory.

cargo run --release -p boa_cli -- bench-v8/combined.js

Tip

If you'd like to run only a subset of the benchmarks, you can modify the Makefile located in the bench-v8 directory. Comment out the benchmarks you don't want to include, then run make. After that, you can run Boa using the same command as above.

🧠 Profiling

See Profiling.

📆 Changelog

See CHANGELOG.md.

💬 Communication

Feel free to contact us on Matrix if you have any questions. Contributor discussions take place on the same Matrix Space if you're interested in contributing. We also have a Discord for any questions or issues.

⚖️ License

This project is licensed under the Unlicense or MIT licenses, at your option.