When :foreign-libs is used for consume commonjs (or amd) modules from clojurescript using the `deps.cljs` mechanism, an unexpected "internal compiler error" is raised. When the same configuration is attached on the build script, everything works as expected.
Simple way to reproduce that, create sample directory tree:
Download the latest compiler or copy the recently build one from master:
Create the sample cljs file:
Create the sample commonjs module:
Create the build script (that works):
And compile this using the following command:
This will generate successfully the final artifact that can be successufully executed with node:
But, if you remove the `:foreign-libs` from the build script and create a new `src/deps.cljs` file
with the following content:
And try compile it:
Comment made by: niwinz
Also happens with `cljs.jar` build from master.
[Compiler noob here]
Here is what is causing the issue:
In src/main/clojure/cljs/closure.clj in process-js-modules function, in the first case :foreign-libs is being set in opts and in the second failing case :ups-foreign-libs is being set in opts.
I am investigating the root of this.
A fix is to that set foreign-libs keyword in opts to a union of both foreign-libs and ups-foreign-libs.
I've verified that it works for both the above given examples. But I don't know enough about the compiler to propose this change.
Attaching patch with fixes this problem. The patch keeps the two sets of data (ups-foreign-libs, foreign-libs) separate.
I've run all the tests and they pass.