rescript-lang / rescript-lang/rescript-lang.org

@directive and @@directive improvements

Open
#1,258 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
MDX
Stars
1.9k
Forks
260
Avg merge
3d 9h
Merged PRs (30d)
17

Description

Directives are a part of React and used by the React compiler. Frameworks like NextJs have started to rely on these heavily. ReScript should improve its support in order to take advantages of these features.

Suggested Changes:

  1. Always output value given to @@directive as a string. Example: @@directive("use client"), not @@directive("'use client'")

    Currently @@directive can generate invalid JS:

    @@directive("use client")
    
    // output
    use client
    
    // should be
    "use client"
    

    Directives are always strings, so we shouldn't need to add internal quotes.

  2. Support @directive for react components and functions

    @rescript.component @directive("use client")
    let make = () => {
      <div />
    }
    
    @directive("use server")
    let submit = (input: FormAction.t) => {
      await input->save
    }
    

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files or tests. Start with the linked React compiler directives documentation, then trace the existing @directive and @@directive handling. Done means @@directive emits a valid string and @directive works on React components and functions as shown in the examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, react
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.