Just a short week ago, we announced the first release of Bolero, enabling full-stack F# web development on WebAssembly. Since then we have been working on a small side project to see what it would take to implement a fully client-side implementation of the F# compiler: basically, to embed FSharp.Compiler.Services (FCS) in a small Bolero application.
The main motivations of this project are pretty straightforward and incredibly useful - it will enable:
You can see the current status below and you can also try it live (Firefox recommended for enhanced performance):
One of the snippets that are available demonstrates the use of the JSON type provider from FSharp.Data:
There is a significant download size to download initialize the application. This involves downloading all the assembly references to get FCS running (~28 MBs, which should cache in the browser for future page loads/refreshes), loading them into the runtime and initializing the code service (around 8-10 seconds, depending on your machine).
Currently, the code service is invoked in the main thread, causing noticable freezes in the UI while it's executing. This can be significant on larger code snippets. Given the nature of on-the-fly type checking, going around the single-threaded limitation with web workers, a possible path to alleviate the UI blocking issue, is not exactly ideal. Instead, this limitation will solve itself when proper threading support is added to the underlying runtime (see one of the related issues filed under Blazor#139/AspNetCore#5475).
Furthermore, in this first version, only basic type providers are supported. This includes the JSON and the XML type providers from FSharp.Data for the time being.
Check out the source code for the project and get involved, your suggestions/contributions/PRs are welcome!
Happy coding!
Can’t find what you were looking for? Drop us a line.
20221229 · 30 min read
20211230 · 20 min read