<< Back to previous view

[TNS-45] File in invalid path will mark namespace for reload Created: 13/Sep/16  Updated: 26/Sep/16

Status: Open
Project: tools.namespace
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Major
Reporter: Juho Teperi Assignee: Stuart Sierra
Resolution: Unresolved Votes: 0
Labels: None

Attachments: Text File TNS-45-2.patch    


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.

Comment by Juho Teperi [ 13/Sep/16 3:50 PM ]

This is nearly the same to http://dev.clojure.org/jira/browse/TNS-24, but this case the inconsistently named ns will be reloade because there is a copy in the correct path.

Comment by Juho Teperi [ 18/Sep/16 10:00 AM ]

Proposed patch with a test.

find-sources-in-dir is the easiest place to do the check, because we need the directory path.

  • Possibly breaking for direct users of find-sources-in-dir?
  • Now both find-sources-in-dir and file/files-and-deps need to read the ns form.
Comment by Juho Teperi [ 26/Sep/16 6:43 AM ]

Fixed a typo on the patch.

Generated at Sat Oct 01 17:21:48 CDT 2016 using JIRA 4.4#649-r158309.