create-rescript-app is the official CLI tool for scaffolding new ReScript applications. It supports creating projects from templates and adding ReScript to existing JavaScript projects. The tool is written in ReScript and distributed as a bundled Node.js CLI.
- Make sure to use modern ReScript and not Reason syntax! Read https://rescript-lang.org/llms/manual/llm-small.txt to learn the language syntax.
- Formatting is enforced by
rescript format; keep 2-space indentation and prefer pattern matching over chained conditionals. - Module files are PascalCase (
Templates.res), values/functions camelCase, types/variants PascalCase, and records snake_case fields only when matching external JSON. - Keep
.resisignatures accurate and minimal; avoid exposing helpers that are template-specific. - When touching templates, mirror upstream defaults and keep package scripts consistent with the chosen toolchain.
- Detects and supports npm, yarn, pnpm, and bun
- Handles existing project detection based on presence of
package.json - Adapts installation commands based on detected package manager
src/: ReScript source fileslib/: Generated build artifacts from ReScript compiler (do not edit)out/: Production bundle (create-rescript-app.cjs) for distributiontemplates/: Project starter templates (keep self-contained)bindings/: External library bindings (ClackPrompts, CompareVersions)
npm start- Run CLI directly from source (src/Main.res.mjs) for interactive testing and developmentnpm run dev- Watch ReScript sources and rebuild automatically tolib/directorynpm run prepack- Compile ReScript and bundle with Rollup intoout/create-rescript-app.cjs(production build)npm run format- Apply ReScript formatter across all source files
- Manual Testing: No automated test suite - perform smoke tests by running the CLI into a temp directory
- Template Validation: After changes, test each template type (basic/Next.js/Vite) to ensure templates bootstrap cleanly
- Build Verification: Run
npm run prepackto ensure the production bundle builds correctly
- ReScript Compiler: Outputs ES modules in-source (
src/*.res.mjs) with configuration inrescript.json - Rollup Bundler: Creates
out/create-rescript-app.cjsCommonJS bundle for distribution
When modifying templates:
- Maintain consistency with upstream toolchain defaults
- Ensure package scripts match the chosen build tool (Vite, Next.js, etc.)
- Keep templates self-contained with their own dependencies
- Test template bootstrapping after modifications