# Boot-cljs compiler options

Boot-cljs does some special handling with some of [ClojureScript compiler options](https://clojurescript.org/reference/compiler-options),
these cases are either related to Boot temp dir and fileset architecture, or to
support some additional features of Boot-cljs.

Example of first case is `:output-to` and `:output-dir`. These filepaths need to
be under temp directory managed by Boot-cljs.

Example of second case if `:main` namespace. Boot-cljs writes it's own main namespace
because we need to support multiple `:require` namespaces from `.cljs.edn` files. This
is important because other tools ([boot-reload](https://github.com/adzerk-oss/boot-reload))
use `:require` to initialize themselves.

## Merge order

1. `:compiler-options` in `.cljs.edn` file
2. `:compiler-options` task option
3. `:optimizations` and `:source-map` task options
4. options automatically set by boot-cljs (`:output-dir`, `:output-to`, `:main`)"

## `:output-dir` & `:output-to`

If these options are set, path of Boot-cljs temp dir is prepended into these.

If values are not set, default value is created based on relative path of the `.cljs.edn` file.

- `resources/js/main.cljs.edn`
  - `:resource-paths #{"resources"}`
  - relative path of the file inside fileset is `js/main.cljs.edn`
  - `:output-dir` is set to `js/main.out`
  - `:output-to` is set to `js/main.js`

## `:main`

This value is always set to namespace generated by Boot-cljs, e.g. `boot.cljs.main31649`,
where the number is generated with `gensym`.

If user provides `:main` option, the namespace is appended to `:require` `.cljs.edn`
option, and is thus required by the Boot-cljs main namespace. This should usually
work nearly the same as without Boot-cljs main namespace, but this keeps the support
for Boot-reload and others to use `:require`.

Note: It could be possible for Boot-reload & co. to be set up using `:preloads`, but
that would change the loading order and cause problems with current implementation
of Boot-reload (check [#143](https://github.com/boot-clj/boot-cljs/pull/143) for some
information.)

## `:source-map`

This option can be provided task option or as compiler-option. If `:optimizations` is
not `:none` and `:modules` is not used, `:source-map` is automatically set to
`:output-to` with `.map` prepended.

## `:modules`

TODO:

Should work similar to `:output-to`. If user provides a value, it is prepended with
path to Boot-cljs temp dir, else default value is created based on relative path of `.cljs.edn`
file and name of the module.

Write documentation about boot-cljs compiler options logic
Write documentation about boot-cljs compiler options logic
