From 4ff804649e52f0498a8b771f69dc0d339dd573a2 Mon Sep 17 00:00:00 2001 From: Florian Hammerschmidt Date: Sat, 21 Oct 2023 01:18:48 +0200 Subject: [PATCH 1/5] Adapt some pages to ReScript 11 including records and variants --- pages/docs/manual/latest/record.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/docs/manual/latest/record.mdx b/pages/docs/manual/latest/record.mdx index b251d7aa4..53c114a9b 100644 --- a/pages/docs/manual/latest/record.mdx +++ b/pages/docs/manual/latest/record.mdx @@ -426,7 +426,7 @@ type c = { } ``` -Record type spreads act as a 'copy-paste' mechanism for fields from one or more records into a new record. This operation inlines the fields from the spread records directly into the new record definition, while preserving their original properties, such as whether they are optional or mandatory. It's important to note that duplicate field names are not allowed across the records being spread, even if the fields have the same type. +Record type spreads act as a 'copy-paste' mechanism for fields from one or more records into a new record. This operation inlines the fields from the spread records directly into the new record definition, while preserving their original properties, such as whether they are optional or mandatory. It's important to note that duplicate field names are not allowed across the records being spread, even if the fields share the same type. ## Record Type Coercion From 03a701f0d4b75d824e685c705711244baed53220 Mon Sep 17 00:00:00 2001 From: Florian Hammerschmidt Date: Sun, 22 Oct 2023 21:52:20 +0200 Subject: [PATCH 2/5] Some better wordings --- pages/docs/manual/latest/record.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/docs/manual/latest/record.mdx b/pages/docs/manual/latest/record.mdx index 53c114a9b..b251d7aa4 100644 --- a/pages/docs/manual/latest/record.mdx +++ b/pages/docs/manual/latest/record.mdx @@ -426,7 +426,7 @@ type c = { } ``` -Record type spreads act as a 'copy-paste' mechanism for fields from one or more records into a new record. This operation inlines the fields from the spread records directly into the new record definition, while preserving their original properties, such as whether they are optional or mandatory. It's important to note that duplicate field names are not allowed across the records being spread, even if the fields share the same type. +Record type spreads act as a 'copy-paste' mechanism for fields from one or more records into a new record. This operation inlines the fields from the spread records directly into the new record definition, while preserving their original properties, such as whether they are optional or mandatory. It's important to note that duplicate field names are not allowed across the records being spread, even if the fields have the same type. ## Record Type Coercion From 8000d9d59cd3910f581f51ab1093a3dfb703c383 Mon Sep 17 00:00:00 2001 From: Florian Hammerschmidt Date: Mon, 23 Oct 2023 23:57:54 +0200 Subject: [PATCH 3/5] Adapt example tests to Rescript11 + uncurried + RescriptCore --- scripts/test-examples.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test-examples.mjs b/scripts/test-examples.mjs index 7e01509f7..d031485c7 100644 --- a/scripts/test-examples.mjs +++ b/scripts/test-examples.mjs @@ -102,7 +102,7 @@ glob.sync(__dirname + '/../pages/docs/manual/latest/**/*.mdx').forEach((file) => rescriptCoreCompiled, '-w', '-109', - '-uncurried', + "-uncurried", '-open', 'RescriptCore', ], From bced3de38e83e16b606dbf212d31d7df88a508d9 Mon Sep 17 00:00:00 2001 From: Florian Hammerschmidt Date: Thu, 2 Nov 2023 13:09:52 +0100 Subject: [PATCH 4/5] Consistent quotes --- scripts/test-examples.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test-examples.mjs b/scripts/test-examples.mjs index d031485c7..7e01509f7 100644 --- a/scripts/test-examples.mjs +++ b/scripts/test-examples.mjs @@ -102,7 +102,7 @@ glob.sync(__dirname + '/../pages/docs/manual/latest/**/*.mdx').forEach((file) => rescriptCoreCompiled, '-w', '-109', - "-uncurried", + '-uncurried', '-open', 'RescriptCore', ], From f782eae007ddb87fdfa382fca5513342f221502d Mon Sep 17 00:00:00 2001 From: Florian Hammerschmidt Date: Sun, 12 Nov 2023 10:55:52 +0100 Subject: [PATCH 5/5] Remove old bs migration guide from latest docs --- .../2020-08-10-bucklescript-is-rebranding.mdx | 2 +- data/sidebar_manual_latest.json | 1 - next.config.mjs | 5 ++ .../migrate-from-bucklescript-reason.mdx | 64 ------------------- 4 files changed, 6 insertions(+), 66 deletions(-) delete mode 100644 pages/docs/manual/latest/migrate-from-bucklescript-reason.mdx diff --git a/_blogposts/2020-08-10-bucklescript-is-rebranding.mdx b/_blogposts/2020-08-10-bucklescript-is-rebranding.mdx index f924b55eb..953804628 100644 --- a/_blogposts/2020-08-10-bucklescript-is-rebranding.mdx +++ b/_blogposts/2020-08-10-bucklescript-is-rebranding.mdx @@ -61,7 +61,7 @@ There's no dedicated name for the syntax anymore. It's simply called the ReScrip **Will there be a migration script to gradually convert our code to the new syntax?** -Yes. See our [migration page](/docs/manual/latest/migrate-from-bucklescript-reason). You can mix and match old and new code for a smoother transition. +Yes. See our [migration page](/docs/manual/v10.0.0/migrate-from-bucklescript-reason). You can mix and match old and new code for a smoother transition. **Will BuckleScript (now ReScript) break my existing code?** diff --git a/data/sidebar_manual_latest.json b/data/sidebar_manual_latest.json index 98e0694c4..a5fc69ea3 100644 --- a/data/sidebar_manual_latest.json +++ b/data/sidebar_manual_latest.json @@ -3,7 +3,6 @@ "introduction", "installation", "editor-plugins", - "migrate-from-bucklescript-reason", "try" ], "Language Features": [ diff --git a/next.config.mjs b/next.config.mjs index fc4cee98b..14fc00747 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -88,6 +88,11 @@ const config = { destination: "/blog/bucklescript-is-rebranding", permanent: true, }, + { + source: "/docs/manual/latest/migrate-from-bucklescript-reason", + destination: "/docs/manual/v10.0.0/migrate-from-bucklescript-reason", + permanent: true, + }, ]; }, }; diff --git a/pages/docs/manual/latest/migrate-from-bucklescript-reason.mdx b/pages/docs/manual/latest/migrate-from-bucklescript-reason.mdx deleted file mode 100644 index ac3fce54f..000000000 --- a/pages/docs/manual/latest/migrate-from-bucklescript-reason.mdx +++ /dev/null @@ -1,64 +0,0 @@ ---- -title: "Migrate to ReScript Syntax" -description: "Instructions on upgrading from Reason to ReScript" -canonical: "/docs/manual/latest/migrate-to-new-syntax" ---- - -# Migrate from BuckleScript/Reason - -ReScript is a rebranding and cleanup of BuckleScript (since `v8.2.0`) & Reason (`v3.6`) that enables us to ship a tighter compile-to-JS stack with more coherent documentation & tools. If you're an existing user of BuckleScript & Reason, here's the gist: - -- ReScript is mostly just BuckleScript rebranded, with a new syntax that's like the Reason syntax, but catered more toward the JavaScript crowd. -- All your existing code will keep working even if you don't upgrade. - -## Upgrade Your Codebase - -There are lots of exciting improvements in the new syntax (features, speed, error messages, etc.). The upgrade is trivial, backward-compatible and can be done on a per-file basis: - -``` -npm install rescript@9 - -# Also works with .rei / .ml / .mli / etc -npx rescript convert src/MyFile.re -``` - -Enjoy the improved experience! - -### Upgrade Individual Folders - -This is useful for per-directory conversions: - -```console -# *.rei, *.ml, *.mli,.... -for f in your-folder/**/*.re; do; node_modules/.bin/rescript convert $f && rm $f; done; -``` - -### Upgrade an Entire Codebase - -In case you are confident in converting your codebase in one step, use the following: - -``` -npx rescript convert -all -``` - - -## Difference With Old Reason - -- Complete removal of semicolon (you can still write them). -- No need for parentheses around `if`, `switch` and `try`. -- Type arguments: from `option(int)` to `option`. -- Old interpolated string: from `{j|hello ${name}|j}` to `` `hello ${name}` ``. Now with proper unicode support! -- New interpolated string: `` `hello world` ``. Also supports multiline and unicode. `"hello world"` string is now singleline. -- Polymorphic variants: from `` `red`` to `#red`. -- Arrays: from `[|1,2,3|]` to `[1,2,3]`. In JS, arrays are the right default. -- Lists: from `[1,2,3]` to `list[1,2,3]` (_8.1.1 update_: now it is `list{1, 2, 3}`). This ties with upcoming plans to access containers in a uniform way: `set[...]` and `map[...]`. Maybe temporary. -- Exception: from `try (compute()) { | Not_found => Js.log("oops")}` to `try compute() catch { | Not_found => Js.log("oops")}`. -- First class module: from `(module S: Student)` to `module(S: Student)`. -- No custom infix operator for now (including `mod`). -- Object access: from `settings##visible #= true` to `settings["visible"] = true`. Rejoice! -- Object: from `Js.t({"age": int})` to just `{"age": int}`. The `Js.t` part is now unneeded. -- Attribute: from `[@myAttribute "hello"]` to `@myAttribute("hello")`. From `[%re bla]` to `%re(bla)`. -- Removed dereference syntax `result^`. Just use `result.contents`. -- `fun` pattern matching syntax removed. -- Type declaration is non-recursive by default, consistent with let bindings. To have recursive types, use `type rec myList<'a> = Nil | Cons('a, myList<'a>)`. -- Use any words, including reserved keywords, as your identifier name: `let \"try" = true`.