Skip to content
Draft
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
55 changes: 55 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Deploy to Cloudflare Pages
on:
push:
branches:
- master
workflow_dispatch:
inputs:
environment:
description: "Choose an environment to deploy to: <dev|staging|prod>"
required: true
default: "dev"
pull_request:
branches:
- master

jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
permissions:
contents: read
deployments: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Setup yarn
uses: actions/setup-node@v3
with:
cache: "yarn"
node-version: "24"
- name: Install dependencies
run: yarn install
- name: Build
run: yarn build
- name: Deploy
id: deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy out --project-name=rescript-lang-org
# Optional: Enable this if you want to have GitHub Deployments triggered
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
- name: Comment PR with deployment link
uses: marocchino/sticky-pull-request-comment@v2
with:
recreate: true
message: |
## Deployed ${{ steps.deploy.outputs.pages-deployment-id }} to Cloudflare Pages ${{ steps.deploy.outputs.pages-environment }}
Deployment Status: ${{ steps.deploy.conclusion }}
Deployment Url: ${{ steps.deploy.outputs.deployment-url }}
Deployment Alias Url: ${{ steps.deploy.outputs.pages-deployment-alias-url }}
${{ steps.deploy.outputs.command-output }}
${{ steps.deploy.outputs.command-stderr }}
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ jobs:
node-version-file: ".node-version"
cache: yarn
- run: yarn
- run: yarn res:build --warn-error +3+8+11+12+26+27+31+32+33+34+35+39+44+45+110
- run: yarn build:res --warn-error +3+8+11+12+26+27+31+32+33+34+35+39+44+45+110
- run: yarn test
- run: yarn ci:format
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,11 @@ app/**/*.jsx
!.yarn/sdks
!.yarn/versions

# wrangler
.wrangler

# Scripts generated from rolldown to convert them from .jsx files to .mjs files
_scripts
_scripts

# Local env files
.env
30 changes: 1 addition & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,10 @@ This is the official documentation platform for the [ReScript](https://rescript-
# For first time clone / build (install dependencies)
yarn

# Initial build
yarn rescript

# Build the index data. Only needed for initial clone (or content H2 changes)
yarn update-index

# In a new tab
# Run ReScript, Vite, and Wrangler in development mode
yarn dev

open localhost:3000
```

In case you want to run ReScript in watchmode:

```sh
yarn rescript -w
```

## Build Index Data

We are parsing our content for specific index data (such as, all interesting
search terms we need for searching inside the `Belt` docs). You can create your
index by running following command:

```sh
yarn update-index
```

All the index data is stored in `index_data`, but will not be tracked by git.
Make sure to build the index after a fresh clone, otherwise Next might not
build specific pages (file `index_data/x.json` not found).

## Project Structure Overview

- `data`: Contains hand-curated data, such as sidebar ordering, blog data, etc
Expand Down
4 changes: 4 additions & 0 deletions functions/echo.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export function onRequest(context) {
const url = new URL(context.request.url);
return new Response(url.searchParams.toString());
}
6 changes: 3 additions & 3 deletions markdown-pages/docs/manual/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ bun create rescript-app
- Trigger a ReScript build:

```sh
npm run res:build
npm run build:res
```
- If you selected the "basic" template, simply run it with:

Expand Down Expand Up @@ -156,8 +156,8 @@ bun create rescript-app
- Add convenience `npm` scripts to `package.json`:
```json
"scripts": {
"res:build": "rescript",
"res:dev": "rescript -w"
"build:res": "rescript",
"dev:res": "rescript watch"
}
```

Expand Down
2 changes: 1 addition & 1 deletion markdown-pages/docs/manual/typescript-integration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ In case of the TypeScript project using `Bundler` module resolution, `allowImpor

Open any relevant `*.res` file and add `@genType` annotations to any bindings / values / functions to be used from JavaScript. If an annotated value uses a type, the type must be annotated too. See e.g. [Hooks.res](https://github.com/rescript-lang/rescript-compiler/blob/master/jscomp/gentype_tests/typescript-react-example/src/Hooks.res).

Save the file and rebuild the project via `npm run res:build` or similar. You should now see a `*.gen.tsx` file with the same name (e.g. `MyComponent.res` -> `MyComponent.gen.tsx`).
Save the file and rebuild the project via `npm run build:res` or similar. You should now see a `*.gen.tsx` file with the same name (e.g. `MyComponent.res` -> `MyComponent.gen.tsx`).

Any values exported from `MyComponent.res` can then be imported from TypeScript. For example:

Expand Down
33 changes: 19 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,25 @@
"packageManager": "[email protected]",
"type": "module",
"scripts": {
"dev": "react-router dev --host",
"res:watch": "rescript watch",
"res:clean": "rescript clean",
"res:build": "rescript build",
"build": "rescript build && yarn build-scripts && yarn update-index && react-router build",
"test": "node scripts/test-examples.mjs && node scripts/test-hrefs.mjs",
"update-index": "yarn generate-llms && node _scripts/generate_feed.mjs > public/blog/feed.xml",
"reanalyze": "rescript-tools reanalyze -all-cmt .",
"sync-bundles": "node scripts/sync-playground-bundles.mjs",
"generate-llms": "node _scripts/generate_llms.mjs",
"format": "prettier . --write --experimental-cli && rescript format",
"build:generate-llms": "node _scripts/generate_llms.mjs",
"build:res": "rescript build",
"build:scripts": "yarn dlx tsdown scripts/*.jsx -d _scripts --no-clean --ext .mjs",
"build:sync-bundles": "node scripts/sync-playground-bundles.mjs",
"build:update-index": "yarn build:generate-llms && node _scripts/generate_feed.mjs > public/blog/feed.xml",
"build:vite": "react-router build",
"build": "yarn build:res && yarn build:scripts && yarn build:update-index && yarn build:vite",
"ci:format": "prettier . --check --experimental-cli",
"preview": "yarn build && static-server build/client",
"clean:res": "rescript clean",
"convert-images": "auto-convert-images",
"build-scripts": "yarn dlx tsdown scripts/*.jsx -d _scripts --no-clean --ext .mjs"
"dev:res": "rescript watch",
"dev:vite": "react-router dev --host",
"dev:wrangler": "yarn wrangler pages dev build/client",
"dev": "yarn prepare && yarn dev:res & yarn dev:vite & yarn dev:wrangler",
"format": "prettier . --write --experimental-cli && rescript format",
"prepare": "yarn build:res && yarn build:scripts && yarn build:update-index",
"preview": "yarn build && static-server build/client",
"reanalyze": "rescript-tools reanalyze -all-cmt .",
"test": "node scripts/test-examples.mjs && node scripts/test-hrefs.mjs"
},
"dependencies": {
"@babel/generator": "^7.24.7",
Expand Down Expand Up @@ -93,6 +97,7 @@
"vite": "^7.0.6",
"vite-plugin-devtools-json": "^1.0.0",
"vite-plugin-env-compatible": "^2.0.1",
"vite-plugin-page-reload": "^0.2.2"
"vite-plugin-page-reload": "^0.2.2",
"wrangler": "^4.51.0"
}
}
Loading