Skip to content

Update rescript + webapi and do a npm cleanup #1083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const bsconfig = JSON.parse(

const { ProvidePlugin } = webpack;

const transpileModules = ["rescript"].concat(bsconfig["bs-dependencies"]);
const transpileModules = ["rescript"].concat(bsconfig["dependencies"]);

/** @type {import("next").NextConfig} */
const config = {
Expand Down
79 changes: 35 additions & 44 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
"@headlessui/react": "^2.2.4",
"@mdx-js/loader": "^3.1.0",
"@rescript/react": "^0.14.0-rc.1",
"@rescript/webapi": "^0.1.0-experimental-03eae8b",
"@rescript/webapi": "^0.1.0-experimental-0b87498",
"codemirror": "^5.54.0",
"docson": "^2.1.0",
"escodegen": "^2.1.0",
"eslint-config-next": "^13.1.1",
"fuse.js": "^6.4.3",
"gentype": "^3.44.0",
"glob": "^7.1.4",
"highlight.js": "^11.9.0",
"highlightjs-rescript": "^0.2.2",
Expand All @@ -42,7 +41,7 @@
"remark-rehype": "^11.1.1",
"remark-stringify": "^11.0.0",
"request": "^2.88.0",
"rescript": "^12.0.0-alpha.14",
"rescript": "^12.0.0-beta.6",
"stringify-object": "^3.3.0",
"unified": "^11.0.5",
"vfile-matter": "^5.0.0"
Expand Down
7 changes: 3 additions & 4 deletions rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@
"jsx": {
"version": 4
},
"bs-dependencies": ["@rescript/react", "@rescript/webapi"],
"bsc-flags": ["-open WebAPI.Global"],
"dependencies": ["@rescript/react", "@rescript/webapi"],
"compiler-flags": ["-open WebAPI.Global"],
"sources": [
{
"dir": "src",
"subdirs": true
},
{
"dir": "scripts",
"subdirs": true,
"type": "dev"
"subdirs": true
}
],
"package-specs": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/gendocs.res
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ node scripts/gendocs.mjs path/to/rescript-compiler latest true
open Node
module Docgen = RescriptTools.Docgen

let args = Process.argv->Array.sliceToEnd(~start=2)
let args = Process.argv->Array.slice(~start=2)
let dirname =
url
->URL.fileURLToPath
Expand Down
2 changes: 1 addition & 1 deletion src/ApiDocs.res
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ module DocstringsStylize = {
[Rehype.WithOptions([Plugin(Rehype.slug), SlugOption({prefix: slugPrefix ++ "-"})])]->Some

let content = switch docstrings->Array.length > 1 {
| true => docstrings->Array.sliceToEnd(~start=1)
| true => docstrings->Array.slice(~start=1)
| false => docstrings
}->Array.join("\n")

Expand Down
2 changes: 1 addition & 1 deletion src/Blog.res
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ let default = (props: props): React.element => {
| 0 => <div> {React.string("No posts for this category available...")} </div>
| _ =>
let first = Belt.Array.getExn(posts, 0)
let rest = Array.sliceToEnd(posts, ~start=1)
let rest = Array.slice(posts, ~start=1)

let featureBox =
<div className="w-full mb-24 lg:px-8 xl:px-0">
Expand Down
4 changes: 0 additions & 4 deletions src/Playground.res
Original file line number Diff line number Diff line change
Expand Up @@ -1478,10 +1478,6 @@ let make = (~versions: array<string>) => {
(),
)

let overlayState = React.useState(() => false)

let windowWidth = CodeMirror.useWindowWidth()

let (keyMap, setKeyMap) = React.useState(() => {
Dom.Storage2.localStorage
->Dom.Storage2.getItem("vimMode")
Expand Down
6 changes: 3 additions & 3 deletions src/common/CompilerManagerHook.res
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ let wrapReactApp = code =>

let capitalizeFirstLetter = string => {
let firstLetter = string->String.charAt(0)->String.toUpperCase
`${firstLetter}${string->String.sliceToEnd(~start=1)}`
`${firstLetter}${string->String.slice(~start=1)}`
}

type error =
Expand Down Expand Up @@ -548,11 +548,11 @@ let useCompilerManager = (
let ast = Parser.parse(jsCode, {sourceType: "module"})
let {entryPointExists, code, imports} = PlaygroundValidator.validate(ast)
let imports = imports->Dict.mapValues(path => {
let filename = path->String.sliceToEnd(~start=9) // the part after "./stdlib/"
let filename = path->String.slice(~start=9) // the part after "./stdlib/"
let filename = switch state.selected.id {
| {major: 12, minor: 0, patch: 0, preRelease: Some(Alpha(alpha))} if alpha < 8 =>
let filename = if filename->String.startsWith("core__") {
filename->String.sliceToEnd(~start=6)
filename->String.slice(~start=6)
} else {
filename
}
Expand Down
23 changes: 5 additions & 18 deletions src/common/MetaTagsApi.res
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,9 @@ let extractMetaTags = async (url: string) => {
}

let metaTags = elements->Array.reduce(Dict.fromArray([]), (tags, meta) => {
let name =
meta
->WebAPI.Element.getAttribute("name")
->Null.make
let property =
meta
->WebAPI.Element.getAttribute("property")
->Null.make
let itemprop =
meta
->WebAPI.Element.getAttribute("itemprop")
->Null.make
let name = meta->WebAPI.Element.getAttribute("name")
let property = meta->WebAPI.Element.getAttribute("property")
let itemprop = meta->WebAPI.Element.getAttribute("itemprop")

let name = switch (name, property, itemprop) {
| (Value(name), _, _) => Some(name)
Expand All @@ -47,14 +38,10 @@ let extractMetaTags = async (url: string) => {
| _ => None
}

let content =
meta
->WebAPI.Element.getAttribute("content")
->Nullable.make
->Nullable.toOption
let content = meta->WebAPI.Element.getAttribute("content")

switch (name, content) {
| (Some(name), Some(content)) => tags->Dict.set(name, content)
| (Some(name), Value(content)) => tags->Dict.set(name, content)
| _ => ()
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/CodeMirror.res
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ type state = {mutable marked: array<CM.TextMarker.t>, mutable hoverHints: array<

let isSpanToken = (element: WebAPI.DOMAPI.element) =>
element.tagName->String.toUpperCase === "SPAN" &&
element->WebAPI.Element.getAttribute("role") !== "presentation"
element->WebAPI.Element.getAttribute("role") !== Value("presentation")

let useHoverTooltip = (~cmStateRef: React.ref<state>, ~cmRef: React.ref<option<CM.t>>, ()) => {
let stateRef = React.useRef(HoverTooltip.Hidden)
Expand All @@ -273,7 +273,7 @@ let useHoverTooltip = (~cmStateRef: React.ref<state>, ~cmRef: React.ref<option<C
let checkIfTextMarker = (element: WebAPI.DOMAPI.element) => {
let isToken =
element.tagName->String.toUpperCase === "SPAN" &&
element->WebAPI.Element.getAttribute("role") !== "presentation"
element->WebAPI.Element.getAttribute("role") !== Value("presentation")

isToken && RegExp.test(/CodeMirror-hover-hint-marker/, element.className)
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Search.res
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ let appId = "S32LNEY41T"
type state = Active | Inactive

let hit = ({hit, children}: DocSearch.hitComponent) => {
let toTitle = str => str->String.charAt(0)->String.toUpperCase ++ String.sliceToEnd(str, ~start=1)
let toTitle = str => str->String.charAt(0)->String.toUpperCase ++ String.slice(str, ~start=1)

let description = switch hit.url
->String.split("/")
->Array.sliceToEnd(~start=1)
->Array.slice(~start=1)
->List.fromArray {
| list{"blog" as r | "community" as r, ..._} => r->toTitle
| list{"docs", doc, version, ...rest} =>
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/ApiLayout.res
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ let makeBreadcrumbs = (~prefix: Url.breadcrumb, route: string): list<Url.breadcr
let url = route->Url.parse

let (_, rest) = // Strip the "api" part of the url before creating the rest of the breadcrumbs
Array.sliceToEnd(url.pagepath, ~start=1)->Array.reduce((prefix.href, []), (acc, path) => {
Array.slice(url.pagepath, ~start=1)->Array.reduce((prefix.href, []), (acc, path) => {
let (baseHref, ret) = acc

let href = baseHref ++ ("/" ++ path)
Expand Down