Is filename uniqueness a problem in practice?

TIL that ReScript filenames need to be unique across an entire project. Is this an issue in practice in larger projects?

If I had a project like:

src/Widgets
    - schema.res
    - prices.res

src/Gadgets
    - schema.res
    - prices.res

I would need instead to have:

src/Widgets
    - WidgetSchema.res
    - WidgetPrices.res

src/Gadgets
    - GadgetSchema.res
    - GadgetPrices.res

So the directory structure is useful to me as a person managing the project code, but is “flat” to the compiler? I can see this approach probably has both pros and cons which I haven’t learned about yet.

I haven’t found any real problem with the second layout.

You can have a root module that contains aliases if you want to have namespaces:

module Widgets = {
  module Schema = WidgetSchema
  module Prices = WidgetPrices
}

module Gadgets = {
  module Schema = GadgetSchema
  module Prices = GadgetPrices
}

The only annoying thing is that you can’t hide the aliased modules for auto-completion, so some discipline is needed.
In general, we use an underscore to flag a module with a namespace, like Gadget_Schema.

1 Like

That’s a useful technique, thanks.