diff --git a/apps/docs/markdown-pages/blog/release-11-0-0.mdx b/apps/docs/markdown-pages/blog/release-11-0-0.mdx index 8cdf56518..55067333a 100644 --- a/apps/docs/markdown-pages/blog/release-11-0-0.mdx +++ b/apps/docs/markdown-pages/blog/release-11-0-0.mdx @@ -16,7 +16,7 @@ Use your favorite package manager to install the new compiler release, e.g.: npm install rescript@11 ``` -You can find the complete migration guide [here](../docs/manual/migrate-to-v11.mdx). +You can find the complete migration guide [here](https://v11.rescript-lang.org/docs/manual/v11.0.0/migrate-to-v11). The complete list of changes can be found [here](https://github.com/rescript-lang/rescript/blob/v11.0.0/CHANGELOG). Let's have a look at the most notable improvements. diff --git a/apps/docs/markdown-pages/blog/release-12-0-0.mdx b/apps/docs/markdown-pages/blog/release-12-0-0.mdx index aeea36ce7..e5754ce14 100644 --- a/apps/docs/markdown-pages/blog/release-12-0-0.mdx +++ b/apps/docs/markdown-pages/blog/release-12-0-0.mdx @@ -18,7 +18,7 @@ The headline upgrades include a rewritten build system, a standalone runtime pac Teams upgrading from ReScript 11 should review the highlighted breaking changes and schedule time for migration. The new tooling provides focused commands, better diagnostics, and smaller downloads, while the language additions flatten sharp edges that many of you encountered in larger codebases. -You can find the complete migration guide [here](../docs/manual/migrate-to-v12.mdx). +You can find the complete migration guide [here](https://v12.rescript-lang.org/docs/manual/migrate-to-v12). ## New Features diff --git a/apps/docs/markdown-pages/docs/manual/build-configuration.mdx b/apps/docs/markdown-pages/docs/manual/build-configuration.mdx index 9eebbc201..24e667e68 100644 --- a/apps/docs/markdown-pages/docs/manual/build-configuration.mdx +++ b/apps/docs/markdown-pages/docs/manual/build-configuration.mdx @@ -9,7 +9,7 @@ order: 2 # Configuration -Put each package's build configuration in `rescript.json`. +Put each package's build configuration in `rescript.json`. Upgrading from an older configuration? See [Migrate to v13](./migrate-to-v13.mdx#build-configuration). Browse the [configuration schema](./build-configuration-schema.mdx) for a reference. The sections below explain common settings and native build-system options. diff --git a/apps/docs/markdown-pages/docs/manual/migrate-to-v11.mdx b/apps/docs/markdown-pages/docs/manual/migrate-to-v11.mdx deleted file mode 100644 index 3d68eac34..000000000 --- a/apps/docs/markdown-pages/docs/manual/migrate-to-v11.mdx +++ /dev/null @@ -1,131 +0,0 @@ ---- -title: "Migrate to v11" -description: "Instructions on upgrading to ReScript 11" -canonical: "/docs/manual/migrate-to-v11" ---- - -# Migrate to ReScript 11 - -## Foreword - -The ReScript community is proud to introduce ReScript V11 which comes with a ton of new features but also removes a lot of bulk. -A migration to it can be very straightforward, but it can also take some time, depending on your code style or what dependencies you use. - -Please have a look at the full [set of breaking changes](#list-of-all-breaking-changes) below to be able to decide whether this is a task you want to undertake. There is also the possibilty to [opt-out of uncurried mode](#minimal-migration) for now, which is probably the most fundamental change of this release. That and other new and notable features are discussed in the following blogposts: - -- [Blog: Improving Interop with unboxed types](../../blog/improving-interop.mdx) -- [Blog: Enhanced Ergonomics for Record Types](../../blog/enhanced-ergonomics-for-record-types.mdx) -- [Blog: First-Class Dynamic `import()` Support](../../blog/first-class-dynamic-import-support.mdx) -- [Blog: Uncurried Mode by Default](../../blog/uncurried-mode.mdx) - -## Recommended Migration - -### Uncurried Mode - -For uncurried mode to take effect in ReScript 11 there is nothing to configure, it is activated by default. - -### Adapt suffix - -ReScript 11 now allows having arbitrary suffixes in the generated JavaScript files. However, it is still recommended to stick to using `.res.js`, `.res.mjs` or `.res.cjs`. For more information, read the Build System Configuration about [suffixes](./build-configuration.mdx#suffix). - -### rescript.json - -The old configuration filename `bsconfig.json` is deprecated. Rename `bsconfig.json` to `rescript.json` to get rid of the deprecation warning. - -### ReScript Core standard library - -[ReScript Core](https://github.com/rescript-association/rescript-core) is ReScript's new standard library. It replaces the complete `Js` module as well as some of the more frequently used modules from `Belt` and is recommended to use with uncurried mode. - -It will be integrated into the compiler in a future version. In ReScript 11, it still needs to be installed manually: - -```console -$ npm install @rescript/core -``` - -Then add `@rescript/core` to your `rescript.json`'s dependencies: - -```diff - { - "bs-dependencies": [ -+ "@rescript/core" - ] - } -``` - -Open it so it's available in the global scope. - -```diff - { - "bsc-flags": [ -+ "-open RescriptCore", - ] - } -``` - -One major change to be aware of is that array access now returns an `option`. - -```res nocheck -let firstItem = myArray[0] // Some("hello") -``` - -If you would like to not use an `option`, you can use [`Array.getUnsafe`](/docs/manual/api/stdlib/array#value-getUnsafe). - -For a detailed explanation on migration to ReScript Core, please refer to its [migration guide](https://github.com/rescript-association/rescript-core#migration). A semi-automated script is available as well. - -See ReScript Core API docs [here](/docs/manual/api/stdlib). - -### Removed bindings - -Many Node bindings have been removed from the compiler. Please use [rescript-nodejs](https://github.com/TheSpyder/rescript-nodejs) instead or write your own local bindings. - -## Minimal Migration - -This guide describes the things to do at least to migrate to ReScript 11. - -### Disable uncurried mode - -If you use currying extensively and don't want to bother with adapting your code, or have dependencies that just don't work with uncurried mode yet, just set it to false in your `rescript.json`. - -```json -{ - "uncurried": false -} -``` - -For more information, read the Build System Configuration about [uncurried](./build-configuration.mdx#uncurried). - -## List of all breaking changes - -Below is an excerpt from the compiler changelog about all the breaking changes of ReScript 11. - -### Language and Compiler - -- Add smart printer for pipe chains. https://github.com/rescript-lang/rescript-compiler/pull/6411 (the formatter will reformat existing code in certain cases) -- Parse `assert` as a regular function. `assert` is no longer a unary expression. Example: before `assert 1 == 2` is parsed as `(assert 1) == 2`, now it is parsed as `assert(1 == 2)`. https://github.com/rescript-lang/rescript-compiler/pull/6180 -- Remove support for the legacy Reason syntax. Existing Reason code can be converted to ReScript syntax using ReScript 9 as follows: - - `npx rescript@9 convert ` -- Curried after uncurried is not fused anymore: `(. x) => y => 3` is not equivalent to `(. x, y) => 3` anymore. It's instead equivalent to `(. x) => { y => 3 }`. - Also, `(. int) => string => bool` is not equivalen to `(. int, string) => bool` anymore. - These are only breaking changes for unformatted code. -- Exponentiation operator `**` is now right-associative. `2. ** 3. ** 2.` now compile to `Math.pow(2, Math.pow(3, 2))` and not anymore `Math.pow(Math.pow(2, 3), 2)`. Parentheses can be used to change precedence. -- Stop mangling object field names. If you had objects with field names containing "\_\_" or leading "\_", they won't be mangled in the compiled JavaScript and represented as it is without changes. https://github.com/rescript-lang/rescript-compiler/pull/6354 -- `$$default` is no longer exported from the generated JavaScript when using default exports. https://github.com/rescript-lang/rescript-compiler/pull/6328 -- `-bs-super-errors` flag has been deprecated along with Super_errors. https://github.com/rescript-lang/rescript-compiler/pull/6243 -- Remove unsafe `` j`$(a)$(b)` `` interpolation deprecated in compiler version 10 https://github.com/rescript-lang/rescript-compiler/pull/6068 -- `@deriving(jsConverter)` not supported anymore for variant types https://github.com/rescript-lang/rescript-compiler/pull/6088 -- New representation for variants, where the tag is a string instead of a number. https://github.com/rescript-lang/rescript-compiler/pull/6088 - -### Compiler Libraries - -- Fixed name collision between the newly defined Js.Json.t and the variant constructor in the existing Js.Json.kind type. To address this, the usage of the existing Js.Json.kind type can be updated to Js.Json.Kind.t. https://github.com/rescript-lang/rescript-compiler/pull/6317 -- Remove rudimentary node bindings and undocumented `%node` extension. https://github.com/rescript-lang/rescript-compiler/pull/6285 -- `@rescript/react` >= 0.12.0-alpha.2 is now required because of the React.fragment's children type fix. https://github.com/rescript-lang/rescript-compiler/pull/6238 -- Remove deprecated module `Printexc` - -### Build System and Tools - -- Update watcher rules to recompile only on config and `*.res`/`*.resi`/`*.ml`/`.mli` file changes. Solves the issue of unnecessary recompiles on `.css`, `.ts`, and other unrelated file changes. https://github.com/rescript-lang/rescript-compiler/pull/6420 -- Made pinned dependencies transitive: if _a_ is a pinned dependency of _b_ and _b_ is a pinned dependency of _c_, then _a_ is implicitly a pinned dependency of _c_. This change is only breaking if your build process assumes non-transitivity. -- Remove obsolete built-in project templates and the "rescript init" functionality. This is replaced by [create-rescript-app](https://github.com/rescript-lang/create-rescript-app) which is maintained separately. -- Do not attempt to build ReScript from source on npm postinstall for platforms without prebuilt binaries anymore. -- GenType: removed support for `@genType.as` for records and variants which has become unnecessary. Use the language's `@as` instead to channge the runtime representation without requiring any runtime conversion during FFI. https://github.com/rescript-lang/rescript-compiler/pull/6099 https://github.com/rescript-lang/rescript-compiler/pull/6101 diff --git a/apps/docs/markdown-pages/docs/manual/migrate-to-v12.mdx b/apps/docs/markdown-pages/docs/manual/migrate-to-v12.mdx deleted file mode 100644 index 830363ade..000000000 --- a/apps/docs/markdown-pages/docs/manual/migrate-to-v12.mdx +++ /dev/null @@ -1,292 +0,0 @@ ---- -title: "Migrate to v12" -description: "Instructions on upgrading to ReScript 12" -canonical: "/docs/manual/migrate-to-v12" -section: "Overview" -order: 5 ---- - -# Migrate to ReScript 12 - -If you encounter any missing information or issues during migration, please [open an issue](https://github.com/rescript-lang/rescript-lang.org/issues/new?template=documentation_issue.md) or, even better, [send a pull request](https://github.com/rescript-lang/rescript-lang.org/) to help improve this guide. - -## Recommended Migration - -### Prerequisites - -- ReScript V11 project. -- Uncurried mode must be enabled (i.e. you have not opted-out from it). -- Your project must not contain any OCaml source code anymore, as support for `.ml` files is removed in this version. However there are ways to convert OCaml syntax with an older ReScript compiler version ([see below](#converting-generated-ml-files)). -- Minimum supported Node.js version is 20.11.0. - -### Standard Library Changes - -In V12, the new standard library ships with the compiler, so you can uninstall and remove the `@rescript/core` dependency from your `rescript.json` - -```console -$ npm remove @rescript/core -``` - -```diff - { - "bs-dependencies": [ -- "@rescript/core" - ] - } -``` - -Also remove auto opening of `RescriptCore`. - -```diff - { - "bsc-flags": [ -- "-open RescriptCore", - ] - } -``` - -if you had `@rescript/std` installed, remove it as well: - -```shell -npm uninstall @rescript/std -``` - -this is replaced by `@rescript/runtime`, which is installed as a dependency of `rescript` now. - - - **pnpm users:** since pnpm does not hoist transitive dependencies, you may need to install `@rescript/runtime` as a direct dependency (`pnpm add @rescript/runtime`), or hoist it by adding the following to `pnpm-workspace.yaml`: - -```yaml -publicHoistPattern: - - "*@rescript/runtime*" -``` - - - -## Replacements - -Some typical name changes include: - -- `Error.t` -> `JsError.t` -- `raise(MyException("error"))` -> `throw(MyException("error"))` -- `Js.Exn.Error` exception -> `JsExn` -- `Error.make` -> `JsExn.make` -- `Error.raise` -> `JsExn.raise` -- `Error.message` -> `JsExn.message` -- `Bool.fromStringExn("true")` -> `Bool.fromStringOrThrow("true")` -- `Int.Bitwise.lsl` -> `Int.shiftLeft` - -Tip: You can use the migration tool to automatically replace these with the new functions. - -```shell -npx rescript-tools migrate-all - -# preview the changes via -rescript-tools migrate [--stdout] -``` - -### Bitwise operations - -v11: - -```res nocheck -let w = lnot(a) // bitwise NOT -let x = lxor(a, b) // bitwise XOR -let y = land(a, b) // bitwise AND -let z = lor(a, b) // bitwise OR -``` - -v12: - -```res -let a = 5 and b = 2 -let w = ~~~a // bitwise NOT -let x = a ^^^ b // bitwise XOR -let y = a &&& b // bitwise AND -let z = a ||| b // bitwise OR -``` - -### Shift operations - -v11: - -```res nocheck -let x = lsl(a, b) // logical left shift -let y = lsr(a, b) // logical right shift -let z = asr(a, b) // unsigned right shift -``` - -v12: - -```res -let a = 5 and b = 2 -let x = a << b // logical left shift -let y = a >> b // logical right shift -let z = a >>> b // unsigned right shift -``` - -### JSX children spread - -v11: - -```res nocheck -
...children
-``` - -v12: - -```res -let children = React.string("Hello") -
children
-``` - -### Attributes - -v11: - -```res nocheck -@bs.as("foo") -@bs.send -@bs.new -@raises -@genType.as -``` - -v12: - -```res nocheck -@as("foo") -@send -@new -@throws -@as -``` - -- `@meth` and `@bs.send.pipe` are removed. - -### Assert - -v11: - -```res -assert 1 == 2 -``` - -v12: - -```res -assert(1 == 2) // Now a regular function call -``` - -## Configuration - -Rename `bsconfig.json` to `rescript.json` and update these configuration options: - -- `bs-dependencies` → `dependencies` -- `bs-dev-dependencies` → `dev-dependencies` -- `bsc-flags` → `compiler-flags` - -### jsx - -- Set `version` to `4` (lower versions are not supported) -- Remove `mode` option (automatically set to `automatic`) - -## Build System Changes - -The build system has been completely rewritten in v12.0.0. - -In v11, we had: - -```shell -# build -rescript build - -# watch build -rescript build -w - -# format -rescript format -all -``` - -in v12, this becomes: - -```shell -# build -rescript - -# watch build -rescript watch - -# format -rescript format -``` - -## Converting generated `.ml` files - -**Note**: This setup is an escape hatch. It keeps legacy generators like `atdgen` working but it also forces you to maintain two compiler versions. Whenever possible migrate such things to modern ReScript tooling such as [Sury](https://github.com/DZakh/sury/). - -Some projects still rely on tools such as `atdgen` that emit `.ml` files. ReScript 12 cannot compile those files directly, so you must keep using ReScript 11 **only** to convert the generated `.ml` files back to `.res` files before you run the v12 build. - -1. Keep ReScript 12 as the sole compiler dependency in your main project (i.e. `devDependencies.rescript` stays at `^12.0.0`). - -2. Install ReScript 11 in a dedicated subfolder (so its binaries never replace the v12 ones in `node_modules/.bin`). A simple option is to store it under a subfolder, e.g. `tools` (if you're using workspaces, keep this folder out of the root workspace list so hoisting can't swap the v12 shims): - -`cd` into `tools` and run `npm create rescript-app` and select the basic template and a v11 version of ReScript. You can name it `rescript-11` for instance. - -3. `cd` back into the root of your project and add a helper script that references the compiler from that folder (adapt the path accordingly): - - ```json - { - "scripts": { - "convert-ml": "tools/rescript-11/node_modules/.bin/rescript convert src/*.ml" - } - } - ``` - -4. Execute the helper script to convert your `.ml` files to `.res` files: - -```console -npm run convert-ml -``` - -## List of all breaking changes - -Below is a consolidated excerpt of all the breaking changes from the compiler changelog. - -### Language & syntax - -- Tag functions named `j` or `js` are no longer reserved, so add your own implementation whenever a tagged template expects them. https://github.com/rescript-lang/rescript-compiler/pull/6817 -- `lazy` syntax was removed; use the `Lazy` module instead. https://github.com/rescript-lang/rescript-compiler/pull/6342 -- All legacy `@bs.*` attributes (e.g. `@bs.as`, `@bs.send`) and `@bs.open` were removed; use their prefix-free successors (`@as`, `@send`, `@open`, …). https://github.com/rescript-lang/rescript-compiler/pull/6643 https://github.com/rescript-lang/rescript-compiler/pull/6629 -- `@bs.send.pipe` was removed; rewrite bindings to use `@send`. https://github.com/rescript-lang/rescript-compiler/pull/6858 https://github.com/rescript-lang/rescript-compiler/pull/6891 -- OCaml `.ml` files are no longer supported anywhere: `.ml` parsing/formatting went away and the `rescript convert` CLI was removed, so convert legacy files to `.res` before upgrading. https://github.com/rescript-lang/rescript-compiler/pull/6848 https://github.com/rescript-lang/rescript-compiler/pull/6852 https://github.com/rescript-lang/rescript-compiler/pull/6860 -- Some global names and old keywords are no longer automatically prefixed during JS emission; update any code that was relying on the mangled names. https://github.com/rescript-lang/rescript-compiler/pull/6831 -- JSX v3 and the `-bs-jsx-mode` option were removed and JSX children spreads are no longer valid; JSX v4 semantics are now the only supported mode. https://github.com/rescript-lang/rescript-compiler/pull/7072 https://github.com/rescript-lang/rescript/pull/7327 https://github.com/rescript-lang/rescript/pull/7869 - -### Standard library & runtime - -- OCaml compatibility layers in the stdlib and primitives were removed/deprecated. https://github.com/rescript-lang/rescript-compiler/pull/6984 -- Deprecated modules `Js.Vector` and `Js.List` were deleted. https://github.com/rescript-lang/rescript-compiler/pull/6900 -- The legacy `js_cast.res` helpers were removed; migrate to explicit externals. https://github.com/rescript-lang/rescript-compiler/pull/7075 -- `JsError` and related modules were renamed/cleaned up under `JsExn`. https://github.com/rescript-lang/rescript/pull/7408 -- `BigInt.fromFloat` now returns `option` and exposes `BigInt.fromFloatOrThrow`, and the `Exn`-suffixed helpers across `Bool`, `BigInt`, `JSON`, `Option`, `Null`, `Nullable`, `Result`, and `List` now end with `OrThrow`. https://github.com/rescript-lang/rescript/pull/7419 https://github.com/rescript-lang/rescript/pull/7518 https://github.com/rescript-lang/rescript/pull/7554 -- `Result.getOrThrow` throws a JS `Error` (instead of `Not_found`), and `Result.equal` / `Result.compare` now provide a comparison function for `Error` values. https://github.com/rescript-lang/rescript/pull/7630 https://github.com/rescript-lang/rescript/pull/7933 -- `Iterator.forEach` now emits `Iterator.prototype.forEach`. https://github.com/rescript-lang/rescript/pull/7506 -- `Date.make` uses `~day` instead of `~date`. https://github.com/rescript-lang/rescript/pull/7324 -- Plain `int` multiplication is implemented as a regular int32 operation instead of `Math.imul`. https://github.com/rescript-lang/rescript/pull/7358 -- The `List` API was cleaned up—several functions were renamed or removed (see the PR for the exact surface). https://github.com/rescript-lang/rescript/pull/7290 -- `String.getSymbol` / `String.setSymbol` were removed; only `String.getSymbolUnsafe` remains on strings. https://github.com/rescript-lang/rescript/pull/7571 https://github.com/rescript-lang/rescript/pull/7626 -- `String.charCodeAt` now returns `option` and exposes `String.charCodeAtUnsafe` for unchecked access. https://github.com/rescript-lang/rescript/pull/7877 -- `Intl.*.supportedLocalesOf` bindings now return `array` and the non-portable `Intl.PluralRules.selectBigInt` / `selectRangeBigInt` were removed. https://github.com/rescript-lang/rescript/pull/7995 - -### Build system & CLI - -- The new Rust-based `rewatch` build system now powers the `rescript` command. The old Ninja-based builder is available through the separate `rescript-legacy` executable, and `--compiler-args` became the `compiler-args` subcommand. https://github.com/rescript-lang/rescript/pull/7551 https://github.com/rescript-lang/rescript/pull/7593 https://github.com/rescript-lang/rescript/pull/7928 -- `rescript format` was reimplemented in Rust, its options now use the `--check` / `--stdin` long-form spelling, and the `--all` flag was removed because every tracked file (non-dev by default) is formatted automatically. https://github.com/rescript-lang/rescript/pull/7603 https://github.com/rescript-lang/rescript/pull/7752 -- The `rescript dump` command was removed; call `bsc` directly if you need to inspect `.cmi` files. https://github.com/rescript-lang/rescript/pull/7710 - -### Configuration & platform - -- The minimum supported Node.js version is now 20.11.0. https://github.com/rescript-lang/rescript/pull/7354 -- The `experimental-features` key in `rescript.json` now uses kebab-case to match the other config fields. https://github.com/rescript-lang/rescript/pull/7891 -- The legacy `-bs-super-errors` flag was removed. https://github.com/rescript-lang/rescript-compiler/pull/6814 diff --git a/apps/docs/markdown-pages/docs/manual/migrate-to-v13.mdx b/apps/docs/markdown-pages/docs/manual/migrate-to-v13.mdx new file mode 100644 index 000000000..c8e935dd4 --- /dev/null +++ b/apps/docs/markdown-pages/docs/manual/migrate-to-v13.mdx @@ -0,0 +1,142 @@ +--- +title: "Migrate to v13" +description: "Instructions on upgrading to ReScript 13" +canonical: "/docs/manual/migrate-to-v13" +section: "Overview" +order: 5 +--- + +# Migrate to ReScript 13 + +This guide lists the changes that need action when upgrading from ReScript 12, up to 13.0.0-alpha.7. Upgrading from ReScript 11? Follow the [v12 migration guide](https://v12.rescript-lang.org/docs/manual/migrate-to-v12) first. If something is missing, please [open an issue](https://github.com/rescript-lang/rescript-lang.org/issues/new?template=documentation_issue.md) or [send a pull request](https://github.com/rescript-lang/rescript-lang.org/). + +## Before You Upgrade + +- **Node.js 22** or newer is required. +- **macOS on Intel** is no longer supported. Stay on ReScript 12 there. +- **APIs deprecated in ReScript 12 are removed**, for example `List.has`, `Error`, `Exn` and the `Char` module. On the latest 12.x release, run `npx rescript-tools migrate-all .` to apply the automatic migrations, then fix any remaining deprecation warnings. + +## Dependencies + +### Belt + +Belt is now a separate package. Install `@rescript/belt` in the same version as `rescript`. During the v13 prereleases, that's the `next-13` tag: + +```sh +npm install @rescript/belt@next-13 +``` + +Then add it to `rescript.json`: + +```json +{ + "dependencies": ["@rescript/belt"] +} +``` + +Belt functions that returned `undefined<'a>`, such as `Belt.Array.getUndefined`, are removed. Use the versions that return `option<'a>`, such as `Belt.Array.get`. + +### Js + +The `Js` namespace is removed. Use the standard library modules instead, such as `Array`, `String`, `Dict` and `JSON`. + +## Build System and CLI + +`rescript` runs a new build system. Check your scripts for these changes: + +- `rescript-legacy` is removed. +- The `--dev` and `--create-sourcedirs` flags and `rescript build -w` are removed. Use `rescript watch` to watch. +- A `rescript.json` with duplicate keys, or with `namespace-entry` but no `namespace`, is an error. +- A failing `--after-build` command fails the build. +- `--filter` only accepts common regular expression syntax. +- `RESCRIPT_BSC_EXE` is no longer read. +- The `-uncurried` and `-pp` compiler flags are removed. Delete them from `compiler-flags`. + +## Build Configuration + +### Configuration File and Keys + +Rename `bsconfig.json` to `rescript.json`, and rename these keys: + +| Legacy key | Current key | +| --------------------- | ------------------ | +| `bs-dependencies` | `dependencies` | +| `bs-dev-dependencies` | `dev-dependencies` | +| `bsc-flags` | `compiler-flags` | + +The old file name and keys still work, but print deprecation warnings. + +Remove `external-stdlib`. It's no longer supported. + +### Module Format + +`esmodule` is now the default when `package-specs` is omitted. To keep CommonJS output, set it explicitly: + +```json +{ + "package-specs": { + "module": "commonjs", + "in-source": true + } +} +``` + +Replace legacy module names: + +- `es6` → `esmodule` and `cjs` → `commonjs`. The old names still work, but print deprecation warnings. +- `es6-global` → `esmodule`. The old name is now an error. + +### Multiple Output Formats + +When you emit several formats to the same location, give each its own suffix. Specs with the same suffix are now rejected: + +```json +{ + "package-specs": [ + { "module": "esmodule", "suffix": ".mjs" }, + { "module": "commonjs", "suffix": ".cjs" } + ] +} +``` + +See [Build Configuration](./build-configuration.mdx#package-specs) for all options. + +## Language Changes + +### Removed Syntax + +| Removed | Use instead | +| ----------------------------------------------- | ------------------------------------------------------------------------------- | +| `(. a, b) => ...` uncurried functions | `(a, b) => ...` | +| `%re("/b/g")` | [Regular expression literals](./primitive-types.mdx#regular-expression): `/b/g` | +| `%debugger` | [`debugger()`](./embed-raw-javascript.mdx#debugger) | +| `%external(name)` | `%raw`, or a binding such as `@val external` | +| `@taggedTemplate` | The [`taggedTemplate<'param, 'output>`](./tagged-templates.mdx) type | +| `@deriving(abstract)`, `@deriving(jsConverter)` | Records and polymorphic variants | +| `@ocaml.warning` and the other `@ocaml.*` forms | `@warning` and the other unprefixed forms | +| `@ocaml.doc`, `@ns.doc` | `/** */` doc comments | +| Record syntax for a dict, `{foo: 1}` | [`dict{"foo": 1}`](./dict.mdx) | + +### Other Changes + +- `break` and `continue` are keywords. Rename identifiers with these names, or escape them, as in `\"break"`. +- `@unboxed` goes on the variant type, not on a constructor. For a constructor whose payload is an inline record with one field, this unboxes the value to that field. Give the record a named type to keep the object. +- Object fields can only be assigned when they are marked `@set`, as in `{@set "name": string}`. The other `@get` and `@set` forms on object types are removed. +- `@this this => async arg => ...` now defines a method that returns an async function. For an async method, write `@this async (this, arg) => ...`. +- `Jsx.component` is an abstract type. To use a plain function as a component, define it with `@react.component` or wrap it in `React.component(...)`. +- Nested functions other than `make` are no longer exported to JavaScript as top-level `A$B$f` values. +- Coercing another type into a private record or variant is an error. +- Records with `@as("0")`, `@as("1")`, … fields compile to JavaScript arrays. Rest patterns, coercions and untagged variants that would treat them as objects are errors. +- Tagged template literals can't be used in patterns. +- Invalid escapes in string and template literals, and malformed UTF-8 in doc comments, are errors. +- `\"_"` is no longer a valid identifier. + +## Standard Library + +- The new `Temporal` module shadows project modules named `Temporal`. Rename yours. Nested modules named `Temporal` are exported to JavaScript as `$$Temporal`. +- Typed array types such as `Int8Array.t` are no longer interchangeable. Upcast with `:> TypedArray.t<_>` to use the generic `TypedArray` functions. `TypedArray.map` and `TypedArray.mapWithIndex` keep the element type. +- `Int.fromString` and `Float.fromString` no longer take a radix. They parse hexadecimal, binary and exponential notation, such as `0x1F`, directly, and are stricter. +- `Intl.Collator.compare` returns `Ordering.t` instead of `int`. +- Iterators are typed as `Iterator.t<'yield, 'return, 'next>`. `fromIterator` on `Array`, `Dict`, `Map` and `Set` is now `fromIterable`; coerce iterators to it, as in `Array.fromIterable((map->Map.keys :> Iterable.t<_>))`. `toArray`, `toArrayWithMapper` and `forEach` moved from `Iterator` to `IteratorObject`, the type that `Map.keys`, `Array.values` and similar functions return. +- `Int.Ref` is removed. Use `ref` values directly. +- Custom externals that use removed primitives, such as `%incr` or `%obj_field`, are rejected. diff --git a/apps/docs/markdown-pages/syntax-lookup/operators_bitwise_and.mdx b/apps/docs/markdown-pages/syntax-lookup/operators_bitwise_and.mdx index c451494d8..9db142d81 100644 --- a/apps/docs/markdown-pages/syntax-lookup/operators_bitwise_and.mdx +++ b/apps/docs/markdown-pages/syntax-lookup/operators_bitwise_and.mdx @@ -26,4 +26,4 @@ export { result }; ### References -- [Migrate to v12](../docs/manual/migrate-to-v12.mdx) +- [Migrate to v12](https://v12.rescript-lang.org/docs/manual/migrate-to-v12) diff --git a/apps/docs/markdown-pages/syntax-lookup/operators_bitwise_not.mdx b/apps/docs/markdown-pages/syntax-lookup/operators_bitwise_not.mdx index c240989b1..3187a8640 100644 --- a/apps/docs/markdown-pages/syntax-lookup/operators_bitwise_not.mdx +++ b/apps/docs/markdown-pages/syntax-lookup/operators_bitwise_not.mdx @@ -26,4 +26,4 @@ export { result }; ### References -- [Migrate to v12](../docs/manual/migrate-to-v12.mdx) +- [Migrate to v12](https://v12.rescript-lang.org/docs/manual/migrate-to-v12) diff --git a/apps/docs/markdown-pages/syntax-lookup/operators_bitwise_or.mdx b/apps/docs/markdown-pages/syntax-lookup/operators_bitwise_or.mdx index 44a9711aa..1114057c4 100644 --- a/apps/docs/markdown-pages/syntax-lookup/operators_bitwise_or.mdx +++ b/apps/docs/markdown-pages/syntax-lookup/operators_bitwise_or.mdx @@ -26,4 +26,4 @@ export { result }; ### References -- [Migrate to v12](../docs/manual/migrate-to-v12.mdx) +- [Migrate to v12](https://v12.rescript-lang.org/docs/manual/migrate-to-v12) diff --git a/apps/docs/markdown-pages/syntax-lookup/operators_bitwise_xor.mdx b/apps/docs/markdown-pages/syntax-lookup/operators_bitwise_xor.mdx index f330608e5..13fe52823 100644 --- a/apps/docs/markdown-pages/syntax-lookup/operators_bitwise_xor.mdx +++ b/apps/docs/markdown-pages/syntax-lookup/operators_bitwise_xor.mdx @@ -26,4 +26,4 @@ export { result }; ### References -- [Migrate to v12](../docs/manual/migrate-to-v12.mdx) +- [Migrate to v12](https://v12.rescript-lang.org/docs/manual/migrate-to-v12) diff --git a/apps/docs/public/_redirects b/apps/docs/public/_redirects index ff0e3e2be..c4f7e2582 100644 --- a/apps/docs/public/_redirects +++ b/apps/docs/public/_redirects @@ -5,6 +5,10 @@ /docs/manual/api/introduction/ /docs/manual/api 308 /syntax-lookup/extension_debugger /syntax-lookup/builtinfunctions_debugger 308 +# Migration guides for older versions live on their version's docs site. +/docs/manual/migrate-to-v12 https://v12.rescript-lang.org/docs/manual/migrate-to-v12 308 +/docs/manual/migrate-to-v11 https://v11.rescript-lang.org/docs/manual/v11.0.0/migrate-to-v11 308 + # Legacy aliases serve the current deployment's generated manual text files. /llms/manual/llms.txt /llms.txt 307 /llms/manual/llms-full.txt /llms/manual/llm-full.txt 307 diff --git a/apps/docs/scripts/__tests__/generate-route-types.test.mjs b/apps/docs/scripts/__tests__/generate-route-types.test.mjs index 640db3382..8c580bb34 100644 --- a/apps/docs/scripts/__tests__/generate-route-types.test.mjs +++ b/apps/docs/scripts/__tests__/generate-route-types.test.mjs @@ -72,7 +72,7 @@ test("the committed type matches the actual React Router configuration", () => { "/packages", "/syntax-lookup", "/docs/manual/api", - "/docs/manual/migrate-to-v12", + "/docs/manual/migrate-to-v13", "/docs/manual/rescript-for-javascript-developers", "/docs/manual/api/dom/storage", "/blog/retreat-recap-2026", diff --git a/apps/docs/scripts/test-redirects.mjs b/apps/docs/scripts/test-redirects.mjs index 26d8b814f..483cb97b2 100644 --- a/apps/docs/scripts/test-redirects.mjs +++ b/apps/docs/scripts/test-redirects.mjs @@ -60,6 +60,16 @@ export function checkRedirects({ "/docs/guides/publishing-packages", "308", ); + assertRedirect( + "/docs/manual/migrate-to-v12", + "https://v12.rescript-lang.org/docs/manual/migrate-to-v12", + "308", + ); + assertRedirect( + "/docs/manual/migrate-to-v11", + "https://v11.rescript-lang.org/docs/manual/v11.0.0/migrate-to-v11", + "308", + ); assertRedirect( "/syntax-lookup/extension_debugger", "/syntax-lookup/builtinfunctions_debugger", diff --git a/packages/shared/src/Path.res b/packages/shared/src/Path.res index b37652c61..cbfc7f4ae 100644 --- a/packages/shared/src/Path.res +++ b/packages/shared/src/Path.res @@ -276,8 +276,7 @@ type t = [ | #"/docs/manual/let-binding" | #"/docs/manual/libraries" | #"/docs/manual/llms" - | #"/docs/manual/migrate-to-v11" - | #"/docs/manual/migrate-to-v12" + | #"/docs/manual/migrate-to-v13" | #"/docs/manual/module" | #"/docs/manual/module-functions" | #"/docs/manual/mutation"