Replace the unmaintained OCaml Flow parser dependency
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
- ocaml
- Área
- compilers
Línea de trabajo
Comienza leyendo la integración existente del parser de Flow y las fuentes previamente vendorizadas en compiler/js_parser. Define la interfaz específica del parser en torno a la validación de sintaxis, las ubicaciones de los errores, la validación de regexp, la aridad de las funciones, la clasificación de literales y el manejo de comentarios; después, añade pruebas para los casos indicados. El trabajo estará terminado cuando ambas implementaciones del parser puedan compararse con el mismo corpus y la dependencia pueda eliminarse si la compatibilidad es suficiente.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem
ReScript depends on the unmaintained OCaml implementation of flow_parser to validate and classify JavaScript in %raw expressions.
Our fork supports ppxlib 0.36, which requires OCaml < 5.4. This blocks upgrades to OCaml 5.4 and 5.5. Updating the fork for each ppxlib release would only postpone the problem.
ReScript currently depends directly on Flow AST and parser types, although it only needs syntax validation, error locations, regexp validation, and classification of literals, functions and comment-only statements.
Possible solutions
1. Vendor the Flow parser
ReScript previously vendored these sources under compiler/js_parser.
We could restore the currently used parser sources and maintain them inside the repository. Ideally, we would commit the PPX-generated OCaml code so the parser no longer depends on ppxlib.
This is the lowest-risk solution and can preserve the existing direct Flow AST integration. However, it leaves ReScript responsible for roughly 33,000 lines of parser code whose JavaScript syntax support will no longer receive upstream updates.
2. Move to js_of_ocaml’s JavaScript parser
js_of_ocaml-compiler's Parse_js API provides maintained OCaml functions for parsing JavaScript expressions and programs.
For a safe migration, we should first introduce a small ReScript-owned parser interface backed by the existing Flow parser. This interface would expose only the operations ReScript needs and remove direct uses of Flow_ast, Parser_flow, Loc, and Parse_error from the rest of the compiler.
We should add focused tests for parsing, error locations, regexp validation, function arity, literal classification, leading comments and comment-only programs. The js_of_ocaml implementation could then be tested against the same corpus before switching.
js_of_ocaml maintains its parser to read JavaScript runtimes and user-provided stubs before linking and optimizing them with generated JavaScript. Its primary goal is therefore not to be a universal parser supporting every new TC39 feature immediately. Its syntax coverage, diagnostics, comment handling and classifications must be compared with the current Flow implementation.
A migration could be split into two independent changes:
- Introduce the internal parser abstraction backed by Flow Parser and strengthen test coverage.
- Implement the abstraction using js_of_ocaml, compare both implementations, and remove
flow_parserif compatibility is sufficient.
Decision
- Vendoring is the quickest and least disruptive solution, but makes ReScript the permanent owner of an unmaintained parser.
- Moving to js_of_ocaml requires more migration work, but offers a maintained long-term dependency with much less parser-specific coupling.
- Lenguaje dominante
- OCaml
- Estrellas
- 7.5k
- Forks
- 485
- Merge medio
- 1 d 2 h
- PR fusionados (30 d)
- 55
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 35/100
rescript-lang/rescript#8659 · 2 comentarios · 2 reacciones ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
rescript-lang/rescript#8647 ·
-
rescript-lang/rescript#8632 · 1 asignado ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 28/100
rescript-lang/rescript#8624 ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
rescript-lang/rescript#8596 · 2 comentarios ·
Todos los issues de rescript-lang/rescript
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
JakeChampion/lang#10213 ·
-
bug language-server
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
purefunctor/purescript-iris#552 ·
-
enhancement good first issue needs testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
bradcypert/plum#58 ·