There are two conventional approaches I’ve seen in the wild and personally adopted
-
Preface the file name with the directory name
// Models__Comment.res type t = { author: string, content: string } let fetchById = (commentId) => // ... let fetchForPost = (postId) => // ...// Components__Comment.res @react.component let make = () => / /...Then export them in a single top-level file
//Models.res module Comment = Models__Comment//Components.res module Comment = Components__CommentThen you can do stuff like
Models.Comment.fetchById()or<Components.Comment/> -
You can utilize rewatch and monorepo.
Rewatch let’s you split your code into different packages with their ownrescript.jsonfile, while still running a single compile step.// packages/models/rescript.json { ... "namespace": "Models" }// packages/components/rescript.json { ... "namespace": "Components" }Then you can have files with the same name, because they are in different namespaces