Make filename-to-module-name derivation consistent across compiler and Rewatch
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Refactorización
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, ocaml
- Área
- build-system, compilers
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- OCaml
- Estrellas
- 7.5k
- Forks
- 484
- Merge medio
- 19 h 40 min
- PR fusionados (30 d)
- 54
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de rescript-lang/rescript
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 22/100
rescript-lang/rescript#8733 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
rescript-lang/rescript#8727 ·
Los mantenedores suelen responder en 1 día
-
Integer range patterns ending at 2147483647 generate incorrect JavaScriptPosiblemente ocupada @fhammerschmidt la tomó hace 5 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 70/100
rescript-lang/rescript#8716 ·
Los mantenedores suelen responder en 1 día
-
Integer range patterns on record fields match values below the rangePosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 76/100
rescript-lang/rescript#8713 ·
Los mantenedores suelen responder en 1 día
-
A regex literal that starts a statement is parsed as division, and the formatter removes the parentheses that prevent itPosiblemente ocupada @fhammerschmidt la tomó hace 5 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 68/100
rescript-lang/rescript#8688 · 1 reacción ·
Los mantenedores suelen responder en 1 día
Todos los issues de rescript-lang/rescript
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
lightpanda-io/browser#3852 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
SDK package doubled in size since 2.81.0 because UMD source maps are publishedPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
hiero-ledger/hiero-sdk-js#4476 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 85/100
pytest-dev/pluggy#757 ·
Los mantenedores suelen responder en 1 día