You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wrote a web worker sample and got this error on the developer tools console:
Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')
I used this template:
dotnet new websharper-spa -lang f# -n MySPA
namespace MySPA
open WebSharper
open WebSharper.JavaScript
open WebSharper.UI
open WebSharper.UI.Client
open WebSharper.UI.Templating
[<JavaScript>]
module Client =
// The templates are loaded from the DOM, so you just can edit index.html
// and refresh your browser, no need to recompile unless you add or remove holes.
type IndexTemplate = Template<"wwwroot/index.html", ClientLoad.FromDocument>
let People =
ListModel.FromSeq [
"John"
"Paul"
]
[<SPAEntryPoint>]
let Main () =
let myWorker = new Worker(fun self ->
Console.Log "This was written from the worker!"
self.PostMessage("This worker's job is done, it can be terminated.")
)
myWorker.Onmessage <- fun event ->
Console.Log event.Data
myWorker.Terminate()
let newName = Var.Create ""
IndexTemplate.Main()
.ListContainer(
People.View.DocSeqCached(fun (name: string) ->
IndexTemplate.ListItem().Name(name).Doc()
)
)
.Name(newName)
.Add(fun _ ->
People.Add(newName.Value)
newName.Value <- ""
)
.Doc()
|> Doc.RunById "main"
The text was updated successfully, but these errors were encountered:
This must be a problem with web workers defined within an SPA project. When bundling runs for the web worker, WebSharper mistakenly also includes the all the code based on SPAEntryPoint in the MySPA.worker.js bundle too, which in this case has WS.UI stuff using DOM Elements, not available in web worker context.
To fix: web worker bundling should ignore the SPAEntryPoint and JavaScriptExport attributes.
I wrote a web worker sample and got this error on the developer tools console:
Uncaught TypeError: Cannot read properties of undefined (reading 'prototype')
I used this template:
dotnet new websharper-spa -lang f# -n MySPA
The text was updated successfully, but these errors were encountered: