Zaid-Ajaj / Fable.Remoting

Type-safe communication layer (RPC-style) for F# featuring Fable and .NET Apps
https://zaid-ajaj.github.io/Fable.Remoting/
MIT License
274 stars 57 forks source link

js uses not defined value #329

Closed hesxenon closed 2 years ago

hesxenon commented 2 years ago

Hi, I'm just trying to get started with Fable (coming from JS) in general and thought Fable.Remoting looked really nice.

However it seems that following the "from scratch" guide for suave produces broken JS and I don't know why.

.fsproj ```xml netstandard2.0 ```
Server.fs ```fsharp module Server open Suave open Suave.Filters open Suave.Successful open Fable.Remoting.Server open Fable.Remoting.Suave let todoStore: Contracts.todoStore = { test = async { return "Hello World" } } let api: WebPart = Remoting.createApi () |> Remoting.fromValue todoStore |> Remoting.buildWebPart startWebServer defaultConfig api ```
Server.fs.js ```javascript import { singleton } from "./fable_modules/fable-library.3.7.20/AsyncBuilder.js"; import { todoStore as todoStore_1 } from "../contracts/Contracts.fs.js"; export const todoStore = new todoStore_1(singleton.Delay(() => singleton.Return("Hello World"))); export const api = Fable_Remoting_Suave_Remoting_buildWebPart(Fable_Remoting_Server_Remoting_fromValue(todoStore, Fable_Remoting_Server_Remoting_createApi())); Suave_Web_startWebServer(Suave_Web_defaultConfig, api); //# sourceMappingURL=Server.fs.js.map ```

Fable_Remoting_Suave_Remoting_buildWebPart obviously doesn't exist in the scope where it's used. Any ideas why and what I did wrong?

kerams commented 2 years ago

Suave is the web server - it runs on .NET and you should not compile it with Fable.

hesxenon commented 2 years ago

well, that explains it then. So if suave is strictly .net and Fable is a F# to JS transpiler, what exactly is Fable.Remoting.Suave? An opinionated way on how to work with suave? And why is it in the Fable namespace if it's not supposed to interact with fable?

On Tue, Nov 15, 2022, 21:38 kerams @.***> wrote:

Suave is the web server - it runs on .NET and you should not compile it with Fable.

— Reply to this email directly, view it on GitHub https://github.com/Zaid-Ajaj/Fable.Remoting/issues/329#issuecomment-1315835406, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACOHZTQ3DPTMJ4VFX3TBSX3WIPYDLANCNFSM6AAAAAASBKVLNY . You are receiving this because you authored the thread.Message ID: @.***>

kerams commented 2 years ago

Fable.Remoting.Client package is what you use in the client project which you compile with Fable. Fable.Remoting.(Suave | Giraffe | etc.) on the other hand are purely .NET packages, which are to be used in the corresponding web server, so that it knows how to handle the Remoting RPC traffic. Both sides are needed - it does not make sense to use one without the other. Fable.Remoting is the name of this project and therefore it is also the main namespace for all Nuget packages, even though most of them aren't technically Fable-compatible.

hesxenon commented 2 years ago

even though most of them aren't technically Fable-compatible.

interesting, and a bit confusing. Nevertheless, thanks for the explanation. Coming from the js side, maybe that could be highlighted in the docs?

Feel free to close this issue though, otherwise I'll do it once I'm at home again

On Tue, Nov 15, 2022, 22:07 kerams @.***> wrote:

Fable.Remoting.Client package is what you use in the client project which you compile with Fable. Fable.Remoting.(Suave | Giraffe | etc.) on the other hand are purely .NET packages, which are to be used in the corresponding web server, so that it knows how to handle the Remoting RPC traffic. Both sides are needed - it does not make sense to use one without the other. Fable.Remoting is the name of this project and therefore it is also the main namespace for all Nuget packages, even though most of them aren't technically Fable-compatible.

— Reply to this email directly, view it on GitHub https://github.com/Zaid-Ajaj/Fable.Remoting/issues/329#issuecomment-1315864612, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACOHZTXPOCSBL6SZ24G6Z3TWIP3QTANCNFSM6AAAAAASBKVLNY . You are receiving this because you authored the thread.Message ID: @.***>