dotnet-websharper / core

WebSharper - Full-stack, functional, reactive web apps and microservices in F# and C#
https://websharper.com
Apache License 2.0
589 stars 52 forks source link

Do not pre-compile quotations in JS-annotated code #1387

Open Jand42 opened 5 months ago

Jand42 commented 5 months ago

WS.UI templating uses methods that take F# quotations even when used in purely client-side code, because if the TP would expose a non-quotation overload too, then the F# type system would ask for disambiguation and that would make the user code uglier.

However, this has the side effect that the compiler finds these quotations to pre-compile as a function callable from the server. This is unnecessary code duplication as this is never the intention. Also, since introducing a fix to add a deserializer call around captured arguments of quotations in #1379, this can create a hard error in a deserializer macro when you capture an object that's not valid in server-client remoting (like an UI Var) but should be perfectly fine in client-only code.