diff --git a/apps/docs/markdown-pages/community/roadmap.mdx b/apps/docs/markdown-pages/community/roadmap.mdx index c4daacfd6..048252e1f 100644 --- a/apps/docs/markdown-pages/community/roadmap.mdx +++ b/apps/docs/markdown-pages/community/roadmap.mdx @@ -12,7 +12,7 @@ ReScript was created by [Hongbo Zhang](https://github.com/bobzhang), whose found ## ReScript 13 -The target for ReScript 13 is **Q4 2026**. This roadmap describes the intended outcomes of the release rather than tracking the day-to-day status of individual changes. +The target for the ReScript 13 release is **Q1 2027**, with the beta phase starting in December 2026. This roadmap describes the intended outcomes of the release rather than tracking the day-to-day status of individual changes. The main areas of focus are: @@ -20,21 +20,32 @@ The main areas of focus are: Compiler-generated source maps, with linked, inline, and hidden modes, will make generated JavaScript easier to debug. Tools that consume source maps will be able to relate stack traces and runtime performance profiles back to their original ReScript source. -### Faster, Observable Builds +### Faster Builds, Without the Legacy Build System -ReScript 13 completes the transition to the native Rewatch build system and removes the legacy Ninja-based builder. +The build system introduced as the default in ReScript 12 (codenamed Rewatch) becomes the only one in ReScript 13: support for the legacy Ninja-based builder is removed. Projects that already use Rewatch in ReScript 12 do not need to switch builders. Projects that relied on CommonJS being the default module system need to set it explicitly, since ReScript 13 defaults to ES modules. -The build scheduler uses a work-stealing dependency-graph dispatcher ordered by critical-path priority. This avoids waiting for the slowest file in each compilation wave and makes better use of the available CPU cores. The build system also focuses on reliable monorepo builds, production-only builds, feature-gated source directories, and a better watch-mode experience. +The build system and the compiler are now a single binary, so modules are compiled in-process on several CPU cores instead of spawning a compiler process per file. -OpenTelemetry tracing through OTLP exposes initialization, dependency discovery, parsing, per-file compilation, and post-build work. This provides a modern path for investigating build performance after the removal of the legacy `bstracing` tool. +Build output moves from `lib/bs` and `lib/ocaml` into one flat `lib/rescript` directory per package, without copies of the sources or generated JavaScript. The build system also focuses on reliable monorepo builds, production-only builds, feature-gated source directories, and a better watch-mode experience. -### TypeScript Declarations +A lot of fine-tuning has also gone into the performance of the compiler itself, from type checking to code generation, so builds should be faster overall. For example, modules with many JSX elements compile up to 10× faster, code generation for large list literals is now linear instead of quadratic, and so is dependency discovery for large `let rec` groups. + +### Cross-Module Inlining with `@inline` -Direct TypeScript declaration (`.d.ts`) generation in the compiler will make ReScript libraries easier to consume from TypeScript without requiring a separate type-information parsing pipeline. The focus is declaration output for ReScript-generated JavaScript, not compiling ReScript to TypeScript source. +`@inline` functions are inlined into every module that calls them, not only their own. Many small standard-library functions are marked `@inline`, so calls such as `Option.isSome`, `Option.getOr`, `Array.reduce`, or the `Result` combinators compile to the JavaScript they run instead of a function call. A new warning tells you when an exported `@inline` function cannot be inlined in other modules, and why. ### JavaScript-Style Control Flow -ReScript 13 adds `for...of` and `for await...of` loops for iterables and async iterables. Loops also support `break` and `continue`, making common JavaScript control-flow patterns available without dropping down to bindings or helper functions. +ReScript 13 adds `for...of` and `for await...of` loops for iterables and async iterables. Loops also support `break` and `continue`, and `try` gains a `finally` block, making common JavaScript control-flow patterns available without dropping down to bindings or helper functions. + +### Better JavaScript Interop + +- Untagged variants can match on JavaScript classes and opaque types with `@instanceOf` and `@typeOf`, so values like `File`, `Blob`, or `Symbol` can be variant cases. +- Types bound to the same JavaScript class with `@instanceOf` can be coerced with `:>`, also to their declared superclasses. Packages that bind the same class separately, such as a DOM element in two binding libraries, can exchange values without `Obj.magic`. +- First-class, type-safe tagged-template functions. +- Inline record types in external definitions. +- `Temporal` bindings in the standard library. +- Nested components such as `` work as React Server Components client references. ### More JavaScript-Aligned Language Features @@ -42,10 +53,33 @@ The ReScript 13 language direction also includes: - dictionary spreads - record rest destructuring -- inline record types in external definitions -- first-class, type-safe tagged-template functions +- `$` in identifiers, e.g. `let count$ = signal(0)` + +### Other Improvements + +Pattern matching gains int range patterns, such as `200 .. 299` for HTTP success codes. + +Error messages improve as well, for example signature mismatches now show only the items that differ, in ReScript syntax. + +The generated JavaScript gets leaner: untagged variant switches test literals and `typeof` before any `instanceof`, matching `Some(x)` emits less code, and creating a nested `None` no longer allocates. + +Beyond new features, a large share of the work on ReScript 13 went into correctness. The compiler keeps JavaScript's evaluation order in more places, such as spreads and external arguments, closes type holes in record spreads and coercions, and rejects code it previously compiled to invalid JavaScript. The formatter also keeps comments and attributes it used to drop or misplace. + +## Beyond ReScript 13 + +Some larger efforts will not be part of the ReScript 13 release but are already being explored. They are listed roughly in the order we expect them to land. + +### Generator Functions + +Generator functions are in the design phase. They would let you write generators and async generators directly in ReScript, complementing the `for...of` and `for await...of` loops that ReScript 13 introduces. They are planned to follow soon after the ReScript 13 release. + +### TypeScript Declarations + +Direct TypeScript declaration (`.d.ts`) generation in the compiler would make ReScript libraries easier to consume from TypeScript, without requiring a separate type-information parsing pipeline. The focus is declaration output for ReScript-generated JavaScript, not compiling ReScript to TypeScript source. + +### Compile-Time Code Generation -ReScript 13 also removes deprecated configuration, syntax, and standard-library APIs, defaults the module system to ES modules, and raises the minimum supported Node.js version to 22. +Further out, we are exploring compile-time code generation written in ReScript itself, as a possible successor to many of today's PPX use cases, such as deriving code from type definitions. This is at an early, experimental stage, and the design is still open. ## Follow Development