diff --git a/src/web/api/src/ServiceContext.ts b/src/web/api/src/ServiceContext.ts index 6f00624a5..20f6d9907 100644 --- a/src/web/api/src/ServiceContext.ts +++ b/src/web/api/src/ServiceContext.ts @@ -1,5 +1,11 @@ function add(a:number, b:number) { - return a + b + 2; -} \ No newline at end of file + return a + b; +} + +function really_long_and_unique_identifier() { + return 42; +} + +export { add , really_long_and_unique_identifier }; \ No newline at end of file diff --git a/src/web/build.cmd b/src/web/build.cmd new file mode 100644 index 000000000..198d11e83 --- /dev/null +++ b/src/web/build.cmd @@ -0,0 +1,9 @@ +REM @echo off +setlocal +cd %~dp0\api +call npm run build +cd %~dp0\..\..\build\web\api +call ts2fable ServiceContext.d.ts ServiceContext.fs +cd %~dp0\ui\src +call dotnet fable webpack + diff --git a/src/web/ui/src/Counter/State.fs b/src/web/ui/src/Counter/State.fs index 2ed154b0b..0a4baa382 100644 --- a/src/web/ui/src/Counter/State.fs +++ b/src/web/ui/src/Counter/State.fs @@ -2,6 +2,12 @@ module Counter.State open Elmish open Types +open Fable.Core.Exceptions +open Fable.Core + + +[] +let sc : ServiceContext.IExports = jsNative let init () : Model * Cmd = 0, [] @@ -9,8 +15,8 @@ let init () : Model * Cmd = let update msg model = match msg with | Increment -> - model + 1, [] + sc.add(float model, 1.) |> int, [] | Decrement -> - model - 1, [] + sc.add(float model, -1.) |> int, [] | Reset -> 0, [] diff --git a/src/web/ui/src/ui.fsproj b/src/web/ui/src/ui.fsproj index 9b4dcfb4d..f3d2d0f67 100644 --- a/src/web/ui/src/ui.fsproj +++ b/src/web/ui/src/ui.fsproj @@ -3,6 +3,8 @@ netstandard2.0 + + diff --git a/src/web/ui/webpack.config.js b/src/web/ui/webpack.config.js index 2b8a48319..9b1d6be16 100644 --- a/src/web/ui/webpack.config.js +++ b/src/web/ui/webpack.config.js @@ -20,7 +20,9 @@ var babelOptions = fableUtils.resolveBabelOptions({ var isProduction = process.argv.indexOf("-p") >= 0; console.log("Bundling for " + (isProduction ? "production" : "development") + "..."); -const output_path = resolve("../../../build/web/ui/"); +const build_path = "../../../build/"; +const output_path = resolve(build_path + "web/ui/"); +const api_path = resolve(build_path + "web/api/"); module.exports = { devtool: isProduction ? undefined : "source-map", @@ -31,7 +33,7 @@ module.exports = { }, resolve: { modules: [ - "node_modules", resolve("./node_modules/") + "node_modules", resolve("./node_modules/"), api_path ] }, devServer: {