Skip to content
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
13 changes: 13 additions & 0 deletions .github/scripts/clean-tracked-rescript-output.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -euo pipefail

# rescript clean only knows sources that still belong to the build. Identify
# tracked compiler output from the index so deleted/excluded sources are covered,
# while handwritten JavaScript and configuration remain untouched.
git ls-files -z -- '*.jsx' '*.mjs' |
while IFS= read -r -d '' output; do
committed=$(git show ":$output")
if [[ "$committed" == "// Generated by ReScript,"* ]]; then
rm -f -- "$output"
fi
done
4 changes: 3 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
cache: yarn
- name: Install dependencies
run: yarn
- name: Format check
- name: Check formatting (Oxfmt and ReScript)
run: yarn ci:format
Site_Checks:
runs-on: ubuntu-latest
Expand All @@ -39,6 +39,8 @@ jobs:
run: |
yarn check:routes
git diff --exit-code -- packages/shared/src/Path.res
- name: Check committed ReScript output
run: yarn ci:generated
- name: Test examples and hrefs
run: yarn test
# Check the built Docs Pages routes and the Guide local dev server.
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,21 @@ ReScript builds and when starting the ReScript watcher. After changing routes,
adding or removing MDX pages, or updating API data during a watch session, run
`yarn build:routes` again. CI rejects a stale generated file.

### Formatting and Generated Output

`yarn ci:format` checks Oxfmt formatting and ReScript formatting across all four
workspaces. Run `yarn format` to apply both formatters.

`yarn ci:generated` cleans ReScript artifacts, removes tracked compiler output,
and rebuilds, then fails if any tracked `.jsx` or `.mjs` file differs from the
committed version. Most compiler output is ignored by Git; the guide's
`app/root.jsx` and `app/routes.jsx` are currently tracked. After changing their
ReScript sources or updating the compiler, run `yarn build:res` and commit the
regenerated output alongside the sources.

Both checks run on pull requests. Removing tracked output before rebuilding also
catches orphaned output whose source was deleted or excluded from the build.

### Vitest Browser Tests

We use [Vitest](https://vitest.dev/) in browser mode with Playwright for component-level tests. Test files live in `__tests__/` and are written in ReScript.
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dev:vite": "react-router dev --host",
"dev:wrangler": "yarn build:vite && yarn wrangler pages dev build/client",
"dev": "yarn prepare && yarn dev:res & yarn dev:vite & yarn dev:wrangler",
"format": "cd ../.. && oxfmt && cd apps/docs && rescript format",
"format": "cd ../.. && yarn format",
"prepare": "yarn build:res && yarn build:scripts && yarn check:algolia-public-env && yarn build:update-index",
"preview": "yarn build && static-server build/client",
"serve:build": "static-server --host 127.0.0.1 --port 4173 build/client",
Expand Down
4 changes: 3 additions & 1 deletion apps/guide/app/routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ import * as Routes from "@react-router/dev/routes";

let $$default = [Routes.index("./GuideHomeRoute.jsx")];

export { $$default as default };
export {
$$default as default,
}
/* default Not a pure module */
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
"build:update-index": "yarn workspace @rescript-lang/docs build:update-index",
"build:vite": "yarn workspace @rescript-lang/docs build:vite",
"build": "yarn workspace @rescript-lang/docs build",
"ci:format": "oxfmt --check",
"ci:format": "oxfmt --check && rescript format --check",
"ci:generated": "yarn clean:res && bash .github/scripts/clean-tracked-rescript-output.sh && yarn build:res && git diff --exit-code -- '*.jsx' '*.mjs'",
"ci:test": "yarn workspace @rescript-lang/docs ci:test && yarn workspace @rescript-lang/guide ci:test",
"ci:test:visual": "yarn workspace @rescript-lang/docs ci:test:visual",
"clean:res": "rescript clean",
"convert-images": "yarn workspace @rescript-lang/docs convert-images",
"dev:res": "yarn build:routes && rescript watch",
"dev:guide": "yarn workspace @rescript-lang/guide dev:vite",
"dev": "yarn workspace @rescript-lang/docs dev",
"format": "yarn workspace @rescript-lang/docs format",
"format": "oxfmt && rescript format",
"preview": "yarn workspace @rescript-lang/docs preview",
"reanalyze": "yarn workspace @rescript-lang/docs reanalyze",
"test": "yarn workspace @rescript-lang/docs test",
Expand Down
Loading