jroc 0.11.2
dotnet tool install --global jroc --version 0.11.2
dotnet new tool-manifest
dotnet tool install --local jroc --version 0.11.2
#tool dotnet:?package=jroc&version=0.11.2
nuke :add-package jroc --version 0.11.2
jroc – JavaScript .NET compiler (consumer guide)
jroc is a JavaScript to .NET compiler, available as a .NET global tool. It compiles JavaScript source code to native .NET assemblies you can run on .NET.
Install
- Prerequisite: .NET 10 SDK or later installed.
- Install the tool globally:
dotnet tool install --global jroc
Update later:
dotnet tool update --global jroc
Uninstall:
dotnet tool uninstall --global jroc
Which package should I use?
jroc- The global CLI tool for ad-hoc/manual JavaScript compilation from a terminal.
Jroc.SDK- The MSBuild/NuGet integration for host projects that should compile JavaScript during
dotnet build.
- The MSBuild/NuGet integration for host projects that should compile JavaScript during
Jroc.Core- The reusable compiler library for custom tooling, build tasks, or other programmatic .NET integration.
Jroc.Runtime- The runtime support library used by generated assemblies and .NET hosting scenarios.
Official releases publish Jroc.Runtime, jroc, Jroc.Core, and Jroc.SDK together at the same version. When you mix these packages in one workflow, keep the versions aligned.
Usage
jroc <InputFile> [<OutputPath>] [options]
Options
- -i, --input The JavaScript file to convert (positional supported)
- -o, --output Output folder for the generated IL/assembly (created if missing; defaults to the input file directory)
- -v, --verbose Print compiler diagnostics to the console
- --diagnostic-file <path> Write compiler diagnostics to a text file
- -a, --analyzeunused Report unused functions/properties/variables --version Show version information and exit
Help: -h, --help, -?
Example:
# Convert tests\simple.js and write output next to the file
jroc .\tests\simple.js
# Convert to a specific directory with verbose output
jroc .\tests\simple.js -o .\out -v
What gets generated?
Given an input like C:\code\sample.js, jroc will emit the following into the output directory (default: alongside the input file):
sample.dll- A .NET assembly (targeting net10.0) containing IL corresponding to your JavaScript.
- The assembly name is the input file name without extension.
- Contains a
Program.Mainentry point that executes your script when run.
sample.runtimeconfig.json- Runtime configuration for the
dotnethost (framework: .NET 10).
- Runtime configuration for the
JavaScriptRuntime.dll(+ optionalJavaScriptRuntime.pdbif available)- Required runtime support library that provides JS primitives (e.g.,
console.log, arrays, objects) used by the emitted IL. - This file is copied next to your generated assembly and must be present at runtime.
- Required runtime support library that provides JS primitives (e.g.,
Run it with:
dotnet .\sample.dll
Notes:
- Console output (e.g.,
console.log) is implemented via the bundledJavaScriptRuntime.dll. - This is a prototype and doesn’t yet support all JavaScript features. See the repo docs for supported syntax and feature coverage.
- Errors are written to stderr and known failures return a non-zero exit code.
Limitations
- Target framework: net10.0
- Not all JS features are supported; some constructs may be validated and rejected with explanations.
- Emitted IL and runtime surface are subject to change between previews.
Troubleshooting
- Ensure the .NET 10 SDK/runtime is on PATH:
dotnet --info - Use
-vto print diagnostics to the console, or--diagnostic-file <path>to capture diagnostics to a file. - File an issue with a minimal JS sample if you suspect a bug.
Hosting samples
The jroc tool package no longer carries the hosted C# samples. Those samples now ship with Jroc.SDK, because they are intended to validate the MSBuild/NuGet integration path that hosting consumers use in real projects.
See:
- the repo
samples\directory Jroc.SDKpackage page:https://www.nuget.org/packages/Jroc.SDKJroc.Corepackage page:https://www.nuget.org/packages/Jroc.Core
Links
- SDK (.NET library mode): https://github.com/tomacox74/jroc/blob/master/docs/sdk/Index.md
- Source, issues, docs: https://github.com/tomacox74/jroc
- License: Apache-2.0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.