Skip to content

The extraExcludes Option

markw65 edited this page Feb 16, 2024 · 3 revisions

If you want to change the exclude annotations when the optimizer is running (eg because the code doesn't fit without it, or just so you can include an indicator in the app while testing), you can use the extraExcludes option.

The extraExcludes option lets you add or remove excludeAnnotations from a build, without editing your monkey.jungle. The option can be specified in the VSCode settings (global, workspace or folder level), and also in your build tasks in tasks.json, or launch configs in launch.json.

The format is a semi-colon separated list of excludeAnnotations. Annotations preceded by - will be removed from the excludeAnnotations for the build, while plain annotations will be added to them.

Rationale

If you have some code that you only want to include when the optimizer is running, for example, you can put this in monkey.jungle:

base.excludeAnnotations = only_with_optimizer

Then set the extraExcludes option to without_optimizer;-only_with_optimizer. Note the -, which means "remove this exclude annotation from the build".

Then in your code you can have:

(:only_with_optimizer)
function myComplexFunction() {
  // Lots of complexity
}
(:without_optimizer)
function myComplexFunction() { /* empty */ }

Alternatively, if you use Garmin's O1 or above, you could write your code this way:

(:only_with_optimizer)
const optimizerIsRunning = true

(:without_optimizer)
const optimizerIsRunning = false

function myComplexFunction() {
  if (optimizerIsRunning) {
    // Lots of complexity
  }
}

and everything under the if will be removed when the prettier optimizer isn't run.

Clone this wiki locally