This is the same issue as https://dev.clojure.org/jira/browse/CLJS-1682, so all the instructions for reproduce the error can be found in the referenced issue.
Here some specific details of the different errors on different cljs versions:
With cljs==1.9.845
the compilation terminates successfully in both cases (:foreign-libs
in build.clj
and in deps.cljs
) but on executing the generated javascript, an exception is raised:
`
$ node out/main.js
out/src/vendor/greeter.js:3
exports.sayHello = function(name) {
^
TypeError: Cannot set property 'sayHello' of undefined
at out/src/vendor/greeter.js:3:18
at ContextifyScript.Script.runInThisContext (vm.js:50:33)
at Object.runInThisContext (vm.js:139:38)
at Object.nodeGlobalRequire (/home/niwi/tmp/greeter/out/goog/bootstrap/nodejs.js:85:8)
at Object.cljs$core$load_file [as load_file] (/home/niwi/tmp/greeter/out/cljs/core.js:341:13)
at Object.<anonymous> (/home/niwi/tmp/greeter/out/testapp/core.js:5:11)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
`
With cljs==1.9.908
the compilation terminates successfully in both cases but on executing the generated javascript and other exception is raised:
`
$ node out/main.js
/home/niwi/tmp/greeter/out/testapp/core.js:28
return cljs.core.println.call(null,module$src$vendor$greeter.sayHello("Ciri"));
^
TypeError: module$src$vendor$greeter.sayHello is not a function
at Function.testapp.core._main.cljs$core$IFn$_invoke$arity$variadic (/home/niwi/tmp/greeter/out/testapp/core.js:28:62)
at testapp$core$_main (/home/niwi/tmp/greeter/out/testapp/core.js:24:27)
at Object.cljs$core$apply_to [as apply_to] (/home/niwi/tmp/greeter/out/cljs/core.js:12793:81)
at Function.cljs.core.apply.cljs$core$IFn$_invoke$arity$2 (/home/niwi/tmp/greeter/out/cljs/core.js:13237:18)
at cljs$core$apply (/home/niwi/tmp/greeter/out/cljs/core.js:13195:24)
at Object.<anonymous> (/home/niwi/tmp/greeter/out/DF0FC10.js:9:17)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
`
And with cljs==1.9.946
, using the :foreign-libs
in the build.clj
file, the following error is raised:
`
$ java -cp cljs.jar:src clojure.main build.clj
module.js:529
throw err;
^
Error: Cannot find module '@cljs-oss/module-deps'
at Function.Module._resolveFilename (module.js:527:15)
at Function.Module._load (module.js:476:23)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at [eval]:3:13
at ContextifyScript.Script.runInThisContext (vm.js:50:33)
at Object.runInThisContext (vm.js:139:38)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (module.js:624:30)
at evalScript (bootstrap_node.js:462:27)
Copying file:/home/niwi/tmp/greeter/src/vendor/greeter.js to out/src/vendor/greeter.js
Copying jar:file:/home/niwi/tmp/greeter/cljs.jar!/cljs/core.cljs to out/cljs/core.cljs
Reading analysis cache for jar:file:/home/niwi/tmp/greeter/cljs.jar!/cljs/core.cljs
Compiling out/cljs/core.cljs
[...]
`
Independently of the error, the compilation continues and terminates, and the generated javascript raises the following error (very similat to the error with cljs==1.9.908):
`
$ node out/main.js
/home/niwi/tmp/greeter/out/testapp/core.js:28
return cljs.core.println.call(null,module$home$niwi$tmp$greeter$src$vendor$greeter.sayHello("Ciri"));
^
TypeError: module$home$niwi$tmp$greeter$src$vendor$greeter.sayHello is not a function
at Function.testapp.core._main.cljs$core$IFn$_invoke$arity$variadic (/home/niwi/tmp/greeter/out/testapp/core.js:28:84)
at testapp$core$_main (/home/niwi/tmp/greeter/out/testapp/core.js:24:27)
at Object.cljs$core$apply_to [as apply_to] (/home/niwi/tmp/greeter/out/cljs/core.js:12785:81)
at Function.cljs.core.apply.cljs$core$IFn$_invoke$arity$2 (/home/niwi/tmp/greeter/out/cljs/core.js:13229:18)
at cljs$core$apply (/home/niwi/tmp/greeter/out/cljs/core.js:13187:24)
at Object.<anonymous> (/home/niwi/tmp/greeter/out/AEF573C.js:10:17)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
`
In case of setting the :foreign-lib
in the deps.cljs
file, the compilation terminates without error but the generated javascript raises the same error as with cljs==1.9.845
.