rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

If the filename is not a valid module name, allow multiple files with the same name

Open jfrolich opened this issue 3 years ago • 6 comments

This is helpful for NextJS. We can now have the filename [slug].res however that file can have multiple instances when using NextJS. Because the module is not accessible from the outside, it would be nice if the compiler allowed for multiple files with that name.

jfrolich avatar Dec 16 '20 09:12 jfrolich

what's the current work around, create [slug].js as a wrapper?

bobzhang avatar Dec 30 '20 04:12 bobzhang

yes or change the attribute name like [blogSlug].res

jfrolich avatar Dec 30 '20 07:12 jfrolich

Does the team have a rough estimate of when it would consider starting to work on this, if at all?

ghost avatar Apr 29 '21 19:04 ghost

Proposed implementation, the module name can include a hash of the content (or based on another stable thing like the relative path of the file). When adding these characters to the filename the module is not accessible internally anyway.

jfrolich avatar Apr 30 '21 02:04 jfrolich

My use cases is very similar to the original statement, but the typical example doesn't need to use [slug].res. I encounter the same issue with: index.res and subdir/index.res.

ghost avatar Apr 30 '21 13:04 ghost

I'm trying to use the optional catch all pattern, and I'm running into the following error:

bsb: [169/174] pages/[[...index]]-Ocamlorg.cmj
FAILED: pages/[[...index]]-Ocamlorg.cmj

  We've found a bug for you!
  /pages/[[...index]].res
  
  Could not find the .cmi file for interface
  /pages/[[...index]].mli.

Did I encounter some illegal character issue?

ghost avatar Jun 09 '21 05:06 ghost

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 30 '23 07:05 stale[bot]

This would still be very helpful for NextJs app directory. Now that we have async and directives, this task is the only thing that prevents a ReScript-only NextJs app directory project.

CarlOlson avatar Jun 12 '23 09:06 CarlOlson