[英]$jscomp not defined in code loaded for clojurescript and reagent
Using clojurescript 1.10.758 and reagent 1.0.0, I am running into an error in which a file index.js tries to reference $jscomp
, which is not defined.使用 clojurescript 1.10.758 和试剂 1.0.0,我遇到了一个错误,其中文件 index.js 尝试引用
$jscomp
,该文件未定义。
I've seen a number of Stackoverflow and Github issues related to $jscomp being undefined in the context of shadow-cljs, but I'm not using that.我已经看到许多与 $jscomp 相关的 Stackoverflow 和 Github 问题在 shadow-cljs 的上下文中未定义,但我没有使用它。
The problem occurs when I use a development mode build with figwheel (using Leiningen with cljsbuild and the figwheel plugin), and also occurs if I use cljsbuild for a once-only development build.当我使用带有 figwheel 的开发模式构建(使用带有 cljsbuild 和 figwheel 插件的 Leiningen)时会出现此问题,并且如果我将 cljsbuild 用于一次性开发构建也会出现此问题。 Strangely, if I use webpack to create a bundle, the problem does not occur.
奇怪的是,如果我使用 webpack 创建捆绑包,则不会出现问题。
Before I tried to make webpack work, I did have working code without webpack.在我尝试使 webpack 工作之前,我确实有没有 webpack 的工作代码。 Something I changed seems to have affected the non-bundled build.
我更改的某些内容似乎影响了非捆绑构建。 The only change I can thing of was to install react and react-dom using npm, and exclude those packages from reagent in Leiningen's dependencies.
我能做的唯一改变是使用 npm 安装 react 和 react-dom,并从 Leiningen 依赖项中的试剂中排除这些包。 But undoing the exclusion didn't make the non-bundled code work again.
但是撤消排除并没有使非捆绑代码再次工作。
Any suggestions for how to cause $jscomp
to be defined when it's first needed?关于如何在第一次需要时定义
$jscomp
的任何建议?
$jscomp
is related to the Closure Compiler and the Polyfills it creates. $jscomp
与 Closure Compiler 及其创建的 Polyfill 相关。
It might be enough to tweak the :language-out:es6
compiler options which is somewhat similar to the :output-feature-set
option used by shadow-cljs
.调整
:language-out:es6
编译器选项可能就足够了,这有点类似于shadow-cljs
使用的:output-feature-set
选项。 The best way to debug this is finding the actual code that is getting polyfilled and why.调试此问题的最佳方法是找到正在填充的实际代码及其原因。 Might require digging through some compiled JS though.
不过可能需要挖掘一些已编译的 JS。
shadow-cljs
uses the Closure Compiler more extensively than regular CLJS or figwheel but they also use it. shadow-cljs
比常规 CLJS 或 figwheel 更广泛地使用闭包编译器,但他们也使用它。 Solutions that apply to shadow-cljs
pretty much apply to other tools as well.适用于
shadow-cljs
的解决方案也几乎适用于其他工具。 Just the settings may work a little differently.只是设置可能会有所不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.