Buckle up Mithril!
Testing Mithril with Bucklescript
Workflow
- write js-ffi (in bucklescript) and normal ocaml code in src/
- npm run watch runs ninja build tool, compiles src-files to folder lib/js/src
- npm run bundle-watch runs webpack via entry lib/js/src/main.js, puts bundle under dist/
- browser-> public/index.html
Errors
don’t know how to call function in obj, i.e. this structure:
- { [Function: m] mount: ”, … }
- this object we get when var m = require(‘mithril’)
- m here is mithrils m-helper which unifies a lot of functionality
- this not working: external h : string -> string -> vnode = “m” [@@bs.module “mithril”]
- SOLUTION: leave [@@bs.module] empty, i.e.:
- external m : string -> string -> vnode = “mithril” [@@bs.module]
- will generate: M(“span”, v[0])
- SOLUTION: leave [@@bs.module] empty, i.e.:
duplicate code in mithril’s .ml and .mli files
- when removing mli declarations, bsc complaining: unbound symbols