Skip to content

Commit fefd9a0

Browse files
authoredMar 17, 2025··
Update codebase to rescript v12.0.0-alpha.9 (#990)
First step to working on #981
1 parent 3655aa3 commit fefd9a0

23 files changed

+83
-146
lines changed
 

‎package-lock.json

+13-48
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
"@docsearch/react": "^3.5.2",
2424
"@headlessui/react": "^1.2.0",
2525
"@mdx-js/loader": "^3.1.0",
26-
"@rescript/core": "^1.4.0",
2726
"@rescript/react": "^0.12.0-alpha.3",
28-
"@rescript/tools": "^0.5.0",
2927
"codemirror": "^5.54.0",
3028
"docson": "^2.1.0",
3129
"escodegen": "^2.1.0",
@@ -52,7 +50,7 @@
5250
"remark-rehype": "^11.1.1",
5351
"remark-stringify": "^11.0.0",
5452
"request": "^2.88.0",
55-
"rescript": "^11.1.0",
53+
"rescript": "^12.0.0-alpha.9",
5654
"stringify-object": "^3.3.0",
5755
"unified": "^11.0.5",
5856
"vfile-matter": "^5.0.0"
@@ -80,4 +78,4 @@
8078
"simple-functional-loader": "^1.2.1",
8179
"tailwindcss": "^3.3.3"
8280
}
83-
}
81+
}

‎rescript.json

+2-9
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,7 @@
55
"version": 4
66
},
77
"bs-dependencies": [
8-
"@rescript/react",
9-
"@rescript/tools",
10-
"@rescript/core"
11-
],
12-
"uncurried": true,
13-
"ppx-flags": [],
14-
"bsc-flags": [
15-
"-open RescriptCore"
8+
"@rescript/react"
169
],
1710
"sources": [
1811
{
@@ -38,4 +31,4 @@
3831
"shims": [],
3932
"module": "es6"
4033
}
41-
}
34+
}

‎scripts/gendocs.res

+7-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ let docs = docsDecoded->Array.map(doc => {
115115
let rec getModules = (lst: list<Docgen.item>, moduleNames: list<module_>) =>
116116
switch lst {
117117
| list{
118-
Module({id, items, name, docstrings}) | ModuleAlias({id, items, name, docstrings}),
118+
Module({id, items, name, docstrings})
119+
| ModuleAlias({id, items, name, docstrings})
120+
| ModuleType({id, items, name, docstrings}),
119121
...rest,
120122
} =>
121123
if Array.includes(hiddenModules, id) {
@@ -255,7 +257,10 @@ let () = {
255257
}
256258
let rec getModules = (lst: list<Docgen.item>, moduleNames, path) => {
257259
switch lst {
258-
| list{Module({id, items, name}) | ModuleAlias({id, items, name}), ...rest} =>
260+
| list{
261+
Module({id, items, name}) | ModuleAlias({id, items, name}) | ModuleType({id, items, name}),
262+
...rest,
263+
} =>
259264
if Array.includes(hiddenModules, id) {
260265
getModules(rest, moduleNames, path)
261266
} else {

‎src/ApiDocs.res

+3-2
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ let default = (props: props) => {
307307
let valuesAndType = items->Array.map(item => {
308308
switch item {
309309
| Value({name, signature, docstrings, deprecated}) =>
310-
let code = String.replaceRegExp(signature, %re("/\\n/g"), "\n")
310+
let code = String.replaceRegExp(signature, /\\n/g, "\n")
311311
let slugPrefix = "value-" ++ name
312312
<>
313313
<H2 id=slugPrefix> {name->React.string} </H2>
@@ -316,7 +316,7 @@ let default = (props: props) => {
316316
<DocstringsStylize docstrings slugPrefix />
317317
</>
318318
| Type({name, signature, docstrings, deprecated}) =>
319-
let code = String.replaceRegExp(signature, %re("/\\n/g"), "\n")
319+
let code = String.replaceRegExp(signature, /\\n/g, "\n")
320320
let slugPrefix = "type-" ++ name
321321
<>
322322
<H2 id=slugPrefix> {name->React.string} </H2>
@@ -474,6 +474,7 @@ let processStaticProps = (~slug: array<string>, ~version: string) => {
474474
})
475475

476476
Variant({items: items})->Null.make
477+
| Signature(_) => Null.null
477478
}
478479
| None => Null.null
479480
}

‎src/Blog.res

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ module BlogCard = {
9595
{
9696
let className = "absolute top-0 h-full w-full object-cover"
9797
switch previewImg {
98-
| Some(src) => <img className src loading={#"lazy"} />
99-
| None => <img className src=defaultPreviewImg loading={#"lazy"} />
98+
| Some(src) => <img className src loading={#lazy} />
99+
| None => <img className src=defaultPreviewImg loading={#lazy} />
100100
}
101101
}
102102
</Link>

‎src/CommunityContent.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module LinkCard = {
2020
let make = (~link, ~index) => {
2121
let loading = switch index {
2222
| 0 => #eager
23-
| _ => #"lazy"
23+
| _ => #lazy
2424
}
2525
<div className="rounded-lg hover:text-fire overflow-hidden bg-gray-10 border-2 border-gray-30">
2626
<a href=link.url className="flex flex-col h-full">

‎src/ConsolePanel.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ let make = (~logs, ~appendLog) => {
3434
->Array.mapWithIndex(({level: logLevel, content: log}, i) => {
3535
let log = Array.join(log, " ")
3636
<pre
37-
key={RescriptCore.Int.toString(i)}
37+
key={Int.toString(i)}
3838
className={switch logLevel {
3939
| #log => ""
4040
| #warn => "text-orange"

‎src/SyntaxLookup.res

+6-6
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,14 @@ type params = {slug: string}
151151

152152
let decode = (json: JSON.t) => {
153153
open Json.Decode
154-
let id = json->(field("id", string, _))
155-
let keywords = json->(field("keywords", array(string, ...), _))
156-
let name = json->(field("name", string, _))
157-
let summary = json->(field("summary", string, _))
158-
let category = json->field("category", string, _)->Category.fromString
154+
let id = json->field("id", string, _)
155+
let keywords = json->field("keywords", array(string, ...), _)
156+
let name = json->field("name", string, _)
157+
let summary = json->field("summary", string, _)
158+
let category = json->(field("category", string, _))->Category.fromString
159159
let status =
160160
json
161-
->optional(field("status", string, _), _)
161+
->(optional(field("status", string, _), _))
162162
->Option.mapOr(Status.Active, Status.fromString)
163163

164164
{

‎src/Try.res

+3-5
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,9 @@ let getStaticProps: Next.GetStaticProps.t<props, _> = async _ => {
3737
switch line->String.startsWith("<a href") {
3838
| true =>
3939
// Adapted from https://semver.org/
40-
let semverRe = %re(
41-
"/v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?/"
42-
)
43-
switch Re.exec(semverRe, line) {
44-
| Some(result) => Re.Result.fullMatch(result)->Some
40+
let semverRe = /v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?/
41+
switch RegExp.exec(semverRe, line) {
42+
| Some(result) => RegExp.Result.fullMatch(result)->Some
4543
| None => None
4644
}
4745
| false => None

‎src/bindings/RescriptCompilerApi.res

+6-6
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,12 @@ module LocMsg = {
9797
let decode = (json): t => {
9898
open Json.Decode
9999
{
100-
fullMsg: json->(field("fullMsg", string, _)),
101-
shortMsg: json->(field("shortMsg", string, _)),
102-
row: json->(field("row", int, _)),
103-
column: json->(field("column", int, _)),
104-
endRow: json->(field("endRow", int, _)),
105-
endColumn: json->(field("endColumn", int, _)),
100+
fullMsg: json->field("fullMsg", string, _),
101+
shortMsg: json->field("shortMsg", string, _),
102+
row: json->field("row", int, _),
103+
column: json->field("column", int, _),
104+
endRow: json->field("endRow", int, _),
105+
endColumn: json->field("endColumn", int, _),
106106
}
107107
}
108108

‎src/common/Ansi.res

+5-5
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module Sgr = {
5454

5555
let esc = `\u001B`
5656

57-
let isAscii = (c: string) => Re.test(%re(`/[\x40-\x7F]/`), c)
57+
let isAscii = (c: string) => RegExp.test(/[\x40-\x7F]/, c)
5858

5959
module Location = {
6060
type t = {
@@ -177,9 +177,9 @@ module Lexer = {
177177

178178
let loc = {startPos, endPos: startPos + String.length(raw) - 1}
179179

180-
let token = switch Re.exec(%re(`/\[([0-9;]+)([\x40-\x7F])/`), raw) {
180+
let token = switch RegExp.exec(/\[([0-9;]+)([\x40-\x7F])/, raw) {
181181
| Some(result) =>
182-
let groups = Re.Result.matches(result)
182+
let groups = RegExp.Result.matches(result)
183183
switch groups[1] {
184184
| Some(str) =>
185185
switch String.split(str, ";") {
@@ -318,7 +318,7 @@ module SgrString = {
318318
let toString = (e: t): string => {
319319
let content = {
320320
open String
321-
replaceRegExp(e.content, %re("/\n/g"), "\\n")->replace(esc, "")
321+
replaceRegExp(e.content, /\n/g, "\\n")->replace(esc, "")
322322
}
323323
let params = Array.map(e.params, Sgr.paramToString)->Array.join(", ")
324324

@@ -334,7 +334,7 @@ module Printer = {
334334
| Text({content, loc: {startPos, endPos}}) =>
335335
let content = {
336336
open String
337-
replaceRegExp(content, %re("/\n/g"), "\\n")->replace(esc, "")
337+
replaceRegExp(content, /\n/g, "\\n")->replace(esc, "")
338338
}
339339
`Text "${content}" (${startPos->Int.toString} to ${endPos->Int.toString})`
340340
| Sgr({params, raw, loc: {startPos, endPos}}) =>

‎src/common/BlogApi.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type post = {
3030
}
3131

3232
let blogPathToSlug = path => {
33-
path->String.replaceRegExp(%re(`/^(archive\/)?\d\d\d\d-\d\d-\d\d-(.+)\.mdx$/`), "$2")
33+
path->String.replaceRegExp(/^(archive\/)?\d\d\d\d-\d\d-\d\d-(.+)\.mdx$/, "$2")
3434
}
3535

3636
let mdxFiles = dir => {

‎src/common/BlogFrontmatter.res

+8-8
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,16 @@ let authorDecoder = (~fieldName: string, ~authors) => {
134134
let decode = (json: JSON.t): result<t, string> => {
135135
open Json.Decode
136136
switch {
137-
author: json->field("author", string, _)->decodeAuthor(~fieldName="author", ~authors),
137+
author: json->(field("author", string, _))->decodeAuthor(~fieldName="author", ~authors),
138138
co_authors: json
139-
->optional(field("co-authors", authorDecoder(~fieldName="co-authors", ~authors), ...), _)
139+
->(optional(field("co-authors", authorDecoder(~fieldName="co-authors", ~authors), ...), _))
140140
->Option.getOr([]),
141-
date: json->field("date", string, _)->DateStr.fromString,
142-
badge: json->optional(j => field("badge", string, j)->decodeBadge, _)->Null.fromOption,
143-
previewImg: json->optional(field("previewImg", string, ...), _)->Null.fromOption,
144-
articleImg: json->optional(field("articleImg", string, ...), _)->Null.fromOption,
145-
title: json->(field("title", string, _)),
146-
description: json->(nullable(field("description", string, ...), _)),
141+
date: json->(field("date", string, _))->DateStr.fromString,
142+
badge: json->(optional(j => field("badge", string, j)->decodeBadge, _))->Null.fromOption,
143+
previewImg: json->(optional(field("previewImg", string, ...), _))->Null.fromOption,
144+
articleImg: json->(optional(field("articleImg", string, ...), _))->Null.fromOption,
145+
title: json->field("title", string, _),
146+
description: json->nullable(field("description", string, ...), _),
147147
} {
148148
| fm => Ok(fm)
149149
| exception DecodeError(str) => Error(str)

‎src/common/DateStr.res

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
type t = string
22

33
// Used to prevent issues with webkit based date representations
4-
let parse = (dateStr: string): Date.t =>
5-
dateStr->String.replaceRegExp(%re("/-/g"), "/")->Date.fromString
4+
let parse = (dateStr: string): Date.t => dateStr->String.replaceRegExp(/-/g, "/")->Date.fromString
65

76
let fromDate = date => Date.toString(date)
87
let toDate = dateStr => parse(dateStr)

‎src/common/Semver.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ let parse = (versionStr: string) => {
3030
}
3131

3232
// Some version contain a suffix. Example: v11.0.0-alpha.5, v11.0.0-beta.1
33-
let isPrerelease = versionStr->String.search(%re("/-/")) != -1
33+
let isPrerelease = versionStr->String.search(/-/) != -1
3434

3535
// Get the first part i.e vX.Y.Z
3636
let versionNumber = versionStr->String.split("-")->Array.get(0)->Option.getOr(versionStr)

‎src/common/Url.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ let prettyString = (str: string) => {
5858
let parse = (route: string): t => {
5959
let fullpath = route->String.split("/")->Array.filter(s => s !== "")
6060
let foundVersionIndex = Array.findIndex(fullpath, chunk => {
61-
Re.test(%re(`/latest|next|v\d+(\.\d+)?(\.\d+)?/`), chunk)
61+
RegExp.test(/latest|next|v\d+(\.\d+)?(\.\d+)?/, chunk)
6262
})
6363

6464
let (version, base, pagepath) = if foundVersionIndex == -1 {

‎src/components/Button.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let make = (
77
~kind: kind=PrimaryRed,
88
~size: size=Large,
99
~children,
10-
~onClick: option<JsxEventU.Mouse.t => unit>=?,
10+
~onClick: option<JsxEvent.Mouse.t => unit>=?,
1111
) => {
1212
let bgColor = switch kind {
1313
| PrimaryRed => "bg-fire hover:bg-fire-70 text-white"

‎src/components/Button.resi

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ let make: (
66
~kind: kind=?,
77
~size: size=?,
88
~children: React.element,
9-
~onClick: JsxEventU.Mouse.t => unit=?,
9+
~onClick: JsxEvent.Mouse.t => unit=?,
1010
) => React.element

‎src/components/CodeMirror.res

+12-34
Original file line numberDiff line numberDiff line change
@@ -66,46 +66,24 @@ module CM = {
6666
}
6767

6868
@module("codemirror")
69-
external onMouseOver: (
70-
Dom.element,
71-
@as("mouseover") _,
72-
@uncurry ReactEvent.Mouse.t => unit,
73-
) => unit = "on"
69+
external onMouseOver: (Dom.element, @as("mouseover") _, ReactEvent.Mouse.t => unit) => unit = "on"
7470

7571
@module("codemirror")
76-
external onMouseMove: (
77-
Dom.element,
78-
@as("mousemove") _,
79-
@uncurry ReactEvent.Mouse.t => unit,
80-
) => unit = "on"
72+
external onMouseMove: (Dom.element, @as("mousemove") _, ReactEvent.Mouse.t => unit) => unit = "on"
8173

8274
@module("codemirror")
83-
external offMouseOver: (
84-
Dom.element,
85-
@as("mouseover") _,
86-
@uncurry ReactEvent.Mouse.t => unit,
87-
) => unit = "off"
75+
external offMouseOver: (Dom.element, @as("mouseover") _, ReactEvent.Mouse.t => unit) => unit =
76+
"off"
8877

8978
@module("codemirror")
90-
external offMouseOut: (
91-
Dom.element,
92-
@as("mouseout") _,
93-
@uncurry ReactEvent.Mouse.t => unit,
94-
) => unit = "off"
79+
external offMouseOut: (Dom.element, @as("mouseout") _, ReactEvent.Mouse.t => unit) => unit = "off"
9580

9681
@module("codemirror")
97-
external offMouseMove: (
98-
Dom.element,
99-
@as("mousemove") _,
100-
@uncurry ReactEvent.Mouse.t => unit,
101-
) => unit = "off"
82+
external offMouseMove: (Dom.element, @as("mousemove") _, ReactEvent.Mouse.t => unit) => unit =
83+
"off"
10284

10385
@module("codemirror")
104-
external onMouseOut: (
105-
Dom.element,
106-
@as("mouseout") _,
107-
@uncurry ReactEvent.Mouse.t => unit,
108-
) => unit = "on"
86+
external onMouseOut: (Dom.element, @as("mouseout") _, ReactEvent.Mouse.t => unit) => unit = "on"
10987

11088
@module("codemirror")
11189
external fromTextArea: (Dom.element, Options.t) => t = "fromTextArea"
@@ -122,7 +100,7 @@ module CM = {
122100
@send external refresh: t => unit = "refresh"
123101

124102
@send
125-
external onChange: (t, @as("change") _, @uncurry t => unit) => unit = "on"
103+
external onChange: (t, @as("change") _, t => unit) => unit = "on"
126104

127105
@send external toTextArea: t => unit = "toTextArea"
128106

@@ -131,7 +109,7 @@ module CM = {
131109
@send external getValue: t => string = "getValue"
132110

133111
@send
134-
external operation: (t, @uncurry unit => unit) => unit = "operation"
112+
external operation: (t, unit => unit) => unit = "operation"
135113

136114
@send
137115
external setGutterMarker: (t, int, string, Dom.element) => unit = "setGutterMarker"
@@ -485,7 +463,7 @@ let extractRowColFromId = (id: string): option<(int, int)> =>
485463
| _ => None
486464
}
487465

488-
module ErrorHash = Belt.Id.MakeHashableU({
466+
module ErrorHash = Belt.Id.MakeHashable({
489467
type t = int
490468
let hash = a => a
491469
let eq = (a, b) => a == b
@@ -536,7 +514,7 @@ let updateErrors = (~state: state, ~onMarkerFocus=?, ~onMarkerFocusLeave=?, ~cm:
536514
(),
537515
),
538516
)
539-
->Array.push(state.marked, _)
517+
->(Array.push(state.marked, _))
540518
->ignore
541519
()
542520
}

‎src/components/Markdown.res

+4-4
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ module Code = {
234234
String.split(metastring, " ")
235235
->Array.find(s => String.startsWith(s, "{") && String.endsWith(s, "}"))
236236
->Option.map(str => {
237-
let nums = String.replaceRegExp(str, %re("/[\{\}]/g"), "")->parseNumericRange
237+
let nums = String.replaceRegExp(str, /[\{\}]/g, "")->parseNumericRange
238238
nums
239239
})
240240
->Option.getOr([])
@@ -248,9 +248,9 @@ module Code = {
248248

249249
let highlightedLines = parseNumericRangeMeta(metastring)
250250

251-
if List.has(metaSplits, "example", \"=") {
251+
if List.has(metaSplits, "example", String.equal) {
252252
<CodeExample code lang />
253-
} else if List.has(metaSplits, "sig", \"=") {
253+
} else if List.has(metaSplits, "sig", String.equal) {
254254
<CodeExample code lang showLabel=false />
255255
} else {
256256
<CodeExample highlightedLines code lang />
@@ -374,7 +374,7 @@ module A = {
374374
// Ideally one would check if this link is relative first,
375375
// but it's very unlikely we'd refer to an absolute URL ending
376376
// with .md
377-
let regex = %re("/\.md(x)?|\.html$/")
377+
let regex = /\.md(x)?|\.html$/
378378
let href = switch String.split(href, "#") {
379379
| [pathname, anchor] => String.replaceRegExp(pathname, regex, "") ++ ("#" ++ anchor)
380380
| [pathname] => String.replaceRegExp(pathname, regex, "")

‎src/vendor/Json_decode.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ let string = json =>
4141
let char = json => {
4242
let s = string(json)
4343
if String.length(s) == 1 {
44-
OCamlCompat.String.get(s, 0)
44+
String.getUnsafe(s, 0)->Obj.magic
4545
} else {
4646
\"@@"(raise, DecodeError("Expected single-character string, got " ++ JSON.stringify(json)))
4747
}

‎src/vendor/Json_encode.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ external float: float => JSON.t = "%identity"
66
external int: int => JSON.t = "%identity"
77
external bool: bool => JSON.t = "%identity"
88

9-
let char = c => string(OCamlCompat.String.make(1, c))
9+
let char = c => string(String.make(c))
1010

1111
let date = d => string(Date.toJSON(d)->Option.getUnsafe)
1212

0 commit comments

Comments
 (0)
Please sign in to comment.