diff --git a/doc/jsoo.rst b/doc/jsoo.rst index fb651121a224..e169b3b70c2f 100644 --- a/doc/jsoo.rst +++ b/doc/jsoo.rst @@ -71,7 +71,16 @@ Dune supports two modes of compilation: The separate compilation mode will be selected when the build profile is ``dev``, which is the default. It can also be explicitly specified -in an ``env`` stanza. See :doc:`/reference/dune/env` for more -information. +in an ``env`` stanza (see :doc:`/reference/dune/env`) or per executable +inside ``(js_of_ocaml (compilation_mode ...))`` (see :doc:`/reference/dune/executable`) + +Sourcemap +========= + +Js_of_ocaml can generate sourcemap for the generated javascript file. +It can either embed it at the end of the ``.js`` file or write it to separate file. +By default, it is inlined when using the ``dev`` build profile, and is not generated otherwise. +The behavior can explicitly be specified in an ``env`` stanza (see :doc:`/reference/dune/env`) +or per executable inside ``(js_of_ocaml (sourcemap ...))`` (see :doc:`/reference/dune/executable`) .. _js_of_ocaml: http://ocsigen.org/js_of_ocaml/ diff --git a/doc/reference/dune/env.rst b/doc/reference/dune/env.rst index 64f2a8968003..569faa70929b 100644 --- a/doc/reference/dune/env.rst +++ b/doc/reference/dune/env.rst @@ -45,6 +45,9 @@ Fields supported in ```` are: compilation or not where ```` is either ``whole_program`` or ``separate``. +- ``(js_of_ocaml (sourcemap ))`` controls whether to generate sourcemap + or not where ```` is either ``no``, ``file`` (to generate sourcemap in a ``.map`` file next the the generated javascript file) or ``inline`` (to inline the sourcemap at the end of the generated javascript file). + - ``(js_of_ocaml (runtest_alias ))`` specifies the alias under which :ref:`inline_tests` and tests (:ref:`tests-stanza`) run for the `js` mode. diff --git a/doc/reference/dune/executable.rst b/doc/reference/dune/executable.rst index b9129d0e380e..0ac01b4ec7af 100644 --- a/doc/reference/dune/executable.rst +++ b/doc/reference/dune/executable.rst @@ -242,7 +242,7 @@ contains C stubs you may want to use ``(modes exe)``. js_of_ocaml ~~~~~~~~~~~ -In ``library`` and ``executables`` stanzas, you can specify ``js_of_ocaml`` +In ``library`` and ``executable`` stanzas, you can specify ``js_of_ocaml`` options using ``(js_of_ocaml ())``. ```` are all optional: @@ -259,10 +259,16 @@ options using ``(js_of_ocaml ())``. - ``(javascript_files ())`` to specify ``js_of_ocaml`` JavaScript runtime files. +- ``(compilation_mode )`` where ``>`` is either ``whole_program`` or ``separate``. + This is only available inside ``executable`` stanzas. + +- ``(sourcemap )`` where ``>`` is one of ``no``, ``file`` or ``inline``. + This is only available inside ``executable`` stanzas. + ```` is specified in the :doc:`/reference/ordered-set-language`. -The default value for ``(flags ...)`` depends on the selected build profile. The -build profile ``dev`` (the default) will enable sourcemap and the pretty +The default values for ``flags``, ``compilation_mode`` and ``sourcemap`` depend on the selected build profile. The +build profile ``dev`` (the default) will enable inline sourcemap, separate compilation and pretty JavaScript output. See :ref:`jsoo` for more information.