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

0 votes
in ClojureScript by
The {{slate}} npm dep depends on {{is-plain-object}} but it can't be loaded. Start up a REPL with:


clojure -m cljs.main -co '{:npm-deps {"react" "15.5.4" "react-dom" "15.5.4" "slate" "0.33.6" "immutable" "3.8.2"} :install-deps true :repl-verbose true}' -d out -r


(Note, that in the above we are going with the default browser REPL; the problem doesn't occur if you specify {{-re node}}.)

Then, after the REPL is up and running:


cljs.user=> (require 'slate)
load-namespace module$private$tmp$test-me$node-modules$slate$lib$slate-es , compiled: ((module$private$tmp$test-me$node-modules$slate$lib$slate-es))
goog.addDependency("../node_modules/slate/lib/slate.es.js", ['module$private$tmp$test_me$node_modules$slate$lib$slate_es'], ['module$is_plain_object', 'module$immutable', 'module$slate_dev_logger', 'module$direction', 'module$esrever', 'module$debug', 'module$lodash$isEqual', 'module$lodash$mergeWith', 'module$slate_schema_violations', 'module$lodash$pick', 'module$lodash$omit', 'module$is_empty']);

goog.require('module$private$tmp$test_me$node_modules$slate$lib$slate_es');
null;

"Error evaluating:" (require (quote slate)) :as "goog.require('module$private$tmp$test_me$node_modules$slate$lib$slate_es');\nnull;\n"
Error: Undefined nameToPath for module$is_plain_object
     (out/goog/base.js:1357:26)
     (out/goog/base.js:1369:14)
     (out/goog/base.js:706:27)
     require (out/clojure/browser/repl.cljs:340:25)


Note that it can't load {{module$is_plain_object}}, which is specified via


goog.require("module$is_plain_object");


inside of {{out/node_modules/slate/lib/slate.es.js}}.

But, you can load that namespace directly:


cljs.user=> (require 'is-plain-object)
load-namespace module$private$tmp$test-me$node-modules$is-plain-object$index , compiled: ([module$private$tmp$test-me$node-modules$isobject$index] (module$private$tmp$test-me$node-modules$is-plain-object$index))
goog.addDependency("../node_modules/isobject/index.js", ['module$private$tmp$test_me$node_modules$isobject$index'], []);
goog.addDependency("../node_modules/is-plain-object/index.js", ['module$private$tmp$test_me$node_modules$is_plain_object$index'], ['module$private$tmp$test_me$node_modules$isobject$index']);

goog.require('module$private$tmp$test_me$node_modules$is_plain_object$index');
null;


This appears to be the result of Closure failing to find the correct paths to the modules and simply emitting {{module$<symbol>}} instead of {{module$<path>}} for the {{goog.require}}.

8 Answers

0 votes
by

Comment made by: kommen

Current master produces a different problem.

These errors are now logged:

Can't find variable: module

undefined is not an object (evaluating 'module$Users$kommen$work$clojurescript$node_modules$slate$node_modules$debug$src$debug["default"]')

TypeError: undefined is not a constructor (evaluating 'new module$Users$kommen$work$clojurescript$node_modules$immutable$dist$immutable.Map')

Juho suggested the original issue actually might have been a duplicate of CLJS-2746.

0 votes
by

Comment made by: mfikes

Yes, CLJS-2746 is definitely in the area. Perhaps the issue described in this ticket is now resolved and we are onto completely different issues.

0 votes
by
_Comment made by: mfikes_

Using current master of Closure Compiler, building the unshaded JAR via {{mvn -DskipTests -pl externs/pom.xml,pom-main.xml,pom-main-unshaded.xml}} and depending on it using

{code:title=deps.edn}
{:deps {org.clojure/clojurescript {:mvn/version "1.10.339"}
        com.google.javascript/closure-compiler-unshaded {:mvn/version "1.0-SNAPSHOT"}}}


then you can {{(require 'slate)}} without errors being reported. (It is not clear to me whether Closure is loading all of the code correctly; after this it is not clear to me how you would use Slate and the exported object appears to be empty.)
0 votes
by
_Comment made by: jumblemuddle_

This may be an unrelated issue, but there seems to be a problem if the npm module uses `process.env.NODE_ENV`.

{code:|title=Starting REPL with snapshot `closure-compiler-unshaded`}
clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.339"} com.google.javascript/closure-compiler-unshaded {:mvn/version "1.0-SNAPSHOT"}}}' -m cljs.main -co '{:npm-deps {"emotion" "9.2.4"} :install-deps true :repl-verbose true}' -d out -r


ClojureScript 1.10.339
cljs.user=> (require '[emotion])
load-namespace module$home$garrett$tmp$node-modules$emotion$dist$index-es , compiled: ([module$home$garrett$tmp$node-modules$$emotion$unitless$dist$index-es module$$emotion$unitless module$$emotion$unitless$dist$index-es] [module$home$garrett$tmp$node-modules$$emotion$hash$dist$index-es module$$emotion$hash module$$emotion$hash$dist$index-es] [module$home$garrett$tmp$node-modules$$emotion$stylis$dist$index-es module$$emotion$stylis module$$emotion$stylis$dist$index-es] [module$home$garrett$tmp$node-modules$stylis-rule-sheet$index module$stylis-rule-sheet module$stylis-rule-sheet$index] [module$home$garrett$tmp$node-modules$create-emotion$dist$index-es module$create-emotion module$create-emotion$dist$index-es] [module$home$garrett$tmp$node-modules$$emotion$memoize$dist$index-es module$$emotion$memoize module$$emotion$memoize$dist$index-es] (module$home$garrett$tmp$node-modules$emotion$dist$index-es module$emotion module$emotion$dist$index-es))
goog.addDependency("../node_modules/@emotion/unitless/dist/index.es.js", ['module$home$garrett$tmp$node_modules$$emotion$unitless$dist$index_es', 'module$$emotion$unitless', 'module$$emotion$unitless$dist$index_es'], []);
goog.addDependency("../node_modules/@emotion/hash/dist/index.es.js", ['module$home$garrett$tmp$node_modules$$emotion$hash$dist$index_es', 'module$$emotion$hash', 'module$$emotion$hash$dist$index_es'], []);
goog.addDependency("../node_modules/@emotion/stylis/dist/index.es.js", ['module$home$garrett$tmp$node_modules$$emotion$stylis$dist$index_es', 'module$$emotion$stylis', 'module$$emotion$stylis$dist$index_es'], []);
goog.addDependency("../node_modules/stylis-rule-sheet/index.js", ['module$home$garrett$tmp$node_modules$stylis_rule_sheet$index', 'module$stylis_rule_sheet', 'module$stylis_rule_sheet$index'], []);
goog.addDependency("../node_modules/create-emotion/dist/index.es.js", ['module$home$garrett$tmp$node_modules$create_emotion$dist$index_es', 'module$create_emotion', 'module$create_emotion$dist$index_es'], ['module$$emotion$memoize', 'module$$emotion$unitless', 'module$$emotion$hash', 'module$$emotion$stylis', 'module$stylis_rule_sheet']);
goog.addDependency("../node_modules/@emotion/memoize/dist/index.es.js", ['module$home$garrett$tmp$node_modules$$emotion$memoize$dist$index_es', 'module$$emotion$memoize', 'module$$emotion$memoize$dist$index_es'], []);
goog.addDependency("../node_modules/emotion/dist/index.es.js", ['module$home$garrett$tmp$node_modules$emotion$dist$index_es', 'module$emotion', 'module$emotion$dist$index_es'], ['module$create_emotion']);

goog.require('module$home$garrett$tmp$node_modules$emotion$dist$index_es');
null;

{code:title=Browser Console Errors}
index.es.js:11 Uncaught ReferenceError: process is not defined
    at index.es.js:11
(anonymous) @ index.es.js:11
index.es.js:5 Uncaught TypeError: module$home$garrett$tmp$node_modules$create_emotion$dist$index_es.default is not a function
    at index.es.js:5
0 votes
by
_Comment made by: jumblemuddle_

In regards to `slate`, there are also browser console errors.
{code:title=REPL}
clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.339"} com.google.javascript/closure-compiler-unshaded {:mvn/version "1.0-SNAPSHOT"}}}' -m cljs.main -co '{:npm-deps {"react" "15.5.4" "react-dom" "15.5.4" "slate" "0.33.6" "immutable" "3.8.2"} :install-deps true}' -d out -r
ClojureScript 1.10.339
cljs.user=> (require '[slate])

cljs.user=> slate
#js {}
cljs.user=>


{code:|title=Browser Console Errors}
browser.js:15 Uncaught TypeError: (0 , module$home$garrett$tmp$node_modules$slate$node_modules$debug$src$browser.default.load) is not a function
    at browser.js:15
(anonymous) @ browser.js:15
isBuffer.js:6 Uncaught ReferenceError: module is not defined
    at isBuffer.js:6
(anonymous) @ isBuffer.js:6
_nodeUtil.js:5 Uncaught ReferenceError: module is not defined
    at _nodeUtil.js:5
(anonymous) @ _nodeUtil.js:5
_cloneBuffer.js:6 Uncaught ReferenceError: module is not defined
    at _cloneBuffer.js:6
(anonymous) @ _cloneBuffer.js:6
slate.es.js:37 Uncaught TypeError: module$home$garrett$tmp$node_modules$immutable$dist$immutable.Map is not a constructor
    at slate.es.js:37
0 votes
by

Comment made by: mfikes

Yeah, one issue (perhaps a different one, strictly speaking, given that this ticket as written will be solved when we ultimately move to a newer version of Closure), is that there seems to be some mixup between the {{debug}} module that is inside the {{slate}} module tree, and the top-level {{debug}} module.

0 votes
by

Comment made by: mfikes

It appears that the Map constructor issue is that the hosting object involves a default field:

`
cljs.user=> (let [Map (.-Map (.-default js/module$private$tmp$cljs_2757$node_modules$immutable$dist$immutable))] (Map.))

object[Map$$module$private$tmp$cljs_2757$node_modules$immutable$dist$immutable Map {}]

`

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