Make filename-to-module-name derivation consistent across compiler and Rewatch
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 35/100
- Type d'issue
- Refactorisation
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- javascript, ocaml
- Domaine
- build-system, compilers
Piste de recherche
Start by tracing Ext_filename.module_name, Js_implementation.module_of_filename, Rewatch’s filename conversion, Ext_char.is_lower_case, and the generated JavaScript dependency filename logic. Compare their handling of ASCII, non-ASCII names, extensions, namespaces, paired .res/.resi files, and -o overrides. Done means the supported contract is explicit, all paths agree, and unsupported filenames receive consistent diagnostics with regression coverage.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Problem
Filename-to-module-name conversion currently follows different rules across the compiler, build system, and generated import paths.
- Implementation compilation uses
Ext_filename.module_name, which applies legacy Latin-1 byte capitalization throughExt_string.capitalize_ascii/capitalize_sub. - Interface compilation uses
Js_implementation.module_of_filename, which appliesString.capitalize_ascii. - Rewatch uses Unicode uppercasing of the first character.
.cmjfilename-case metadata usesExt_char.is_lower_case, with the same legacy Latin-1 byte ranges.- JavaScript dependency filenames are reconstructed with ASCII-only uncapitalization.
For ordinary ASCII filenames these rules agree. For non-ASCII input they can disagree or corrupt the module name.
Confirmed examples
| Filename stem | Implementation conversion | Interface conversion | Rewatch conversion |
|---|---|---|---|
foo |
Foo |
Foo |
Foo |
éclair |
éclair |
éclair |
Éclair |
ßeta |
ßeta |
ßeta |
SSeta |
中文 |
Invalid UTF-8 | Unchanged | Unchanged |
😀foo |
Invalid UTF-8 | Unchanged | Unchanged |
The invalid UTF-8 results occur because the legacy implementation subtracts 32 from the first byte, treating a UTF-8 leading byte as a Latin-1 lowercase character.
The compiler accepts these non-ASCII filenames without an early naming diagnostic. However, Éclair is not an ordinary ReScript module identifier, and quoting it does not make it valid in a module alias.
Ext_filename.as_module has ASCII-oriented validation, but the compilation paths above do not use it. Rewatch’s is_non_exotic_module_name filters generated namespace aliases rather than rejecting source filenames during discovery.
Why this matters
Inconsistent derivation can make the build graph disagree with compiler module identities. Inconsistent case metadata and filename reconstruction can also produce dependency imports that do not match emitted files.
Unicode uppercasing is not generally reversible: for example, ß becomes SS. A binary upper/lower case flag cannot recover the original filename from such a transformation.
Proposed direction
Define the supported filename-to-module-name contract explicitly and apply it consistently:
- Use ASCII-only capitalization for conventional module filenames.
- Decide how unsupported or exotic filenames should be handled, and report a clear diagnostic where appropriate.
- Share compiler derivation between implementations and interfaces, returning the module name and filename-case metadata together.
- Make Rewatch follow the same contract.
- Remove
Ext_charand the legacy Latin-1 capitalization once their responsibilities have been replaced.
Also reconcile extension stripping: interface derivation stops at the first dot, implementation derivation at the last dot, and Rewatch removes the final source extension. Any change must preserve intended handling of generated filenames.
Regression coverage
Cover lowercase/uppercase ASCII names, non-ASCII first and subsequent characters, Unicode case expansion, multiple dots, namespaces and namespace entries, paired .res/.resi files, and compiler output overrides (-o).
For supported names, verify that compiler identities, Rewatch dependency keys, emitted filenames, and generated imports agree. For unsupported names, verify consistent diagnostics before compilation artifacts are produced.
- Langage dominant
- OCaml
- Étoiles
- 7.5k
- Forks
- 485
- Merge moyen
- 1 j 34 min
- PR mergées (30 j)
- 52
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de rescript-lang/rescript
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
rescript-lang/rescript#8727 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 3/5 1-2 jours Accessibilité débutants 70/100
rescript-lang/rescript#8716 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 3/5 1-2 jours Accessibilité débutants 76/100
rescript-lang/rescript#8713 ·
Les mainteneurs répondent en général sous 1 jour
-
A regex literal that starts a statement is parsed as division, and the formatter removes the parentheses that prevent itPeut-être pris @fhammerschmidt l’a pris il y a 4 jours. Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 68/100
rescript-lang/rescript#8688 · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
bsc crashes with `Fatal error: exception Not_found` on `Some(x)` when the type of `x` comes from a transitive dependencyPeut-être pris @fhammerschmidt l’a pris il y a 4 jours. Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 76/100
rescript-lang/rescript#8687 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de rescript-lang/rescript
Issues similaires
-
triage/needs-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
praxis-proxy/praxis#1359 ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement good first issue help wanted
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
gabrielmongefranco/privatium#84 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
EchoTools/nevr-runtime#171 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
graphql-hive/graphql-modules#2686 ·