package b0

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

js_of_ocaml B0 file support

Metadata

type comp_mode = [
  1. | `Separate
  2. | `Whole
]

The type for js_of_ocaml compilation either whole program compilation mode for runtime efficiency and minimality or `Separate for build time efficiency.

comp are options added to the js_of_ocaml compile subcommand.

val comp_mode : comp_mode B0_meta.key

mode is the js_of_ocaml compilation mode.

FIXME this should likely be a store key.

source_map is the source map option.

val tag : unit B0_meta.key

tag indicates the entity is related to js_of_ocaml.

val toplevel : bool B0_meta.key

toplevel should be true to embed toplevel support in the js executable.

link are options added to the js_of_ocaml link subcommand.

val assets_root : B00_std.Fpath.t B0_meta.key

assets_root indicates the path w.r.t. to which assets are are Fpath.rerooted. Assets that are not prefoxied by assets_root are simply copied at the toplevel of the build dir.

val meta : ?meta:B0_meta.t -> ?assets_root:B00_std.Fpath.t -> ?comp:B00_std.Cmd.t -> ?comp_mode:comp_mode -> ?link:B00_std.Cmd.t -> ?requires:B00_ocaml.Lib.Name.t list -> ?source_map:B00_jsoo.source_map -> ?toplevel:bool -> unit -> B0_meta.t

meta creates a base metadata dictionary for compiling with js_of_ocaml. See the corresponding keys above. FIXME defaults.

Build units

val exe : ?doc:string -> ?meta:B0_meta.t -> ?action:B0_unit.action -> ?name:string -> string -> srcs:B0_srcs.sels -> B0_unit.t

exe n is a JavaScript "executable" file named n (without the .js extension).

  • doc is the unit doc string.
  • meta is the initial metadata.
  • requires are the OCaml libraries required to compile the JavaScript.
  • name is the name of the unit (defaults to n).
  • srcs are the executable sources. All files with extension .ml, .mli and .js are considered for compiling and linked in the JavaScript file.
val web : ?doc:string -> ?meta:B0_meta.t -> ?action:B0_unit.action -> ?name:string -> string -> srcs:B0_srcs.sels -> B0_unit.t

web n is an HTML page named n (without the .html extension).

  • doc is the unit doc string.
  • meta is the initial metadata.
  • requires are the OCaml libraries required to compile the JavaScript.
  • name is the name of the unit (defaults to n).
  • srcs are the executable sources. All files with extension .ml, .mli and .js are considered for compiling and linking the executable. The files B00_fexts.www in srcs minus .js files are copied over the build directory. If these files are can be rerooted to the build dir according to assets_dir they are copied as such otherwise they are copied assets_dir FIXME. A competing idea was to have a notion of root induced by B0_srcs selection. See the commented stuff there. This is likely something that will play better with generated assets. It's also sligthly borderline with deployements.

TODO document. The js file is n.js, if there's no .html source in the srcs a minimal HTML file is generated in which n.js is linked as a script and any css file in srcs as a stylesheet.

Build fragments

OCaml

Innovation. Community. Security.