We're updating the issue view to help you get more done. 

Setting *main-cli-fn* when using :target :nodejs shouldn't be manditory

Description

Currently, when you use :target :nodejs in the build options for ClojureScript, the resulting code requires you to set main-cli-fn to a function.

This prevents someone from writing a library that can be used by JavaScript developers because it forces code execution on require. It also makes writing a CLI tool that can be distributed using NPM less straightforward. I ran into this issue trying to create a Leiningen template for writing CLI tools that could be installed using npm install or npm link. I had a wrapper script to take care of the CLI use-case, and intended to write the ClojureScript module in a more library oriented way, but ran into issues. I could work around this by not using the wrapper script, but it got me thinking about the more general library issue.

I don't see any reason why you should be forced to set main-cli-fn and so I'm suggesting making it optional.

Attached is a patch that makes it optional but retains the check for whether the value it is set to is a function in the case where it is set.

This is my first time submitting a change to a project using a git patch and not a pull request, so let me know if I've made the patch wrong.

Environment

None

Status

Assignee

Unassigned

Reporter

import

Labels

None

Approval

None

Patch

Code

Fix versions

Affects versions

1.7.145

Priority

Minor