Welcome! Please see the About page for a little more info on how this works.

0 votes
in ClojureScript by

Currently we don't validate :global-exports. It must map known provides to some symbol that represents a JavaScript global var.

3 Answers

0 votes
by
_Comment made by: mfikes_

Note, the attached patch makes one change that falls a little out of the scope of the ticket: In the case that {{:provides}} is implicit (because {{:file}} represents a directory), and {{:global-exports}} is specified, the previous code would copy the entire global exports map into each of the generated foreign lib specs. This was revised to copy only the sub-map relevant to the associated file. While this seems like the correct thing to do when generating the expansion, it is also necessary with the new validation logic: Without this change any non-relevant global exports that happen to be copied would cause the validation logic to conclude that there is a missing provide.

For example


{:file "libs"
 :global-exports {foo foo-g bar bar-g}}


would be expanded into several lib specs, one for each file found in "libs", with the previous implementation copying the entire map into each. The revised code only copies the submap


:global-exports {foo foo-g}


into the spec related to {{:file "libs/foo.js"}}.

Example validation messages:

Explicit case:


java.lang.Exception: Foreign lib global exports not provided: ["missing-lib" "another-lib"] not found in :provides in {:file "libs/mylib.js", :provides ["my-lib"], :global-exports {my-lib mylib, missing-lib missing, another-lib another}}
...


Explicit case, with namespaces:


java.lang.Exception: Foreign lib global exports not provided: ["missing-lib" "another-ns/another-lib"] not found in :provides in {:file "libs/mylib.js", :provides ["some-ns/my-lib"], :global-exports {some-ns/my-lib mylib, missing-lib missing, another-ns/another-lib another}}
...


Implicit (directory) case where only libs/other.js is present


java.lang.Exception: Foreign lib global exports not implicitly provided. Files ["libs/missing.js" "libs/another.js"] not found for library spec {:file "libs", :global-exports {other other-g, missing missing-g, another another-g}}
...


0 votes
by

Comment made by: mfikes

CLJS-2781.patch added to Patch Tender (i)

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJS-2781 (reported by dnolen)
...