:foreign-libs with module conversion does not works properly if it is used form deps.cljs

Description

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:

Environment

Linux, openjdk8

Activity

Show:
import
June 13, 2016, 11:42 AM

Comment made by: niwinz

Also happens with `cljs.jar` build from master.

Rohit Aggarwal
June 14, 2016, 11:40 AM

[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.

Rohit Aggarwal
June 14, 2016, 12:11 PM

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.

Rohit Aggarwal
June 14, 2016, 4:57 PM

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.

David Nolen
September 23, 2016, 8:31 PM

Assignee

Unassigned

Reporter

import

Approval

None

Patch

Code

Affects versions

Priority

Minor
Configure