Giter Site home page Giter Site logo

Comments (5)

MangelMaxime avatar MangelMaxime commented on June 6, 2024 1

Thanks for confirming.

I am closing this issue, because the problem is not with Fable but the weback configuration.

from fable.

MangelMaxime avatar MangelMaxime commented on June 6, 2024

Hello,

This is normal that you can't access the validate function.

The function is only available from inside the Program.fs.js or your bundle.js in your case. You need to look on Webpack documentation how to expose a bundle as a library.

I think you want to look for the output.library.type options in webpack.

Depending on the option you should be able to use it via a variable, a globally available API or using import statement.

If you are new to JavaScript, you should also look at ESM modules as this is the type of JavaScript that Fable produce.

from fable.

dcook-net avatar dcook-net commented on June 6, 2024

Ok, thanks.
I've tried this and I can't get it to work.
Are there examples of this?

from fable.

dcook-net avatar dcook-net commented on June 6, 2024

I think I now have it working....
once I confirm, I shall update here with the how.

from fable.

dcook-net avatar dcook-net commented on June 6, 2024

Confirmed, I have this working:

webpack.config.js:

var path = require("path");

module.exports = {
    mode: "development",
    entry: "./src/Program.fs.js",
    optimization: {
        minimize: false
    },
    output: {
        path: path.resolve(__dirname, './src/public'),
        filename: 'Program.fs.js',
        libraryTarget: 'var',
        library: 'Program'
    },

    devServer: {
        static: "./public",
        port: 8080,
    }
}

package.json:

{
  "private": true,
  "scripts": {
    "postinstall": "dotnet tool restore",
    "start": "fable watch src --run webpack serve"
  },
  "dependencies": {
    "webpack": "^5.75.0",
    "webpack-cli": "^5.0.0",
    "webpack-dev-server": "^4.11.1"
  }
}

I'll update my repo shortly too.

from fable.

Related Issues (20)

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.