Skip to content

Commit fefd9a0

Browse files
authored
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)

0 commit comments

Comments
 (0)