[WIP] Rescript#207
Draft
rofinn wants to merge 4 commits into
Draft
Conversation
added 2 commits
March 21, 2026 18:06
This export doesn't follow the same pattern as the typescript code since specta-rescript doesn't implement a similar FrameworkExporter pattern. In general, we've implement a basic `export(self, config, path) -> Result` method with a bunch of simpler utility functions for rendering (take a mutable `out` string) or format functions. Over half of the rescript.rs file is tests.
Decided to setup a separate rescript example rather than extending the default examples/app. 1. This allows us to keep the setup separate 2. We can keep the dependencies and vite config separate. **Frontend** - src/Main.res: Largely the same as main.ts, just converted to rescript - src/style.css: Basically copied from the original app - index.html: Again, copied from the original app (might have slight autoformatting differences) - src/assets: vite.svg and tauri.svg were copied from the app and I've just added the rescript logo. - src/Bindings.res: Our generated bindings file committed for reference - src/*.js: I've opted to ignore rescript's compiled .js files for now NOTE: You may noticed the bindings.res file is a bit different than the corresponding bindings.ts file. 1. Rescript has stricter requirements on the order of definitions 2. Rescript has a different convention regarding modules and importing 3. Some elements like docstrings and deprecations are unsupported. **Backend** - src-tauri/src/main.rs: Is just the original app version with updated imports and main functions. NOTE: For dependencies and configuration, we're using rescript v12 with the experimental webapi lib and a beta version of the vite-plugin-rescript (so vite automatically compiles the rescript code). ** Exporter ** While debugging the new example, I noticed a few issues. 1. Docstrings aren't generated (expected) 2. Constants weren't being included (added) 3. Js.Obj.empty() was producing warnings on rescript v12 (should be Object.make()) 4. We were just inline the events code rather than following the makeEvent function pattern in the typescript implementation.
1. Updated the re-updated the root cargo and pnpm files to sync deps, but keep our specta branches. 2. Updated src/lang/rescript.rs to the new api (e.g., r.get(types) -> types.get(r), getters replaced with public field access) 3. Added a render_types filter to suppress std::result::Result from being exported as a custom type since it conflicts with the Rescript `result` type. 4. Reduced some dead code warnings in the example for now. 5. To suppress a build warning with the rescript/webapi package we need to patch their rescript.json file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Work in progress rescript language extension with an example for setting up a tauri + rescript app.
Depends on specta-rs/specta#459 and #206 (rebase once the updates are working correctly).
Decided to setup a separate rescript example rather than extending the
default examples/app.
Frontend
autoformatting differences)
just added the rescript logo.
NOTE: You may noticed the bindings.res file is a bit different than the
corresponding bindings.ts file.
Backend
imports and main functions.
NOTE: For dependencies and configuration, we're using rescript v12 with
the experimental webapi lib and a beta version of the
vite-plugin-rescript (so vite automatically compiles the rescript code).
** Exporter **
This export doesn't follow the same pattern as the typescript code since
specta-rescript doesn't implement a FrameworkExporter pattern.
In general, it's a pretty basic
export(self, config, path) -> Resultmethod with abunch of simpler utility functions for rendering_ (takes a mutable
outstring) or format_ functions.