Giter VIP home page Giter VIP logo

fable-getting-started's Introduction

Fable Getting Started

This is the simplest Fable application you can make: it is a frontend web application with an empty page that writes Hello from Fable to the console.

This template is not for production use and is only used to demonstrate Fable features in The Elmish Book

Requirements

Installation

To compile the project, first you need to restore dotnet tools which bring it the Fable compiler

dotnet tool restore

Then run the following commands to install Node.js dependencies such as webpack and bundle the application

npm install
npm run build

npm install will install dependencies from npm which is the Node.js equivalent of dotnet's Nuget registry. These dependencies include the Fable compiler itself as it is distributed to npm to make compilation workflow as simple as possible.

npm run build is an alies for "compile with Fable, then bundle with webpack"

After npm run build finished running, the generated javascript will be bundled in a single file called main.js located in the dist directory along with an existing index.html page that references that script file.

Development mode

While developing the application, you don't want to recompile the application every time you make a change. Instead of that, you can start the compilation process in development mode which will watch changes you make in the file and re-compile automatically really fast:

npm install
npm start

If you already ran npm install then you don't need to run it again. npm start will start the developement mode by invoking webpack-dev-server: the webpack development server that starts a lightweight local server at http://localhost:8080 from which the server will serve the client application

fable-getting-started's People

Contributors

dependabot[bot] avatar goswinr avatar rommsen avatar wallacekelly avatar zaid-ajaj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fable-getting-started's Issues

Webpack & Debugging

I am new to Fable, but have watched a number of Roman and your youtube videos on the Dev Owl channel.

The project appears to be out of date. The webpack.config.js schema has changed with version 5.58.2 webpack. In order to get the code to run I had to make the following changes:

// Note this only includes basic configuration for development mode.
// For a more comprehensive configuration check:
// https://github.com/fable-compiler/webpack-config-template

var path = require("path");

module.exports = {
    mode: "development",
    entry: "./src/App.fs.js",
    output: {
        path: path.join(__dirname, "./public"),
        filename: "bundle.js",
    },
    devServer: {
        static: {
            publicPath: "/",
            directory: "./public",
        },
        port: 8080,
    },
    module: {
        rules: [{
            test: /\.fs(x|proj)?$/,
            use: "fable-loader"
        }]
    }
}

I am also having trouble debugging the fable code using Visual Code version 1.61.2 and v5.8.1 of the Ionide plugin. I have had to adapt the .vscode/launch.json as the Browser Preview and the Chrome Debugger plugins seem to be deprecated.

I am currently using the following launch.json file:

{
  "version": "0.2.0",
  "configurations": [
      {
          "name": "Debug with Edge",
          "type": "pwa-msedge",
          "request": "launch",
          "preLaunchTask": "Watch Client",
          "url": "http://localhost:8080",
          "webRoot": "${workspaceFolder}/src",
          "sourceMaps": true,
          "sourceMapPathOverrides": {
              "webpack:///*": "${workspaceFolder}/*",
          }
      },
      {
          "name": "Debug with Chrome",
          "type": "pwa-chrome",
          "request": "launch",
          "preLaunchTask": "Watch Client",
          "url": "http://localhost:8080",
          "webRoot": "${workspaceFolder}/src",
          "sourceMaps": true,
          "sourceMapPathOverrides": {
              "webpack:///*": "${workspaceFolder}/*",
          }
      }
  ],
}

When I start debugging, the code builds and webpack starts but the browser window is never shown. I can see the "Watch Client" task running but nothing else happens.

The tasks.json file contents are the same as the repository. Although I did try:

          "command": "dotnet",
          "args": [ "fable", "watch", "src", "--run", "webpack-dev-server" ],

Do you have any suggestions as to what is going wrong?

Many thanks.

Question about fixes to get everything working according to the youtube video

@Zaid-Ajaj I know its been a while since your last commit, but I have some questions

I watched the dev-owl video on youtube. Are the following correct

  1. You need devtool: "source-map" in the webpack config to be able to debug App.fs?
  2. Why did you change to dist instead of public, and is this the default output destination in webpack, since you just erased
output: {
        path: path.join(__dirname, "./public"),
        filename: "bundle.js",
    },

in last commit from webpack config?

Does the missing source map file have anything to do with you changing mode from mode: "development" to mode: "none" in your last commit? Is this why main.js.map is suddenly missing (without the devtool: "source-map")?

I thought so because I can see you still have both bundle.js and bundle.js.map in GIT ignored. So source mapping used to be generated earlier...

Addendum

I watched the rest of the video, and saw there used to be

devtool: isProduction ? 'source-map' : 'eval-source-map'

in the web config. I always code along any tutorial, because learning is about trying/playing not watching/reading ๐Ÿ˜‰

Error thrown by LoadRunner.js as part of webpack: callback was already called

Platform: Windows 10
Shell: Git Bash for Windows (with zsh)
Nodejs: v18.4.0
fable-compiler: 2.13.0

I am trying to run through the code examples from "The Elmish Book". (Thank you very much for this book. Reading it really helps understand what's going on.)

I cloned this repository, removed the .git directory (since I have a "parent" local git repository already), and then executed npm install. Installing packages succeeded with warnings and some audit flags.

I then ran npm run build and encountered an error I'm at loss to investigate. Here's my shell output:

larry.jones in fable-getting-started on laj/proto/use-npm
ฮป npm run build

build
webpack

fable-compiler 2.13.0
fable: Compiled src\App.fsproj
C:\Users\larry.jones\professional\projects\the-elmish-book\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\larry.jones\professional\projects\the-elmish-book\fable-getting-started\node_modules\loader-runner\lib\LoaderRunner.js:106:10)
at C:\Users\larry.jones\professional\projects\the-elmish-book\fable-getting-started\node_modules\fable-loader\index.js:147:9
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v18.4.0

I've joined the F# Software Foundation and am awaiting my invitation to the slack channel, but thought this repository might be an appropriate place to raise this issue.

Thanks.

P.S. My first set of steps, which produced the same error, involved deleting the node_modules directory and package-lock.json and running yarn install. This start eventually led to the same error.

fable-getting-started app hangs

I was following The Elmish Book and the Fable compilation hangs because of the early Fable 4 version in the tools manifest: 4.0.0-snake-island-alpha-021.

When I changed it to 4.9.0, compilation succeeded.
It would be good to update version in this reference repo so no one else would trip on this.

Thank you,
Viktoras

Package deps may be out of date

Just cloned this repo while starting to follow https://zaid-ajaj.github.io/the-elmish-book/ . Upon running npm install, I got the following errors:

image

Removing node_modules, package-lock.json, and running npm install again resolved my issues, although I got this warning:

image

Just wanted to give a heads up. Don't know the ecosystem well enough to know if simply updating the dependencies is enough to fix this, but it worked for me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.