Fork me on GitHub
#shadow-cljs
<
2022-07-08
>
Christopher Genovese01:07:37

Sudden "Critical Dependency" warning. I've been running a React app to test and develop a CLJS library built with shadow-cljs for months now with out any real issues. Throughout that time when I would compile with npx shadow-cljs compile react it would take 8-10 seconds. (Relevant shadow-cljs.edn part below). Suddenly, after a seemingly insignificant change, the compile time dropped to consistently under a second, I started seeing the following warning when running the React app in dev mode:

WARNING in ../Zephyr/zephyr/dist/cljs-runtime/cljs_env.js 1822:9-49
Critical dependency: the request of a dependency is an expression
 @ ../Zephyr/zephyr/dist/cljs-runtime/shadow.module.zephyr.prepend.js 3:0-23
 @ ../Zephyr/zephyr/dist/zephyr.js 3:0-59
 @ ./src/components/ZephyrStaticInline.js 7:0-40 33:29-40
 @ ./src/App.js 7:0-71 69:133-154
 @ ./src/index.js 11:0-24 18:35-38
There's nothing remarkable in the code at those points that I could see, and I did not change any dependencies or even any requires. Has anyone seen this warning before or such an order of magnitude drop in compile times? (I'm not sure how the file size changed.) I'd appreciate any pointers you have. The relevant part of the shadow-cljs.edn file is
:react {:target :esm
          :output-dir "dist"
          :modules {:zephyr
                    {:exports {:math        zephyr.core/math
                               :equation    zephyr.core/equation
                               :inline      zephyr.core/inline
                               :align       zephyr.core/align
                               :staticLaTeX zephyr.core/staticLaTeX}}}
          :js-options {:js-provider :import}
          :compiler-options {:infer-externs :auto
                             :output-feature-set :es2018
                             :optimizations :advanced}}
Again this has worked flawlessly for quite a while. Thanks for your help!

Christopher Genovese02:07:01

P.S. As a follow up, I checked out old branches going back well before the warning first appeared. The compile times and warning remain, which is rather surprising. An external/implicit/automatic change in dependencies? Not sure how to explain this. Thanks.

rolt14:07:56

if you have version ranges for some packages that might explain it

thheller04:07:59

@genovese I don't know what that error means either. it is not from shadow-cljs or any code it generates. it seems to be from whatever you are using to post process the output. google suggests this https://stackoverflow.com/questions/42908116/webpack-critical-dependency-the-request-of-a-dependency-is-an-expression

thheller04:07:08

and many others but the cause consistently seems to come from one of the included npm dependencies

Christopher Genovese12:07:16

Thanks @thheller. Webpack is definitely generating the warning, but the npm deps on the react side did not change. Since the message pointed to the cljs runtime and the shadow-cljs compile time changed so noticeably pre and post warning, I thought it might be something in the shadow-cljs generated code. I'm glad to hear that that's not the case, though. A bit of a mystery still, but... Appreciate your help.

thheller12:07:52

did you check what is at ../Zephyr/zephyr/dist/cljs-runtime/shadow.module.zephyr.prepend.js 3:0-23 that location in the file?

Christopher Genovese20:07:17

So sorry I missed this. Yes I had, and it's just an import

import "./cljs_env.js";