Created
November 20, 2021 09:47
-
-
Save Xanthus/3de206e0f3bf41bd448a647469b14fa3 to your computer and use it in GitHub Desktop.
Fable app where opening a type doesn't compile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module App | |
open Elmish | |
open Elmish.React | |
open Feliz | |
open type Feliz.Html | |
type State = | |
{ Count: int } | |
type Msg = | |
| ChangeCount of int | |
let init () = | |
{ Count = 0 } | |
let update msg state = | |
match msg with | |
| ChangeCount delta -> { state with Count = state.Count + delta } | |
let render (state: State) (dispatch: Msg -> unit) = | |
let description = | |
if state.Count % 2 = 0 | |
then "Count is even" | |
else "Count is odd" | |
Html.div [ | |
Html.button [ | |
prop.text "Increment" | |
prop.onClick (fun _ -> dispatch (ChangeCount 1)) | |
] | |
Html.div state.Count | |
Html.button [ | |
prop.text "Decrement" | |
prop.onClick (fun _ -> dispatch (ChangeCount -1)) | |
] | |
Html.h1 [ | |
prop.style [ | |
if state.Count >= 0 | |
then style.display.block | |
else style.display.none | |
] | |
prop.text description | |
] | |
] | |
Program.mkSimple init update render | |
|> Program.withReactSynchronous "elmish-app" | |
|> Program.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<TargetFramework>net6.0</TargetFramework> | |
<LangVersion>preview</LangVersion> | |
</PropertyGroup> | |
<ItemGroup> | |
<Compile Include="App.fs" /> | |
</ItemGroup> | |
<ItemGroup> | |
<PackageReference Include="Fable.Elmish.React" Version="3.0.1" /> | |
<PackageReference Include="Feliz" Version="0.68.10" /> | |
</ItemGroup> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<configuration> | |
<!-- This clears Nuget configuration in the machine to avoid conflicts --> | |
<packageSources> | |
<clear /> | |
<add key="NuGet.org" value="https://api.nuget.org/v3/index.json" /> | |
</packageSources> | |
<disabledPackageSources> | |
<clear /> | |
</disabledPackageSources> | |
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ npm start | |
> @ start /home/nyatracos/elmish-getting-started | |
> webpack-dev-server | |
ℹ 「wds」: Project is running at http://localhost:8080/ | |
ℹ 「wds」: webpack output is served from / | |
ℹ 「wds」: Content not from webpack is served from /home/nyatracos/elmish-getting-started/dist | |
fable-compiler 2.4.16 | |
fable: Compiled src/App.fsproj | |
fable: Compiled src/App.fs | |
fable: Compiled .fable/Feliz.0.68.10/Interop.fs | |
fable: Compiled .fable/Fable.Elmish.React.3.0.1/react.fs | |
fable: Compiled .fable/Fable.Elmish.3.0.0/program.fs | |
fable: Compiled .fable/Fable.Elmish.3.0.0/prelude.fs | |
fable: Compiled .fable/Fable.Elmish.React.3.0.1/common.fs | |
fable: Compiled .fable/Fable.Elmish.3.0.0/cmd.fs | |
fable: Compiled .fable/Fable.Elmish.3.0.0/ring.fs | |
✖ 「wdm」: Hash: 7d2a3090606532f12bb2 | |
Version: webpack 4.38.0 | |
Time: 14862ms | |
Built at: 11/20/2021 11:46:27 AM | |
Asset Size Chunks Chunk Names | |
main.js 1.7 MiB 0 [emitted] main | |
Entrypoint main = main.js | |
[0] multi (webpack)-dev-server/client?http://localhost ./src/App.fsproj 40 bytes {0} [built] | |
[1] (webpack)-dev-server/client?http://localhost 4.29 KiB {0} [built] | |
[2] (webpack)-dev-server/node_modules/strip-ansi/index.js 161 bytes {0} [built] | |
[3] (webpack)-dev-server/node_modules/ansi-regex/index.js 135 bytes {0} [built] | |
[4] (webpack)-dev-server/client/socket.js 1.53 KiB {0} [built] | |
[5] (webpack)-dev-server/client/clients/SockJSClient.js 3.15 KiB {0} [built] | |
[9] (webpack)-dev-server/client/overlay.js 3.51 KiB {0} [built] | |
[10] ./node_modules/ansi-html/index.js 4.16 KiB {0} [built] | |
[15] (webpack)-dev-server/client/utils/log.js 964 bytes {0} [built] | |
[17] (webpack)-dev-server/client/utils/sendMessage.js 402 bytes {0} [built] | |
[18] (webpack)-dev-server/client/utils/reloadApp.js 1.63 KiB {0} [built] | |
[21] (webpack)-dev-server/client/utils/createSocketUrl.js 2.77 KiB {0} [built] | |
[30] (webpack)/hot sync nonrecursive ^\.\/log$ 170 bytes {0} [built] | |
[32] ./src/App.fsproj 25 bytes {0} [built] | |
[33] ./src/App.fs 2.63 KiB {0} [not cacheable] [built] [1 error] | |
+ 58 hidden modules | |
ERROR in ./src/App.fs | |
Module Error (from ./node_modules/fable-loader/index.js): | |
/home/nyatracos/elmish-getting-started/src/App.fs(7,6): (7,10) error FSHARP: Unexpected keyword 'type' in open declaration. Expected identifier, 'global' or other token. (code 10) | |
@ ./src/App.fsproj 1:0-25 1:0-25 | |
ℹ 「wdm」: Failed to compile. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"private": true, | |
"scripts": { | |
"start": "webpack-dev-server", | |
"build": "webpack" | |
}, | |
"dependencies": { | |
"react": "^16.8.0", | |
"react-dom": "^16.8.0" | |
}, | |
"devDependencies": { | |
"@babel/core": "^7.1.2", | |
"fable-compiler": "^2.4.16", | |
"fable-loader": "^2.1.8", | |
"webpack": "^4.38.0", | |
"webpack-cli": "^3.3.6", | |
"webpack-dev-server": "^3.7.2" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require("path") | |
module.exports = { | |
mode: "none", | |
entry: "./src/App.fsproj", | |
devServer: { | |
contentBase: path.join(__dirname, "./dist") | |
}, | |
module: { | |
rules: [{ | |
test: /\.fs(x|proj)?$/, | |
use: "fable-loader" | |
}] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment