Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to make Cljs warnings fatal #106

Open
Deraen opened this issue Nov 2, 2015 · 8 comments
Open

Add option to make Cljs warnings fatal #106

Deraen opened this issue Nov 2, 2015 · 8 comments
Assignees

Comments

@Deraen
Copy link
Member

Deraen commented Nov 2, 2015

For production builds it would be useful to have Cljs task fail completely if there are any warnings.

I think this should be a separate option.

@martinklepsch
Copy link
Member

With the warnings on fileset metadata this could even be a separate task. Not sure if there is much value in that besides keeping code out of the regular cljs task though. edit: Would be a nice example of what fileset metadata enables.

@micha
Copy link
Contributor

micha commented Nov 2, 2015

Yes, warning/error info on the fileset would be a great way to solve this. If we could draft a standard for this (perhaps functions in boot.core) then we could make completely separate tasks that could fail on error, print messages in some preferred format, send messages to other services, etc.

The way it would work is the task that catches the error/warning/etc would attach that info to the fileset as metadata and passit down the pipeline. If a subsequent task handles it that task can remove the metadata from the fileset before it passes it on to the next task. Thus, when the fileset bubbles back up to the task where the error originated it can handle it in some default way if the metadata is still on the fileset.

@nberger
Copy link

nberger commented Jan 11, 2016

We have the following task in a project:

(defn throw-when-cljs-warnings []
  (b/with-pre-wrap fileset
    (let [warnings (->> fileset
                        all-cljs-builds
                        (map :adzerk.boot-cljs/warnings)
                        (apply merge)
                        (remove empty?))]
      (when (seq warnings)
        (throw (Exception. "There were warnings from the cljs compile step!")))
      fileset)))

It works for us, helped catching some warnings :)

@pesterhazy
Copy link

@nberger thanks for the snippet, looks great.

Adding this as a boot-cljs option would be a great addition however. I asked elsewhere if a "strict mode" (like -Werror, fail on warning) could be added to the clojurescript compiler. I got a negative answer, which I take to mean that tooling is the place to do this. I'd like to use it even for dev builds.

@martinklepsch
Copy link
Member

@nberger @pesterhazy any of you up for making a PR? :)

@pesterhazy
Copy link

@martinklepsch, would love to but don't know when I'll get a chance

@pesterhazy
Copy link

See http://jakemccrary.com/blog/2015/12/19/clojurescript-treat-warnings-as-errors/ as an example of how to do this, with lein-cljsbuild.

@Deraen
Copy link
Member Author

Deraen commented Aug 17, 2016

Boot-cljs overwrites the warning-handler to store the warnings in the fileset metadata, so that is not going to work with Boot-cljs current: https://github.com/adzerk-oss/boot-cljs/blob/master/src/adzerk/boot_cljs/impl.clj#L91

Boot-cljs could add the handler to those set by user, but I'm not sure if this is very useful. A separate task or option is good idea for this.

@Deraen Deraen self-assigned this Sep 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants