JS_OF_OCAML(1)
π 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 againstjs_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β registerFILEto the pseudo filesystem. get in there, file.-I DIRβ addDIRto 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 toFILE.
π₯ 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 filesJS_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 programPROGRAM. 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 forSECTION.--debuginfo,--debug-infoβ output debug information.--disable=OPTβ disable the optimizationOPT.--dynlinkβ enable dynlink of bytecode files. use this if you wanna be able to use theDynlinkmodule. heads up tho: you'll also need to link with'js_of_ocaml-compiler.dynlink'.--effects=KINDβ pick an implementation of effect handlers.KINDhas to be one ofcps,double-translationordisabled(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 optimizationOPT.--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 fileFILE.--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 toFILE.--opt=NUMβ set the optimization profile toNUM.--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 argumentWARN.--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 formatFMT. the valueFMTmust be one ofauto,pager,grofforplain. withauto, the format ispagerorplainwhenever theTERMenv var isdumbor 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 π slay123β on indiscriminate errors reported on standard error124β on command line parsing errors125β 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 π
π 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
- ubuntu resolute: js-of-ocaml 6.2.0-2build6 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms