Skip to content

How to add a rescript library

pnpm run gen is a code generation script that creates new ReScript packages from templates. Here’s what it does:

  1. User runs the script pnpm run gen
  2. Script asks: “What is the original package name?”
  3. User enters a name (e.g., “array-async”)
  4. Script generates a new package structure in types/array-async/ using the template
  5. All __name__ placeholders in template files are replaced with the actual name
  • Interactive Package Creation: It prompts the user to enter a package name via command line input
  • Template-based Generation: Uses the generate-template-files library to create a new package structure from a template
  • Dynamic Name Replacement: Replaces placeholder name in template files with the user-provided package name
  • Template Source: Uses files from scripts/template/ directory
  • Output Location: Creates new packages in types/__name__(kebabCase)/ directory
  • Dynamic Replacement: Converts the user input name to kebab-case and replaces __name__ placeholders