_Comment made by: mfikes_
The patch works for the ticket description if you go with the default browser REPL, but on macOS if you specify the Node REPL you will see a failure related to the canonicalization of the temp directory path:
$ clj -Sdeps '{:deps {org.clojure/clojurescript {:local/root "/Users/mfikes/Projects/clojurescript"}}}' -m cljs.main -re node -r
cljs.user=> Exception in thread "main" java.lang.AssertionError: Assert failed: Output file /private/tmp/cljs-2917/cljs/core.js is not in output directory /var/folders/gx/nymj3l7x4zq3gxb97v2zwzb40000gn/T/out5998260788018592691311499618489419
(string/starts-with? (util/path output-file) out-dir)
at cljs.closure$compile_file.invokeStatic(closure.clj:636)
at cljs.closure$compile_file.invoke(closure.clj:625)
at cljs.closure$eval7272$fn__7273.invoke(closure.clj:730)
at cljs.closure$eval7175$fn__7176$G__7164__7183.invoke(closure.clj:543)
at cljs.closure$eval7278$fn__7279.invoke(closure.clj:739)
at cljs.closure$eval7175$fn__7176$G__7164__7183.invoke(closure.clj:543)
at cljs.closure$compile.invokeStatic(closure.clj:595)
at cljs.closure$compile.invoke(closure.clj:592)
at cljs.repl.node$setup$fn__9880.invoke(node.clj:164)
at cljs.repl.node$setup.invokeStatic(node.clj:131)
at cljs.repl.node$setup.invoke(node.clj:124)
at cljs.repl.node.NodeEnv._setup(node.clj:236)
at cljs.repl$repl_STAR_$fn__8878.invoke(repl.cljc:951)
at cljs.compiler$with_core_cljs.invokeStatic(compiler.cljc:1416)
at cljs.compiler$with_core_cljs.invoke(compiler.cljc:1405)
at cljs.repl$repl_STAR_.invokeStatic(repl.cljc:949)
at cljs.repl$repl_STAR_.invoke(repl.cljc:861)
at cljs.cli$repl_opt.invokeStatic(cli.clj:314)
at cljs.cli$repl_opt.invoke(cli.clj:301)
at cljs.cli$main.invokeStatic(cli.clj:646)
at cljs.cli$main.doInvoke(cli.clj:635)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$apply.invoke(core.clj:652)
at cljs.main$_main.invokeStatic(main.clj:61)
at cljs.main$_main.doInvoke(main.clj:52)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:702)
at clojure.core$apply.invokeStatic(core.clj:657)
at clojure.main$main_opt.invokeStatic(main.clj:317)
at clojure.main$main_opt.invoke(main.clj:313)
at clojure.main$main.invokeStatic(main.clj:424)
at clojure.main$main.doInvoke(main.clj:387)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:702)
at clojure.main.main(main.java:37)
I think that this can be fixed by asserting
(same-or-subdirectory-of? out-dir output-file)
instead of
(string/starts-with? (util/path output-file) out-dir)
Another issue that concerns me about the patch is that {{output-file}} could be a _relative_ {{File}}, in which case
(io/file out-dir output-file)
is a legitimate construct and the code should probably take that branch. In my opinion, it is only when {{out-file}} is _absolute_ (either a string or {{File}}) that it should be take "as is" and not relative to {{out-dir}}. In other words, the condition is probably not that it satisfies {{util/file?}} but rather {{absolute-path?}}.
If we consider those two changes (using {{absolute-path?}} to trigger the logic and {{same-or-subdirectory-of?}} for the assert), this might cover all bases. (Both fns would need to be {{declare}} d as they occur after {{compile-file}}.)