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

0 votes
in ClojureScript by

Compiler complains of missing provides when there is circular dependency in node_modules.

Cause is the order of the 'goog.addDependency' statements in out/cljs_deps.js

goog.addDependency("../node_modules/lib1.js", (link: 'lib1'), (link: 'lib2')); // This line will fail since 'lib2' is not yet provided
goog.addDependency("../node_modules/lib2.js", (link: 'lib2'), (link: 'lib1'));

Example of affected node_modules: apollo-client 1.9.2

I'm not sure if this is a closure compiler limitation or explicitly unsupported, but it does reduce the number of node packages that can be included using node_modules.

Current workaround is to rewrite the library code to not have circular deps or to switch to cljsjs.

2 Answers

0 votes
by

Comment made by: deraen

I didn't notice circular dependencies when testing Apollo-client 1.9.2 with latest Cljs changes, but there is something else strange going on.

`}
// Code from apollo-client references some modules by incorrect name:
goog.provide("module$home$juho$Source$reagent$test_environments$browser_node$node_modules$apollo_client$transport$networkInterface");
goog.require("module$whatwg_fetch");
goog.require("module$graphql$language$printer");

// From whatwg file:
goog.provide("module$home$juho$Source$reagent$test_environments$browser_node$node_modules$whatwg_fetch$fetch");
`
}

It is possible this is caused by Cljs bug, because provide name is created by us, and require names are provided by Closure.

0 votes
by
...