ClojureScript

circular dependency in node_modules prevents compilation

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 1.9.908
  • Fix Version/s: None
  • Component/s: None
  • Labels:

Description

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", ['lib1'], ['lib2']); // This line will fail since 'lib2' is not yet provided
goog.addDependency("../node_modules/lib2.js", ['lib2'], ['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.

Activity

Hide
Juho Teperi added a comment -

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
// 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");
code

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

Show
Juho Teperi added a comment - 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 // 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"); code It is possible this is caused by Cljs bug, because provide name is created by us, and require names are provided by Closure.

People

Vote (1)
Watch (0)

Dates

  • Created:
    Updated: