The build script for the F# Snippets project does exactly this.
The idea is that you have app.fsx
file that defines a top-level WebPart
named app
. You can see the example for F# Snippets here. The app.fsx
script file can also load other files, so you can structure your application in any way you need.
The build.fsx
build script then starts a server,
monitors file system changes for your source code and app.fsx
and reloads it using F# Compiler Service in the background and replaces the "currently loaded" server with the one obtained from the new app
value.
The only limitation of the current build script is that it does not correctly relcaim memory (it should probably be fixed by recreating F# Interactive Session in the build script) and so it runs out of memory after a larger number of reloads. But still, it makes the workflow much nicer!