File in invalid path will mark namespace for reload

Description

Having a cljc file at path public/js/out/foo/bar.cljc with ns form (ns foo.bar) will result in namespace foo.bar being reloaded.

This is problematic because ClojureScript compiler will copy all the input files to :output-dir for source-map use. Lately as more libraries have started using cljc, and this has started causing problems in cases where library is used on Clojure env. Cljs compilation will result in reload of the library code, which can redefine protocols etc. and break the Clojure env.

I think it would make sense for tools.namespace to ignore changes where file path and namespace don't match.
Another question and perhaps way to fix this, is to understand why dependency resolution doesn't work in this case: namespaces which depend on the protocols at a cljc file on output-dir aren't reloaded.

Environment

None

Assignee

Stuart Sierra

Reporter

Juho Teperi

Labels

None

Approval

None

Patch

Code and Test

Priority

Major
Configure