Skip to content

[feat-req] rescript init command #7951

@tx46

Description

@tx46

i would like a rescript init command that creates a rescript.json file

it should use values from package.json (for e.g. the name field) if one exists, otherwise use sane defaults (like dir name as project name).

it should insert all possible fields (commented out) so the file becomes self-documenting, just like tsc init does.

it could also insert one or multiple links (commented out) to documentation for easy access

example

rescript init

generates something like (ai slop below, just to give you an idea)

{
  // The project name, taken from package.json if available, otherwise defaults to the directory name
  "name": "theproject",
  // Directories containing your ReScript source files
  "sources": [
    {
      "dir": "src",
      // Set to true to include all nested subdirectories
      "subdirs": true
    }
  ],
  // Configure how compiled JS files are emitted
  "package-specs": [
    {
      // Possible values: "commonjs" | "esmodule"
      "module": "esmodule",
      // If true, .res.js files are emitted next to source files
      // If false, they go under lib/js/
      "in-source": true
    }
  ],
  // File extension suffix for compiled output
  "suffix": ".res.js",
  // Dependencies that should be compiled by ReScript as well
  "bs-dependencies": [
    "@rescript/core"
    // Add other rescript packages here, e.g. "rescript-react"
  ],
  // Flags passed to the ReScript compiler
  "bsc-flags": [
    "-open RescriptCore"
    // Example: "-bs-super-errors" for detailed compiler output
  ],
  // Output directory for generated JS artifacts when not using "in-source": true
  // "gentypeconfig": { "language": "typescript" }, // Example if using gentype
  // Clean output on build
  // "clean-on-build": true,
  // Specify the namespace of generated JS modules
  // "namespace": "MyNamespace",
  // Enables warnings as errors
  // "warnings-as-errors": true,
  // Optional compiler version pinning
  // "version": "11.0.0",
  // ⚙️ For more options and docs:
  // https://rescript-lang.org/docs/manual/latest/build-configuration
  // https://rescript-lang.org/docs/manual/latest/configuration-schema
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions