ClojureScript

Externs don't get loaded when running under immutant as cljs.js-deps/find-js-classpath fails

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    Java 1.8.0_05, Clojure 1.6.0, clojurescript 0.0-2234, immutant 1.1.1

Description

When compiling clojurescript that relies on library-provided externs (e.g. Om needing React.js externs), the clojurescript is compiled without errors, but the generated javascript fails to work, due to the externs not being loaded. Externs don't get loaded, as cljs.js-deps/find-js-classpath doesn't find the javascript externs file. This occurs because it uses cljs.js-deps/all-classpath-urls, which filters out the immutant classloader, since org.immutant.core.ImmutantClassLoader is not an instance of java.net.URLClassLoader (and hence lacks a .getURLs method anyway).

Activity

Hide
Toby Crawley added a comment -

Chas: Is there a reason not to depend on dynapath here? This exact case is kinda why it exists

Show
Toby Crawley added a comment - Chas: Is there a reason not to depend on dynapath here? This exact case is kinda why it exists
Hide
David Nolen added a comment -

Patch welcome for this.

Show
David Nolen added a comment - Patch welcome for this.
Hide
James Cash added a comment -

Simply replacing cljs.js-deps/all-classpath-urls with dynapath.util/all-classpath-urls worked for me. I don't know if there are policies around adding dependencies to cljs, but the following patch is working for me. Would it be preferable to re-implement the functionality instead?

Show
James Cash added a comment - Simply replacing cljs.js-deps/all-classpath-urls with dynapath.util/all-classpath-urls worked for me. I don't know if there are policies around adding dependencies to cljs, but the following patch is working for me. Would it be preferable to re-implement the functionality instead?
Hide
David Nolen added a comment -

We are not going to take on a dependency for this. The code should be copied over, thanks.

Show
David Nolen added a comment - We are not going to take on a dependency for this. The code should be copied over, thanks.
Hide
James Cash added a comment -

Due to the way dynapath works, I don't think a straightforward copying of the code will work, since it relies on a protocol. Backing up a step though, would it be reasonable for externs to be loaded via io/resource, in the same way that the :preamble is?

Show
James Cash added a comment - Due to the way dynapath works, I don't think a straightforward copying of the code will work, since it relies on a protocol. Backing up a step though, would it be reasonable for externs to be loaded via io/resource, in the same way that the :preamble is?
Hide
Toby Crawley added a comment -

Unfortunately, the code can't be copied over. Dynapath works by providing a protocol that providers/users of funky classloaders can implement, allowing libraries that use dynapath to access the dynamic features of those classloaders without having to care about the loader's concrete type. Dynapath itself provides implementations for j.n.URLClassLoader and c.l.DynamicClassloader by default, so libraries don't have to do anything special to access the dynamic features of those classes.

java.classpath also provides a similar mechanism that the Immutant classloader implements as well. If you are more open to dependencies that are under org.clojure, using that will work as well. Ideally, I'd like to see java.classpath subsume dynapath.

Show
Toby Crawley added a comment - Unfortunately, the code can't be copied over. Dynapath works by providing a protocol that providers/users of funky classloaders can implement, allowing libraries that use dynapath to access the dynamic features of those classloaders without having to care about the loader's concrete type. Dynapath itself provides implementations for j.n.URLClassLoader and c.l.DynamicClassloader by default, so libraries don't have to do anything special to access the dynamic features of those classes. java.classpath also provides a similar mechanism that the Immutant classloader implements as well. If you are more open to dependencies that are under org.clojure, using that will work as well. Ideally, I'd like to see java.classpath subsume dynapath.
Hide
James Cash added a comment -

Made a new patch that sidesteps the all-classpath-urls issue by just using io/resource instead of iterating over all urls

Show
James Cash added a comment - Made a new patch that sidesteps the all-classpath-urls issue by just using io/resource instead of iterating over all urls
Hide
David Nolen added a comment -

Can people chime in whether the patch works for them, thanks.

Show
David Nolen added a comment - Can people chime in whether the patch works for them, thanks.

People

Vote (0)
Watch (4)

Dates

  • Created:
    Updated: