-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Firstly, excellent work that we have this sink.
Kindof related to #20
Create a New .Net8 WASM app (hosted)
Add a simple javascript file to client wwwroot folder
In program.cs
create WebAssemblyHostBuilder
Add Serilog BrowserConsole
Log something
Now build the WebAssemblyHostBuilder
Get the JSRuntime from DI container
try to import a module using JSRuntime - module is returned as null
The expected behaviour is the module is returned as an IJSObjectReference
If I don't use the Logger before getting the module - it works
A workaround is to put the module import in a loop, this works and it succeeds on the second try.
Another workaround as suggested in issue #20 is to pass the JSRuntime to the BrowserConsole sink. However, I do many things prior to building the DI container(initialising dynamically loaded modules etc), so I need to be able to log before building the WebAssemblyHostBuilder. This workaround is not an option for me and this scenario needs to be considered for issue #20.
The behaviour is the same using dotnet run and dotnet watch. So I don't think this is a tooling issue.
So while I have a workaround, there is clearly something here that is changing the default behaviour of JSRuntime.
Example repo is here