3
votes

What I am trying to do is to write an SPA application in F#. Is it possible to use Fable without the full tooling, just only as F# to html+javascript compiler? Ideally I would like to be able to compile one or more F# files into a static html+javascript markup and send it straight to the browser from F# interactive, without any web server.

The typical workflow is:

1) Create new project from template

2) Modify project files

3) Build

4) Open browser and point to specific url

What I would like to do is something like (from F# interactive):

let html = Fable.compile([fileXYZ.fs])
do XPlot.Plotly.Html.showInBrowser html "pageid"

Is this possible? How can I do it?

1
You'll have to clarify what you mean by "full tooling". Which specific tools would you like to avoid? - Fyodor Soikin
The full Fable tooling doesn't actually require a Web server. The reason why instructions like these have you point a browser at http://localhost:8080/ is because during development, having a server process allows for watching your source files, recompiling when you edit a file, and automatically refreshing the browser after the compile finishes. But ultimately, Fable just compiles to Javascript, which could be served up from a static HTML file just fine. - rmunn
@FyodorSoikin The way I read it, the question is "how to invoke Fable as a library" (taking F# source code and producing JS). This looks like a reasonable question to me, but alas, I don't know the answer. - Tomas Petricek
@Tomas yes the "way you read it" is correct. - Franco Tiveron
@munn that would be my assumption too, yet I couldn't find an example not following the "full tooling" pattern - Franco Tiveron

1 Answers

1
votes

I have asked for the same in the past as sometimes the requirement is just to transpile a single file (Azure DevOps extensions for example).

Sadly, the current answer is "no".

The question is still open today: https://github.com/fable-compiler/Fable/issues/1369

People have build prototypes: https://github.com/TheAngryByrd/fantasy

But I don't think you can answer with a "yes" at this time.

I hope this helps.