Skip to content
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

Migrate to ReScript v11 #738

Merged
merged 30 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f07271b
first test: compiling
aspeddro Oct 25, 2023
b654f99
fixes
aspeddro Oct 26, 2023
eb94e03
Merge branch 'remove-unsafe-string-inter' into migrate-rescript-v11
aspeddro Oct 28, 2023
d70fb2f
fixed playground
aspeddro Oct 29, 2023
b42f2b7
compiling
aspeddro Oct 29, 2023
2cfb4bc
Merge branch 'master' into test-jsx-v4
aspeddro Oct 29, 2023
b8118bf
done
aspeddro Oct 29, 2023
dca1fa7
Merge branch 'master' into migrate-rescript-v11
aspeddro Oct 29, 2023
6584435
Merge branch 'test-jsx-v4' into migrate-rescript-v11
aspeddro Oct 29, 2023
0190f67
migrate to v11
aspeddro Oct 29, 2023
1e6ca8c
remove log
aspeddro Oct 29, 2023
cadc3e2
remove comment
aspeddro Oct 29, 2023
e5dc492
playground: fix format
aspeddro Oct 29, 2023
2e4b6bb
add rehype-slug
aspeddro Oct 29, 2023
ff120fb
checkout .bs.mjs
aspeddro Oct 29, 2023
7990f88
fix test
aspeddro Oct 29, 2023
7a6b5dc
fix typo and update to rc5
aspeddro Oct 31, 2023
16e1036
Vendored bs-json converted to .res
cknitt Nov 1, 2023
59d6047
add Json lib
aspeddro Nov 1, 2023
e9a7755
Merge branch 'bs-json-res' into migrate-rescript-v11
aspeddro Nov 1, 2023
47a9d5b
back to vendored Json lib
aspeddro Nov 1, 2023
707644e
back to .mjs files
aspeddro Nov 1, 2023
9ba5161
back to json decode
aspeddro Nov 2, 2023
1b3bc12
reduce diff
aspeddro Nov 2, 2023
4e50432
format
aspeddro Nov 2, 2023
c59c44d
add Json interface files
aspeddro Nov 17, 2023
af26d28
use type alias
aspeddro Nov 17, 2023
3482f98
update to rescript-rc.6
aspeddro Nov 23, 2023
d6624a8
Merge branch 'master' into migrate-rescript-v11
aspeddro Nov 25, 2023
b45987b
fix warnings
aspeddro Nov 29, 2023
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ lib/

.vercel

src/**/*.mjs
*.bs.mjs
4 changes: 2 additions & 2 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import remarkFrontmatter from 'remark-frontmatter'
import remarkMdxFrontmatter from "remark-mdx-frontmatter";
import { createLoader } from 'simple-functional-loader'

const bsconfig = JSON.parse(fs.readFileSync("./bsconfig.json"))
const bsconfig = JSON.parse(fs.readFileSync("./rescript.json"))

const { ProvidePlugin } = webpack;

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

const config = {
pageExtensions: ["jsx", "js", "bs.js", "mdx", "mjs"],
pageExtensions: ["jsx", "js", "bs.mjs", "mdx", "mjs"],
env: {
ENV: process.env.NODE_ENV,
},
Expand Down
47 changes: 19 additions & 28 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 @@ -17,8 +17,7 @@
"dependencies": {
"@headlessui/react": "^1.2.0",
"@mdx-js/loader": "^2.3.0",
"@rescript/react": "^0.10.3",
"@ryyppy/rescript-promise": "2.1.0",
"@rescript/react": "^0.12.0-alpha.3",
"codemirror": "^5.54.0",
"docson": "^2.1.0",
"eslint-config-next": "^13.1.1",
Expand Down Expand Up @@ -60,7 +59,7 @@
"postcss": "^8.4.27",
"postcss-cli": "^8.3.0",
"reanalyze": "^2.16.0",
"rescript": "^10.1.4",
"rescript": "^11.0.0-rc.4",
"simple-functional-loader": "^1.2.1",
"tailwindcss": "^3.3.3"
}
Expand Down
2 changes: 1 addition & 1 deletion pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import "codemirror/lib/codemirror.css";
import "styles/cm.css";
import "styles/docson.css";

import {make as ResApp} from "src/common/App.mjs";
import {make as ResApp} from "src/common/App.bs.mjs";

export default function App(props) {
return <ResApp {...props} />
Expand Down
2 changes: 1 addition & 1 deletion pages/api/revalidate.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { handler as default } from "src/others/Revalidate.mjs";
export { handler as default } from "src/others/Revalidate.bs.mjs";
4 changes: 2 additions & 2 deletions pages/blog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BlogRes from "src/Blog.mjs";
import BlogRes from "src/Blog.bs.mjs";

export { getStaticProps } from "src/Blog.mjs";
export { getStaticProps } from "src/Blog.bs.mjs";

export default function Blog(props) {
return <BlogRes {...props} />
Expand Down
2 changes: 1 addition & 1 deletion pages/blog/[slug].js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export {
default,
getStaticPaths,
getStaticProps
} from "src/BlogArticle.mjs";
} from "src/BlogArticle.bs.mjs";
2 changes: 1 addition & 1 deletion pages/docs/latest.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import make from "src/DocsOverview.mjs";
import make from "src/DocsOverview.bs.mjs";

export default make;
2 changes: 1 addition & 1 deletion pages/docs/v8.0.0.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import make from "src/DocsOverview.mjs";
import make from "src/DocsOverview.bs.mjs";

export default make;
2 changes: 1 addition & 1 deletion pages/docs/v9.0.0.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import make from "src/DocsOverview.mjs";
import make from "src/DocsOverview.bs.mjs";

export default make;
4 changes: 2 additions & 2 deletions pages/packages.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Comp from "src/Packages"
import Comp from "src/Packages.bs.mjs"

export { getStaticProps } from "src/Packages"
export { getStaticProps } from "src/Packages.bs.mjs"

export default function PackagesPage(props) {
return <Comp {...props}/>;
Expand Down
4 changes: 2 additions & 2 deletions pages/syntax-lookup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SyntaxLookupRes from "src/SyntaxLookup.mjs";
import SyntaxLookupRes from "src/SyntaxLookup.bs.mjs";

export { getStaticProps } from "src/SyntaxLookup.mjs";
export { getStaticProps } from "src/SyntaxLookup.bs.mjs";

export default function SyntaxLookup(props) {
return <SyntaxLookupRes {...props} />
Expand Down
20 changes: 1 addition & 19 deletions pages/try.js
Original file line number Diff line number Diff line change
@@ -1,19 +1 @@
import dynamic from "next/dynamic";

export { getStaticProps } from "src/Try.mjs";
import Try from "src/Try.mjs";

const Playground = dynamic(() => import("src/Playground.mjs"), {
ssr: false,
loading: () => <span>Loading...</span>
});

function Comp(props) {
return (
<Try>
<Playground {...props} />
</Try>
);
}

export default Comp;
export { getStaticProps, default } from "src/Try.bs.mjs";
10 changes: 5 additions & 5 deletions bsconfig.json → rescript.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "rescript-lang.org",
"namespace": false,
"reason": {
"react-jsx": 3
"jsx": {
"version": 4
},
"bs-dependencies": [
"@rescript/react",
"@ryyppy/rescript-promise"
"@rescript/react"
],
"uncurried": true,
"ppx-flags": [],
"sources": [
{
Expand All @@ -27,7 +27,7 @@
"warnings": {
"error": "+8"
},
"suffix": ".mjs",
"suffix": ".bs.mjs",
aspeddro marked this conversation as resolved.
Show resolved Hide resolved
"bsc-flags": [
"-bs-g"
],
Expand Down
12 changes: 0 additions & 12 deletions scripts/generate_feed.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/test-hrefs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import path from "path";
import fs from "fs";
import urlModule from "url";
import { URL } from 'url';
import {getAllPosts, blogPathToSlug} from '../src/common/BlogApi.mjs'
import {getAllPosts, blogPathToSlug} from '../src/common/BlogApi.bs.mjs'

const pathname = new URL('.', import.meta.url).pathname;
const __dirname = process.platform !== 'win32' ? pathname : pathname.substring(1)
Expand Down
15 changes: 6 additions & 9 deletions src/Blog.res
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,7 @@ module BlogCard = {
<Badge badge />
</div>
}}
<Link
href="/blog/[slug]"
_as={"/blog/" ++ slug}
className="relative hl-title block mb-4 pt-9/16">
<Link href={`/blog/${slug}`} className="relative hl-title block mb-4 pt-9/16">
{
let className = "absolute top-0 h-full w-full object-cover"
switch previewImg {
Expand All @@ -115,7 +112,7 @@ module BlogCard = {
</Link>
</div>
<div className="px-2">
<Link href="/blog/[slug]" _as={"/blog/" ++ slug}>
<Link href={`/blog/${slug}`}>
<h2 className="hl-4"> {React.string(title)} </h2>
</Link>
<div className="captions text-gray-40 pt-1">
Expand Down Expand Up @@ -156,7 +153,7 @@ module FeatureCard = {
~maxHeight="25.4375rem",
(),
)}>
<Link href="/blog/[slug]" _as={"/blog/" ++ slug} className="relative block pt-2/3">
<Link href={`/blog/${slug}`} className="relative block pt-2/3">
{switch badge {
| Some(badge) =>
<div className="absolute z-10 top-0 mt-10 ml-4 lg:-ml-4">
Expand Down Expand Up @@ -202,7 +199,7 @@ module FeatureCard = {
<p className="body-md text-gray-70"> {React.string(firstParagraph)} </p>
</div>
</div>
<Link href="/blog/[slug]" _as={"/blog/" ++ slug}>
<Link href={`/blog/${slug}`}>
<Button> {React.string("Read Article")} </Button>
</Link>
</div>
Expand Down Expand Up @@ -304,13 +301,13 @@ let default = (props: props): React.element => {
<Navigation overlayState />
<div className="flex justify-center overflow-hidden">
<main className="min-w-320 lg:align-center w-full lg:px-0 max-w-1280 pb-48">
<Mdx.Provider components=Markdown.default>
<MdxProvider components=MarkdownComponents.default>
<div className="flex justify-center">
<div className="w-full" style={ReactDOMStyle.make(~maxWidth="66.625rem", ())}>
content
</div>
</div>
</Mdx.Provider>
</MdxProvider>
</main>
</div>
<Footer />
Expand Down
35 changes: 11 additions & 24 deletions src/BlogArticle.res
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module Params = {
type t = {slug: string}
}

type props = {mdxSource: Mdx.Remote.output, isArchived: bool, path: string}
type props = {mdxSource: MdxRemote.output, isArchived: bool, path: string}

module Line = {
@react.component
Expand Down Expand Up @@ -116,29 +116,16 @@ module BlogHeader = {
}
}

type remarkPlugin
@module("remark-comment") external remarkComment: remarkPlugin = "default"
@module("remark-gfm") external remarkGfm: remarkPlugin = "default"
@module("remark-frontmatter") external remarkFrontmatter: remarkPlugin = "default"

let mdxOptions = {"remarkPlugins": [remarkComment, remarkGfm, remarkFrontmatter]}

external asProps: {..} => {"props": Mdx.Remote.output} = "%identity"

let default = (props: props) => {
let {mdxSource, isArchived, path} = props

let mdxProps = {
"frontmatter": mdxSource.frontmatter,
"scope": mdxSource.scope,
"compiledSource": mdxSource.compiledSource,
"components": Markdown.default,
"options": {
"mdxOptions": mdxOptions,
},
}

let children = React.createElement(Mdx.MDXRemote.make, asProps(mdxProps))
let children =
<MdxRemote
frontmatter={mdxSource.frontmatter}
compiledSource={mdxSource.compiledSource}
scope={mdxSource.scope}
components={MarkdownComponents.default}
/>

let fm = mdxSource.frontmatter->BlogFrontmatter.decode

Expand Down Expand Up @@ -230,11 +217,11 @@ let getStaticProps: Next.GetStaticProps.t<props, Params.t> = async ctx => {

let isArchived = Js.String2.startsWith(path, "archive/")

let source = filePath->Node.Fs.readFileSync(#utf8)
let source = filePath->Node.Fs.readFileSync

let mdxSource = await Mdx.Remote.serialize(
let mdxSource = await MdxRemote.serialize(
source,
{"parseFrontmatter": true, "mdxOptions": mdxOptions},
{parseFrontmatter: true, mdxOptions: MdxRemote.defaulltMdxOptions},
)

let props = {mdxSource, isArchived, path}
Expand Down
Loading