Zaid-Ajaj / the-elmish-book

A practical guide to building modern and reliable web applications in F# from first principles
https://zaid-ajaj.github.io/the-elmish-book
Other
335 stars 49 forks source link

Examples not working #182

Closed HarryMcCarney closed 11 months ago

HarryMcCarney commented 11 months ago

This follows a discussion in.the #web room of the fsharp discord

I am trying get started with fable/elmish/feliz. Have been reading through the Elmish book (which is excellent) but struggling to get the examples working. The feliz template does work but feels like too much magic for my current level of understanding. Is there a barebones example that works with latest dependencies or maybe i am doing something wrong.

this

https://zaid-ajaj.github.io/the-elmish-book/#/chapters/fable/hello-world

returns

PS C:\Users\harry\fableTest\fable-getting-started> npm run build

build webpack

fable-compiler 2.4.21 C:\Users\harry\fableTest\fable-getting-started\node_modules\loader-runner\lib\LoaderRunner.js:106 throw new Error("callback(): The callback was already called."); ^

Error: callback(): The callback was already called. at context.callback (C:\Users\harry\fableTest\fable-getting-started\node_modules\loader-runner\lib\LoaderRunner.js:106:10) at C:\Users\harry\fableTest\fable-getting-started\node_modules\fable-loader\index.js:147:9 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

And

https://github.com/Zaid-Ajaj/elmish-getting-started.git

returns

PS C:\Users\harry\elmishTest> npm run build

build webpack

fable-compiler 2.13.0 asset main.js 1.47 KiB [compared for emit] (name: main) ./src/App.fsproj 39 bytes [built] [code generated] [1 error]

ERROR in ./src/App.fsproj Module build failed (from ./node_modules/fable-loader/index.js):
Error: Exception of type 'FSharp.Compiler.CompileOps+FileNameNotResolved' was thrown. at C:\Users\harry\elmishTest\node_modules\fable-loader\index.js:98:22 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

webpack 5.88.2 compiled with 1 error in 3226 ms

A work around was suggested in discord but not clear if its best practice. Any help appreciated!

MangelMaxime commented 11 months ago

I see that you are using fable-loader which is for Fable 2 and is not supported anymore.

I made this template for using Fable 4, Vite and React you can use it on your machine or directly in the browser by clicking on the Gitpod button.

HarryMcCarney commented 11 months ago

ah yes thanks, those changes are on the fable-v4-updates branch. The master branch contains the outdated package.json

The v4 branch did build for me but I had to update from fable v4.0,0 to version 4.2.1 before the build completed successfully.