Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Document automatic libs/externs support for libraries #143

Closed
emezeske opened this Issue · 12 comments

6 participants

Evan Mezeske Frozenlock Kevin Lynagh Trevor Wennblom Wang Liao Chas Emerick
Evan Mezeske
Owner

We originally added this feature as an experiment, but I haven't heard any complaints about it so I think it's time to document its existence.

See Issue #95 for an explanation of the feature in question.

Frozenlock

I tried to used this feature.
The externs.js does get included in the jar.
However, projects using a library built this way don't seem to use the externs.js file and will happily munge away every names.

Did I miss a step?

Evan Mezeske
Owner

No, I don't think you missed a step -- that sounds weird. Could you post the output of jar tf <your-project.jar>, and maybe the project.clj files for the library and client projects? I am at a loss to explain the problem you're seeing, and I don't know specifically what I'm looking for, but maybe something will jump out at me.

When I have a chance, I will set up a little test bed and see if I can reproduce the problem myself.

Frozenlock

Sure thing.
I've already made the necessary test environment here:
https://github.com/Frozenlock/envision-cljs-test

The html files are in "resources/public/cljs"
The test.html works as expected, but not the test-with-min.html (the avanced compilation one).

Here is the result of jar tf envision-cljs-0.1.7.jar:

META-INF/MANIFEST.MF
META-INF/maven/org.clojars.frozenlock/envision-cljs/pom.xml
META-INF/maven/org.clojars.frozenlock/envision-cljs/pom.properties
META-INF/leiningen/org.clojars.frozenlock/envision-cljs/project.clj
project.clj
public/js/cljs.js
envision_cljs/core.cljs
externs/externs.js

The externs.js is indeed in there.

I hope I just forgot something really obvious... :-)

Kevin Lynagh

@frozenlock, it doesn't look like the externs are going into the library jar under /closure-js, which is where they need to be to get picked up automatically when client projects are compiled.

Frozenlock

Yup, worked perfectly once I renamed the directory /closure-js instead of /externs.
Thank you very much!

Is using the project-name in the path necessary to avoid any collision?
I see you specified /closure-js/<project name>/externs, but it works even with only /closure-js.

Kevin Lynagh

I'm not that familiar with the JAR spec, but in all of my projects I'm packaging externs.js files in /closure-js/ and haven't run into any problems.

Evan Mezeske
Owner

Thanks guys. I will count this as a +1 for me getting the docs written... :)

Trevor Wennblom

:+1: for docs

Wang Liao

Hi, I have a stupid question. Is the closure-js just the path name, or :source-paths in cljsbuild configuration?

Trevor Wennblom

@liaowang11

% grep "closure" project.clj
% ;: none
%
% grep "source-paths" project.clj
    :builds [{:source-paths ["src-cljs"]
%
% ls -d1 ./resources/closure-js/*
./resources/closure-js/externs
./resources/closure-js/libs
%
Chas Emerick
Collaborator

FYI, ClojureScript will be changing to automatically resolve "goog-style" JavaScript libraries (i.e. those that contain the necessary goog.provide and goog.require declarations) from the classpath: http://dev.clojure.org/jira/browse/CLJS-656.

It seems like this should subsume the libs portion of this change. I'd love to hear from any users of cljsbuild's closure-js/libs and closure-js/externs conventions about CLJS-656, and how relevant externs are to you from a library perspective, etc.

Chas Emerick
Collaborator

No replies in more than a year. Closing.

Chas Emerick cemerick closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.