JS_OF_OCAML(1)

πŸ“¦
version 6.2.0 Β· 4 versions
, in ubuntu resolute

πŸ’– JS_OF_OCAML πŸ’–

okay bestie, welcome to the js_of_ocaml compiler page β€” this is the one from the Js_of_ocaml Manual, and it's literally about turning your OCaml bytecode into JavaScript. sit down, grab a boba, we're doing this πŸ§‹βœ¨


✨ NAME ✨

js_of_ocaml β€” the Js_of_ocaml compiler, aka your new bestie πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

js_of_ocaml [COMMAND] …

🌸 DESCRIPTION 🌸

Js_of_ocaml is a compiler from OCaml bytecode to Javascript. that's the whole vibe. it means you can take your pure OCaml programs and run them in JavaScript environments β€” think web browsers, think Node.js β€” no cap. πŸ‘‘


πŸ’œ OPTIONS (TOPLEVEL) πŸ’œ

  • --export=VAL β€” a file holding the list of units to export in a toplevel, with Dynlink or with --linkall. if you don't give it, all units get exported. generous queen behavior fr fr.
  • --nocmis, --no-cmis β€” don't include cmis when compiling to toplevel. nope, not today. πŸ™ˆ
  • --toplevel β€” compile a toplevel and embed the necessary cmis (unless you passed --no-cmis, obviously πŸ’…). you can configure which compilation units get exported with --export. also heads up bestie: you'll also need to link against js_of_ocaml-toplevel.

πŸŽ€ OPTIONS (FILESYSTEM) πŸŽ€

  • --extern-fs β€” configure the pseudo-filesystem so it allows registering files from outside. (this is the default, so it's already on unless you say otherwise)
  • --file=FILE β€” register FILE to the pseudo filesystem. get in there, file.
  • -I DIR β€” add DIR to the list of include directories.
  • --no-extern-fs β€” configure the pseudo-filesystem to NOT allow registering files from outside. boundaries, established.
  • --ofs=FILE β€” output the filesystem to FILE.

πŸ”₯ COMMANDS πŸ”₯

  • build-fs [-I DIR] [-o FILE] [OPTION]… [FILES]… β€” the Js_of_ocaml pseudo filesystem utility ✨
  • build-runtime [OPTION]… [JS_FILES]… β€” build a standalone runtime. used for separate compilation, iykyk.
  • check-runtime [--target-env={isomorphic,browser,nodejs}] [OPTION]… [FILES]… β€” check runtime πŸ‘€
  • compile [OPTION]… [JS_FILES]… PROGRAM β€” the Js_of_ocaml compiler itself. main character energy.
  • link [OPTION]… [JS_FILES]… β€” the Js_of_ocaml linker πŸ”—
  • print-standard-runtime [OPTION]… β€” print the standard runtime to stdout

πŸ’… ARGUMENTS πŸ’…

  • JS_FILES β€” link JavaScript files JS_FILES. and okay this part is cute: you can refer to a path relative to Findlib packages using the syntax '+pkg_name/file.js'. obsessed.
  • PROGRAM (required) β€” compile the bytecode program PROGRAM. and if you're feeling quirky, use '-' to read from standard input instead.

🌈 OPTIONS 🌈

  • --custom-header=VAL β€” give your generated JavaScript file a custom header. super useful if you wanna make the script an executable file with #!/usr/bin/env node πŸ’€
  • --debug=SECTION β€” enable debug for SECTION.
  • --debuginfo, --debug-info β€” output debug information.
  • --disable=OPT β€” disable the optimization OPT.
  • --dynlink β€” enable dynlink of bytecode files. use this if you wanna be able to use the Dynlink module. heads up tho: you'll also need to link with 'js_of_ocaml-compiler.dynlink'.
  • --effects=KIND β€” pick an implementation of effect handlers. KIND has to be one of cps, double-translation or disabled (which is the default). effects won't be supported if it's unspecified, so don't play games with this one bestie.
  • --empty-sourcemap, --empty-source-map β€” always generate empty source maps. iconic.
  • --enable=OPT β€” enable the optimization OPT.
  • --include-runtime β€” include the (partial) runtime when compiling cmo and cma files to JavaScript.
  • --keep-unit-names β€” keep the unit name πŸ’–
  • --linkall β€” link all primitives and compilation units. exported compilation units can be configured with --export.
  • --load-shape=FILE β€” load the shape file FILE.
  • --no-sourcemap, --no-source-map β€” don't generate a source map. and lowkey, all other source map related flags will be ignored once you say this.
  • --noinline, --no-inline β€” disable inlining.
  • --noruntime, --no-runtime β€” do not include the standard runtime.
  • -o FILE β€” set the output file name to FILE.
  • --opt=NUM β€” set the optimization profile to NUM.
  • --pretty β€” pretty print the output ✨
  • -q, --quiet β€” suppress non-error messages. shhh 🀫
  • --set=PARAM=VALUE β€” set compiler options.
  • --setenv=PARAM=VALUE β€” set an environment variable statically.
  • --source-map-inline β€” inline the sourcemap in the generated JavaScript.
  • --source-map-no-source β€” do not inline sources in the source map.
  • --source-map-root=VAL β€” root dir for the source map.
  • --sourcemap, --source-map β€” generate a source map.
  • --target-env={isomorphic,browser,nodejs} (absent=isomorphic) β€” the runtime compile target.
  • -w WARN β€” enable or disable the warnings specified by the argument WARN.
  • --Werror β€” turn all warnings into errors. no warnings allowed, periodt. πŸ’€
  • --wrap-with-fun=VAL (absent=<Immediately Invoked Function Expression>) β€” wrap the generated JavaScript code inside a function that needs to be applied with the global object.

πŸ’œ COMMON OPTIONS πŸ’œ

  • --help[=FMT] (default=auto) β€” show this help in format FMT. the value FMT must be one of auto, pager, groff or plain. with auto, the format is pager or plain whenever the TERM env var is dumb or undefined. bestie behavior: just ask for help when you need it 🫢
  • --version β€” show version information.

⭐ EXIT STATUS ⭐

js_of_ocaml exits with:

  • 0 β€” on success πŸŽ‰ slay
  • 123 β€” on indiscriminate errors reported on standard error
  • 124 β€” on command line parsing errors
  • 125 β€” on unexpected internal errors (bugs) 😭

πŸ’€ BUGS πŸ’€

bugs are tracked on github at https://github.com/ocsigen/js_of_ocaml/issues. go report them bestie, they wanna know.


🌈 SEE ALSO 🌈

ocaml(1)


πŸ‘‘ AUTHORS πŸ‘‘

Jerome Vouillon, Hugo Heuzard. legends, fr fr.


πŸŽ€ LICENSE πŸŽ€

Copyright (C) 2010-2020.

js_of_ocaml is free software, you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, with linking exception; either version 2.1 of the License, or (at your option) any later version. 🫢


okay that's the whole thing, you ate that πŸ’…βœ¨ this was Js_of_ocaml 6.2.0, from the JS_OF_OCAML(1) manual page β€” mwah, go compile something cute πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from