Closed pbiggar closed 2 years ago
Steps to test:
sudo dotnet workload install wasm-tools
IsPublishable
and RunAotCompilation
in Wasm.fsprojIsTrimmable
is set to false in Wasm.fsprojdotnet publish -c Release
The latest attempt gets further, but is now blocked by https://github.com/dotnet/aspnetcore/issues/37690
I spent a few days on this - tried fiddling with .fsproj flags, tried upgrading to .net 6.0.2, 6.0.3, and 7.0.1 - all with no luck. Consistently across those .NET upgrades, the non-publish wwwroot folder works, but the publish folder fails. Likely there's a path forward here, but this was a bit over my head.
I have some unorganized notes here: https://github.com/StachuDotNet/dark-notes/blob/1e07e99d6ae459d6d0fe7a8b5821672891214b82/tasks,%20now/improve%20blazor%20perf%20(aot).md Mostly, some of those links might turn out handy for the next round of attempts - seems we're not the only ones who have struggled in this space.
We made some discoveries made in a 1:1 with @pbiggar yesterday
Cloning the aspnetcore project (https://github.com/dotnet/aspnetcore/) and compiling the Web.JS project isn't too bad. We can use this to get a reasonable Blazor IO .js module to work with.
There are a few steps involved:
src/Components/Web.JS/webpack.config.js
; set .optimization.minimize
to false
cd src/Components
and run build.sh
heresrc/Components/Web.JS/dist/Release/blazor.webassembly.js
autostart="false"
in the script tagBlazor
object: Blazor.start(options)
options
object should look like
You should be able to compile the Blazor files using RunAOTCompilation. However, it failed with the following error:
Nothing I could do would make this work.
I suspect that once we're not on bleeding edge F# & .NET (we're on a nightly build to make something else work), this might work.
I doubt trimming will work, as we use reflection in the JSON serializers. It doesn't look like source generators are going to be in F# anytime soon, but it might be possible to write the source generator in C#.