philoskim / debux

A trace-based debugging library for Clojure and ClojureScript.
468 stars 19 forks source link

add :scope provided to clojure and clojurescript #13

Closed AndreaCrotti closed 5 years ago

AndreaCrotti commented 5 years ago

This is to avoid dependencies (specially clojurescript) in cases where they are not used by the project being debugged.

philoskim commented 5 years ago

Thanks for your pull request, but I'm sorry to say that I can't accept your request.

This issue was raised here (https://github.com/philoskim/debux/issues/3 and https://github.com/philoskim/debux/issues/1).

The debux library shares a lot of code between Clojure and ClojureScript to eliminate code duplicates. Therefore debux library uses cljs/analyzer/api.clj internally in the shared Clojure and ClojureScript source code. However, the cljs/analyzer/api.clj file is included in clojurescript release, not in clojure release . So when I follow your proposal, modify the project.clj in debux library as you said and execute the following code, the exception occurs.

;; project.clj
(defproject debux-test "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.10.1"]
                 [philoskim/debux "0.5.6"]]
  :repl-options {:init-ns debux-test.core})
;; src/debux_test/core.clj
(ns debux-test.core)

(use 'debux.core)

(defn foo
  "I don't do a whole lot."
  [x]
  (println x "Hello, World!"))

(dbgn (+ 1 2 (* 3 4)))
2. Unhandled clojure.lang.Compiler$CompilerException
   Error compiling debux/common/util.cljc at (1:1)
   #:clojure.error{:phase :compile-syntax-check,
                   :line 1,
                   :column 1,
                   :source "debux/common/util.cljc"}

1. Caused by java.io.FileNotFoundException
   Could not locate cljs/analyzer/api__init.class,
   cljs/analyzer/api.clj or cljs/analyzer/api.cljc on classpath.

So I decided to delete :scope "provided" in the original project.clj and split the library into the development version (debux) and the production version (debux-stubs).

To sum up, I tried your proposal originally but the above problem occurred, so gave it up.