Conditional array as a parameter inside array

Solution 1:

You could simply construct the array before passing it into process.

First create your default array, this could be:

const extensions = [a, b]

Then add an extra condition in case your boolean is true:

if(myFlag) {
  extensions.push(...bindings)
}

Combining this together:

const extensions = [a, b]

if(myFlag) {
  extensions.push(...bindings)
}

const obj = new plugin.process({
  extensions
});

If bindings need to be added before a and b, we can write logic like this:

const extensions = []

if(myFlag) {
  extensions.push(...bindings)
}

extensions.push(a, b)

const obj = new plugin.process({
  extensions
});