Skip to content

Commit

Permalink
Document --closure-args in emcc reference. (#15683)
Browse files Browse the repository at this point in the history
The environment variable `EMCC_CLOSURE_ARGS` does not work well in
all places (e.g. Bazel), so it would be good document the ability to use flags
to impact Closure.
  • Loading branch information
kjlubick authored Dec 1, 2021
1 parent 8028625 commit 8ce0ce0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/emcc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,16 @@ Options that are modified or new in *emcc* are listed below:
* Closure is only run if JavaScript opts are being done ("-O2" or
above).

"--closure-args=<args>"
[link] Pass arguments to the *Closure compiler*. This is an
alternative to "EMCC_CLOSURE_ARGS".

For example, one might want to pass an externs file to avoid
minifying JS functions defined in "--pre-js" or "--post-js" files.
To pass to Closure the "externs.js" file containing those public
APIs that should not be minified, one would add the flag: "--
closure-args=--externs=path/to/externs.js"

"--pre-js <file>"
[link] Specify a file whose contents are added before the emitted
code and optimized together with it. Note that this might not
Expand Down
7 changes: 7 additions & 0 deletions site/source/docs/tools_reference/emcc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ Options that are modified or new in *emcc* are listed below:
- If closure compiler hits an out-of-memory, try adjusting ``JAVA_HEAP_SIZE`` in the environment (for example, to 4096m for 4GB).
- Closure is only run if JavaScript opts are being done (``-O2`` or above).

``--closure-args=<args>``
[link]
Pass arguments to the :term:`Closure compiler`. This is an alternative to ``EMCC_CLOSURE_ARGS``.

For example, one might want to pass an externs file to avoid minifying JS functions defined in ``--pre-js`` or ``--post-js`` files.
To pass to Closure the ``externs.js`` file containing those public APIs that should not be minified, one would add the flag:
``--closure-args=--externs=path/to/externs.js``

.. _emcc-pre-js:

Expand Down

0 comments on commit 8ce0ce0

Please sign in to comment.