Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use elm-solve-deps-wasm instead of elm-json solve (#558)
Use a custom dependency solver library instead of the elm-json binary. This PR introduces a custom dependency solver, extracted from the solver in elm-test-rs, improving the compatibility with other elm-based platforms such as Lamdera. The core algorithmic part of the solver, called "pubgrub", is rooted in the same logic than used in elm-json but implemented differently in the rust package `pubgrub-rs`. That core algorithmic logic has been ported into a WebAssembly package called `elm-solve-deps-wasm` dedicated to the constraints of the elm package ecosystem and providing the following `solve_deps` wasm function where the two functions passed as arguments `js_fetch_elm_json` and `js_list_available_versions` are two functions injected via the JS call. ```rust pub fn solve_deps( project_elm_json_str: &str, use_test: bool, // additional_constraints_str: &HashMap<String, Constraint>, additional_constraints_str: JsValue, // js_fetch_elm_json(pkg: &str, version: &str) -> String; js_fetch_elm_json: js_sys::Function, // js_list_available_versions(pkg: &str) -> Vec<String>; js_list_available_versions: js_sys::Function, ) -> Result<JsValue, JsValue> { ``` In this PR, the JS overlay implementing those two `js_fetch_elm_json` and `js_list_available_versions` is taken care of in the form of a `DependencyProvider` class providing two functions `solveOffline` and `solveOnline`. In the case of the offline solver, listing of existing versions and discovery of dependencies is exclusively performed from the packages installed inside the elm home. In the case of the online solver, some information may be retrieved from the package server. ```js // same interface for solveOnline solveOffline( elmJson /*: string */, useTest /*: boolean */, extra /*: { [string]: string } */ ) /*: string */ { ... } ``` Remark: since requests for the online solver need to perform http requests in a synchronous manner, an approach based on a web worker thread is used, requiring a minimum node version of 12.20.0.
- Loading branch information