Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .devcontainer/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ node_modules
*.dump
coverage

.ninja_log
.bsdeps
.bsbuild
lib/ocaml
tests/build_tests/*/lib/
#ignore temporary directory
Expand Down Expand Up @@ -94,6 +91,3 @@ tests/analysis_tests/**/*.bs.js
# package tarballs
package.tgz
*.exe

/ninja/ninja
/ninja/build.ninja
2 changes: 0 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ LABEL org.opencontainers.image.description="Docker image for ReScript developmen
RUN sudo apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
cmake \
ninja-build \
musl-tools \
python-is-python3 \
&& rm -rf /var/lib/apt/lists/*

# Install OPAM
Expand Down
37 changes: 0 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,43 +296,6 @@ jobs:
- name: Copy compiler exes to platform bin dir
run: node scripts/copyExes.js --compiler

- name: Restore ninja build cache
id: ninja-build-cache
uses: actions/cache@v5
with:
path: ninja/ninja${{ matrix.exe-suffix }}
key: ninja-build-v2-${{ matrix.os }}-${{ hashFiles('ninja/src/**') }}

- name: Setup Python for ninja build
if: steps.ninja-build-cache.outputs.cache-hit != 'true'
uses: actions/setup-python@v6
with:
python-version: "3.13"

- name: Setup MSVC for ninja build (Windows)
if: steps.ninja-build-cache.outputs.cache-hit != 'true' && runner.os == 'Windows'
uses: TheMrMilchmann/setup-msvc-dev@v4
with:
arch: x64

- name: Build ninja
if: steps.ninja-build-cache.outputs.cache-hit != 'true' && runner.os != 'Linux'
run: node scripts/buildNinjaBinary.js

- name: Build ninja (Linux static)
if: steps.ninja-build-cache.outputs.cache-hit != 'true' && runner.os == 'Linux'
env:
LDFLAGS: -static
run: node scripts/buildNinjaBinary.js

# Prevent ninja being rebuilt on playground build step later
- name: Touch ninja/ninja
if: ${{ matrix.build_playground && steps.ninja-build-cache.outputs.cache-hit == 'true' }}
run: touch ninja/ninja${{ matrix.exe-suffix }}

- name: Copy ninja exe to platform bin dir
run: node scripts/copyExes.js --ninja

- name: "Syntax: Run tests"
env:
ROUNDTRIP_TEST: ${{ runner.os == 'Windows' && '0' || '1' }}
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ node_modules
*.dump
coverage

.ninja_log
.bsdeps
.bsbuild
lib/ocaml
tests/build_tests/*/lib/
#ignore temporary directory
Expand Down
14 changes: 2 additions & 12 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ The Makefile’s targets build on each other in this order:

1. `yarn-install` runs automatically for targets that need JavaScript tooling (lib, playground, tests, formatting, etc.).
2. `build` (default target) builds the toolchain binaries (all copied into `packages/@rescript/<platform>/bin`):
- `compiler` builds the dune executables (`bsc`, `bsb_helper`, `rescript-*`, `ounit_tests`, etc.).
- `compiler` builds the dune executables (`bsc`, `rescript-*`, `ounit_tests`, etc.).
- `rewatch` builds the Rust-based ReScript build system and CLI.
- `ninja` bootstraps the ninja binary (part of the legacy build system).
3. `lib` uses those toolchain outputs to build the runtime sources.
4. Test targets (`make test`, `make test-syntax`, etc.) reuse everything above.

Expand Down Expand Up @@ -82,7 +81,6 @@ compiler/
├── ml/ # OCaml compiler infrastructure
├── core/ # Core compilation (lam_*, js_* files)
├── ext/ # Extended utilities and data structures
├── bsb/ # Legacy build system
└── gentype/ # TypeScript generation

analysis/ # Language server and tooling
Expand Down Expand Up @@ -254,7 +252,6 @@ The compiler is designed for fast feedback loops and scales to large codebases:
- **Build System**: dune with profiles (dev, release, browser)
- **JavaScript**: Node.js 20+ for tooling
- **Rust**: Toolchain needed for rewatch
- **Python**: 3 required for building ninja

## Common Tasks

Expand Down Expand Up @@ -283,7 +280,7 @@ The compiler is designed for fast feedback loops and scales to large codebases:

### Rewatch Architecture

Rewatch is the modern build system written in Rust that replaces the legacy bsb (BuckleScript) build system. It provides faster incremental builds, better error messages, and improved developer experience.
Rewatch is ReScript's build system written in Rust. It provides fast incremental builds, better error messages, and improved developer experience.

#### Key Components

Expand Down Expand Up @@ -410,13 +407,6 @@ When clippy suggests refactoring that could impact performance, consider the tra

- **Avoid Unnecessary Type Conversions**: When threading parameters through multiple function calls, use consistent types (e.g., `String` throughout) rather than converting between `String` and `&str` at each boundary. This eliminates unnecessary allocations and conversions.

#### Compatibility with Legacy bsb

- **Command-line Flags**: Maintain compatibility with bsb flags where possible
- **Configuration**: Support both old (`bs-*`) and new field names
- **Output Format**: Generate compatible build artifacts
- **Error Messages**: Provide clear migration guidance

### Common Tasks

#### Adding New CLI Flags
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#### :boom: Breaking Change

- Remove the legacy build system. Going forward, only the modern build system is supported, and the `rescript-legacy` command is not available anymore. https://github.com/rescript-lang/rescript/pull/8186
- `Int.fromString` and `Float.fromString` use stricter number parsing and no longer uses an explicit radix argument, but instead supports parsing hexadecimal, binary and exponential notation.
- Remove `external-stdlib` configuration option from `rescript.json`. This option was rarely used and is no longer supported.

Expand Down
12 changes: 3 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Happy hacking!
- [Node.js](https://nodejs.org/) v22.x or newer
- [Yarn CLI](https://yarnpkg.com/getting-started/install) (can be installed with `corepack`, Homebrew, etc)
- C compiler toolchain (usually installed with `xcode` on Mac)
- Python <= 3.11 (required to build ninja)
- Rust toolchain (required to build rewatch; follow the instructions at https://www.rust-lang.org/tools/install and install the version listed as `rust-version` in `rewatch/Cargo.toml`)
- `opam` (OCaml Package Manager) v2.2.0 or newer
- VSCode (+ [OCaml Platform Extension](https://marketplace.visualstudio.com/items?itemName=ocamllabs.ocaml-platform))
Expand Down Expand Up @@ -103,12 +102,10 @@ You can also open this dev container with [GitHub Codespaces](https://github.com

## Building the Compiler

To build the compiler, the build tools (rewatch and ninja), and the ReScript runtime/standard library, just run:

Main targets:

```sh
# Build the compiler and the build tools (rewatch and ninja)
# Build the compiler and the build system (rewatch)
make

# Build the runtime/standard library
Expand All @@ -127,9 +124,6 @@ make compiler
# Build rewatch only
make rewatch

# Build the ninja tool only
make ninja

# Run syntax tests
make test-syntax

Expand Down Expand Up @@ -230,10 +224,10 @@ node scripts/test.js -mocha

**Run build system test (integration tests):**

This will run the whole build system test suite defined in `tests/build_tests`.
This will run the build system test suite defined in `tests/build_tests`.

```
node scripts/test.js -bsb
node scripts/test.js -build
```

**Run ounit tests:**
Expand Down
4 changes: 0 additions & 4 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ This file was imported but changed significantly in iterations later.

ReScript compiler unit test builds on [OUnit](http://ounit.forge.ocamlcore.org/)

## Ninja

Thanks to [ninja-build](https://ninja-build.org), ReScript also comes with a blazing fast build tool on top of it, `ninja` is a truly [well engineered](http://aosabook.org/en/posa/ninja.html) scalable build tool.

## Bloomberg and Facebook

Thanks to [Bloomberg](https://www.techatbloomberg.com) and [Facebook](https://github.com/facebook/). This project began at Bloomberg and was published in 2016; without the support of Bloomberg, it would not have happened. This project's funded by Facebook since July 2017.
41 changes: 11 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ RUNTIME_BUILD_STAMP := packages/@rescript/runtime/.buildstamp

# Default target

build: compiler rewatch ninja
build: compiler rewatch

# Yarn

Expand All @@ -72,25 +72,6 @@ $(YARN_INSTALL_STAMP): $(YARN_INSTALL_SOURCES)
yarn install
touch $@

# Ninja

NINJA_SOURCES = $(wildcard ninja/src/*.cc ninja/src/*.h) $(wildcard ninja/*.py)
NINJA_EXE = $(BIN_DIR)/ninja.exe

ninja: $(NINJA_EXE)

ninja/ninja: $(NINJA_SOURCES)
ifeq ($(OS),Darwin)
export CXXFLAGS="-flto"
endif
cd ninja && python3 configure.py --bootstrap --verbose

$(NINJA_EXE): ninja/ninja
$(call COPY_EXE,$<,$@)

clean-ninja:
rm -rf $(NINJA_EXE) ninja/build.ninja ninja/build ninja/misc/__pycache__ ninja/ninja

# Rewatch

REWATCH_SOURCES = $(shell find rewatch/src -name '*.rs') rewatch/Cargo.toml rewatch/Cargo.lock rewatch/rust-toolchain.toml
Expand Down Expand Up @@ -119,7 +100,7 @@ clean-rewatch:

COMPILER_SOURCE_DIRS := compiler tests analysis tools
COMPILER_SOURCES = $(shell find $(COMPILER_SOURCE_DIRS) -type f \( -name '*.ml' -o -name '*.mli' -o -name '*.dune' -o -name dune -o -name dune-project \))
COMPILER_BIN_NAMES := bsc bsb_helper rescript-legacy rescript-editor-analysis rescript-tools
COMPILER_BIN_NAMES := bsc rescript-editor-analysis rescript-tools
COMPILER_EXES := $(addsuffix .exe,$(addprefix $(BIN_DIR)/,$(COMPILER_BIN_NAMES)))
COMPILER_DUNE_BINS := $(addsuffix $(PLATFORM_EXE_EXT),$(addprefix $(DUNE_BIN_DIR)/,$(COMPILER_BIN_NAMES)))

Expand Down Expand Up @@ -166,20 +147,20 @@ artifacts: lib
bench: compiler
$(DUNE_BIN_DIR)/syntax_benchmarks

test: lib ninja
test: lib
node scripts/test.js -all

test-analysis: lib ninja
test-analysis: lib
make -C tests/analysis_tests clean test

test-reanalyze: lib ninja
test-reanalyze: lib
make -C tests/analysis_tests/tests-reanalyze/deadcode test

# Benchmark reanalyze on larger codebase (COPIES=N for more files)
benchmark-reanalyze: lib ninja
benchmark-reanalyze: lib
make -C tests/analysis_tests/tests-reanalyze/deadcode-benchmark benchmark COPIES=$(or $(COPIES),50)

test-tools: lib ninja
test-tools: lib
make -C tests/tools_tests clean test

test-syntax: compiler
Expand All @@ -188,7 +169,7 @@ test-syntax: compiler
test-syntax-roundtrip: compiler
ROUNDTRIP_TEST=1 ./scripts/test_syntax.sh

test-gentype: lib ninja
test-gentype: lib
make -C tests/gentype_tests/typescript-react-example clean test
make -C tests/gentype_tests/stdlib-no-shims clean test

Expand Down Expand Up @@ -217,7 +198,7 @@ $(PLAYGROUND_BUILD_STAMP): $(COMPILER_SOURCES)
# Creates all the relevant core and third party cmij files to side-load together with the playground bundle
playground-cmijs: $(PLAYGROUND_CMI_BUILD_STAMP)

$(PLAYGROUND_CMI_BUILD_STAMP): $(RUNTIME_BUILD_STAMP) $(NINJA_EXE)
$(PLAYGROUND_CMI_BUILD_STAMP): $(RUNTIME_BUILD_STAMP)
yarn workspace playground build

playground-test: playground
Expand All @@ -244,11 +225,11 @@ clean-gentype:

clean-tests: clean-gentype

clean: clean-lib clean-compiler clean-rewatch clean-ninja
clean: clean-lib clean-compiler clean-rewatch

dev-container:
docker build -t rescript-dev-container docker

.DEFAULT_GOAL := build

.PHONY: yarn-install build ninja rewatch compiler lib artifacts bench test test-analysis test-reanalyze benchmark-reanalyze test-tools test-syntax test-syntax-roundtrip test-gentype test-rewatch test-all playground playground-compiler playground-test playground-cmijs playground-release format checkformat clean-ninja clean-rewatch clean-compiler clean-lib clean-gentype clean-tests clean dev-container
.PHONY: yarn-install build rewatch compiler lib artifacts bench test test-analysis test-reanalyze benchmark-reanalyze test-tools test-syntax test-syntax-roundtrip test-gentype test-rewatch test-all playground playground-compiler playground-test playground-cmijs playground-release format checkformat clean-rewatch clean-compiler clean-lib clean-gentype clean-tests clean dev-container
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ ReScript is licensed under LGPL version 3, with relaxed rules about creating and

The ReScript parser (subdirectory `compiler/syntax`) is licensed under the [MIT License](compiler/syntax/LICENSE).

The `ninja` subdirectory contains the vendored [ninja](https://github.com/ninja-build/ninja) build system.
Refer to its copyright and license notices for information about its licensing.

## 🏅 Acknowledgments

ReScript was originally created by [Hongbo Zhang](https://github.com/bobzhang) in 2015.
Expand Down
2 changes: 0 additions & 2 deletions analysis/examples/example-project/src/Json.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
@@ocaml.doc(" # Json parser
*
* Works with bucklescript and bsb-native
*
* ## Basics
*
Expand Down
14 changes: 0 additions & 14 deletions analysis/examples/larger-project/.merlin

This file was deleted.

1 change: 0 additions & 1 deletion analysis/examples/workspace-project/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ lib
*.mliast
.vscode
.merlin
.bsb.lock
/node_modules/
package-lock.json
yarn.lock
2 changes: 0 additions & 2 deletions analysis/vendor/json/Json.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
(** # Json parser
*
* Works with bucklescript and bsb-native
*
* ## Basics
*
Expand Down
1 change: 0 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"lib/es6/**",
"lib/js/**",
"lib/bs/**",
"ninja/**",
"playground/**",
"*.bs.js",
"*.res.js",
Expand Down
Loading
Loading