Closed martasp closed 4 years ago
@martasp I haven't tried it. Please let me know how you make out.
Heres how I made a library that compiles razor components in runtime.
In react we have hot module replacement this feature allows us to change code and see changes immediately in your browser. We can make a similar feature in blazor using Roslyn compiler. Compiling down razor components in runtime and serving with WebSockets on every file change using file watcher.
It uses razor engine version 3 to compile components to c# classes. Then using Roslyn compiler I compiled down those classes to assembly. Finally, I loaded the app.razor component from an assembly with reflection and with Steve Sanderson Test host modified library I turned component to plain HTML. To serve HTML files in realtime I used WebSockets to have a full-duplex communication.
Fixing routes instead of using /preview, this could be implemented by injecting WebSocket client into every HTTP request context.
In Blazor web assembly maybe we can load and unload assemblies in the browser?
Using two build servers one for fast previewing and another server with dotnet watch build for actual real longer builds.
In Blazor web assembly maybe we can load and unload assemblies in the browser?
Looks good but where are you using RazorLight?
Blazor is a relatively new stuff, and we've never did anything specific to support it. It might be a good idea to investigate this direction, but it is only possible after going stable in 2.0
Hello. I am looking a way to compile in runtime a razor markup that I have in a string and convert it into an assembly. Could I do it with this tool? Thanks
@AntonitoMt I am pretty confused as to why you put this question on a closed issue unrelated to your question. We don't support precompilation currently. In theory, if you want to submit a PR, look at the Razorlight.Precompile.csproj to add support for that
I apologize. My question was regarding the tool BlazorLiveReload posted by martasp. Thank you
I apologize as well. BlazorLiveReload is a blazor-specific feature. Blazor is technically a separate feature from Razor itself. I still think you could get very far if you decided to submit a PR to help along the Razorlight.Precompile project.
I want to render .razor files.