Code Monkey home page Code Monkey logo

Comments (6)

kumarshantanu avatar kumarshantanu commented on September 26, 2024

This may involve classpath scanning to find out the .cljs files from CLASSPATH. These pointers may be useful:

http://stackoverflow.com/questions/1456930/how-do-i-read-all-classes-from-a-java-package-in-the-classpath

http://code.google.com/p/reflections/

from lein-cljsbuild.

emezeske avatar emezeske commented on September 26, 2024

What is the use case for this? Typically I would expect that if a CLJS file was not in the :source-path tree, it would be referred to by something that is, via a ns form, which as far as I know works just fine.

This would be a not-insignificant amount of work to implement, as cljs.closure/build expects a directory name. An alternate build function would have to be created to support compiling an arbitrary set of files instead of just the files in a directory. Another difficulty is that the CLJS files in JARs would have to be specified one-by-one, because there is no way to list a directory in a JAR file.

from lein-cljsbuild.

kumarshantanu avatar kumarshantanu commented on September 26, 2024

What do you mean by "..it would be referred to by something that is, via a ns form, which as far as I know works just fine." I am not sure I understood what you meant by that.

A use-case would be distributing CLJS library in source form via Maven infrastructure (e.g. Clojars) so that others can extend the code.

I understand the work would be non-trivial. I realized reusable CLJS code must be distributed in source form, which could be JAR or ZIP. When we distribute CLJS code in source form via JAR/ZIP files via Maven infrastructure, it's very important to support loading them from CLASSPATH as source files.

I also realized it's possible to scan the CLASSPATH when the top-level package or directory name is supplied. Should we support this, we may need to provide for a key in project.clj under :cljsbuild ==> :builds ==> :source-namespaces that points to a vector of top-level namespaces that should be scanned for .cljs files. All of those .cljs files and those from :source-path should be copied to a common directory before they can be compiled, because the CLJS compiler picks up source files from a filesystem directory.

from lein-cljsbuild.

emezeske avatar emezeske commented on September 26, 2024

It is already possible to distribute CLJS code inside a JAR, and to refer to that code from a dependent project. As long as the CLJS source files are included in the JAR, and that JAR is on the classpath, you can :require or :use them. For instance, the jayq [1] library has some CLJS files in its src/ dir, which is included in the JAR file. In my project, I added a dependency on [jayq "0.1.0-SNAPSHOT"]. Then, in one of my CLJS files in my :source-path, I have (ns (:require [jayq.core :as jayq])) and I can access the namespace just fine.

It seems to me that this is sufficient for sharing CLJS code between projects. Am I missing something?

[1] https://github.com/ibdknox/jayq

from lein-cljsbuild.

swannodette avatar swannodette commented on September 26, 2024

I can also confirm that this already works and works well :)

from lein-cljsbuild.

emezeske avatar emezeske commented on September 26, 2024

I'm closing this because I think it is not needed. Feel free to reopen it with a detailed description if I am wrong.

from lein-cljsbuild.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.