Open harrisse opened 1 year ago
Hi @harrisse, I'll take a look if anything can be done here.
Hi @harrisse I know it has been ages but do you have any repro for this? I am not super familiar with WebAssembly so a test project would help.
Closed due to lack of interest.
I'm very interested in this one. However if fsc-host uses fsi under the cover, it will not work, there will be many unsupported operation errors while speaking to console in/out, file etc. I created a ticket to address that but I think it would be easier to write some FsiLight version. And with .NET 9 is coming real multi-threading (tentative) :)
So, fsc-host doesn't use fsi. It uses FSharp.Compiler.Service which under the hood uses fsc.exe (i.e. it requires the dotnet sdk). Web assembly has never been a priority for me personally and I am not even sure how people use F# in web assembly. However, if fsc-host could add any value to that scenario I am open to suggestions.
My interest in using some sort of fsc-host/fsi-light in webassembly is to enable writing and executing a custom DSL code by the application users to extend the application features for their personal needs.
For that I'm using .net interactive that has a F# kernel, however that uses fsi which is not wasm friendly.
It all works when Blazor (wasm for .NET) runs in server mode but not in a client mode. And wasm is getting real multi-threading support with .NET 9 :)
Why I need it? At least for 2 reasons:
So I see two options:
The later could be done starting from scratch or extending fsc-host.
Currently when I run example of fsc-host in wasm I'm getting
Unhandled exception rendering component: Could not find a part of the path '/plugins/default/plugin.fsx'.
That most likely can be eliminated as I have seen it support plain string body as well. Not sure if wasm will allow to use fsc.exe. Even thought, I would still need some sort of interactivity to query the bounded values and run several snippets in a session mode to make it possible to mix with other languages/kernels of .net interactive (C#, AI).
I will explore more.
run example of fsc-host in wasm I'm getting
Would you be able to share a minimum example of how you run it in wasm? A repo/Dockerfile would be great.
Also I think fsc-host was never meant to be used in interactive contexts. So you may actually be better with an fsi-light approach.
My interest in using some sort of fsc-host/fsi-light in webassembly is to enable writing and executing a custom DSL code by the application users to extend the application features for their personal needs.
@PawelStadnicki I'm also interested in this exact use case. Have you made any progress on achieving this?
hi @evelant I did a more detailed research and ... we have to wait for MSFT
Fsi is currently not wasm-friendly, it has a lot dependencies on a local files etc.
Maybe there are other ways than using Fsi but I don't know them and I want to use .NET Interactive (to have a polyglot programming capabilities with JS and Python). .NET Interactive uses Fsi in the F# Kernel.
I asked the F# team to make Fsi warm-friendly, don't know when it is going to happen.
Moreover, real multithreading in wasm is postponed until .NET 10 (there is a great progress on that but the amount of changes and backward compatibility was a huge effort to make it with .NET 9).
Last but not least, when it is ready, it will require a vast amount of F# services to be loaded into wasm as well, making it slow to load - but only on a first load. Not that tragic, but important (still I'm not sure about the overall performance having so many stuff in the web cache)
Summary, I'm waiting for:
Is it possible to run fsc-host in WebAssembly?
I'm trying to invoke fsc-host with
CompilerHost.getAssembly Options.Default (Inline text)
but am hitting the following exception:Googling the error took me to https://github.com/dotnet/fsharp/issues/11966 which I saw you had left a comment on, so I figured you might know something one way or the other 😄
This project got fsc working in the browser a while back but the approach no longer works in .net 7. I was able to make some progress on their approach by copying dlls from the browser cache to the filesystem, but was never able to get fsc to recognize symbols from
-r:
'd dlls.Thanks!