简体   繁体   English

在:prod配置文件下使用NPM模块编译cljs prj时,“ a未定义”

[英]'a is undefined' when compiling a cljs prj with an NPM module under :prod profile

I followed this howto: http://blob.tomerweller.com/reagent-import-react-components-from-npm and it worked great. 我遵循了此方法: http//blob.tomerweller.com/reagent-import-react-components-from-npm ,它的效果很好。 I even managed to use one of my own NPM module on top of this example app of re-frame: https://github.com/Day8/re-frame/tree/master/examples/simple/ 在这个重新设计的示例应用程序的顶部,我什至设法使用了我自己的NPM模块之一: https : //github.com/Day8/re-frame/tree/master/examples/simple/

Starting the resulting app with: 使用以下命令启动生成的应用程序:

lein clean && lein figwheel

everything works ok, but when I do: 一切正常,但是当我这样做时:

lein do clean, with-profile prod compile

I get a TypeError: a is undefined . 我收到TypeError: a is undefined Any idea to fix this? 有解决这个问题的主意吗?

Let me provide you with the code: the bad commit is here , while both :dev and :prod profiles work OK at this just previous commit . 让我为您提供代码:错误的提交在这里 ,而:dev:prod配置文件在上一次提交时都可以正常工作。

Update : I managed to fix the compiled version like this (see the commit ): 更新 :我设法修复了这样的编译版本(请参阅commit ):

  return d.c?d.c(c,v,w):d.call(null,c,v,w)}}(G,r,b,c,d,e)),I=dw(G);rf.b?: […]
  };w.b=v;w.c=f;return w}()}(c,d,e,f))};hf.b(ow,ik);hf.b(ow,bp);hf.b(ow,To); […]
  function nx(a){var b=window.deps["react-mathjax"],
-    c=window.deps.clubexpr.kf;
+    c=window.deps.clubexpr.renderLispAsLaTeX;
  return new U(null,3,5,V,[Vj,b.Context,new U(null,4,null)}
  function Wv(){return function(a){return function(){return new U(null,6,5,V,[…]

This seems to me a compilation misconfiguration or bug. 在我看来,这似乎是编译错误或错误。

Update 2 : my code compiles OK if I set :optimizations to :simple (was :advanced ). 更新2 :如果将:optimizations设置为:simple (是:advanced ),我的代码将编译正常。 See the cljs compiler doc about this option . 有关此选项,请参见cljs编译器文档

Thanks. 谢谢。

The code that is failing is here . 失败的代码在这里

It looks like you might need to provide externs for clubexpr, so that the Closure Compiler knows not to rewrite renderLispAsLatex as kf . 看来您可能需要为clubexpr提供extern,以便Closure编译器知道不将renderLispAsLatex重写为kf When compiling under :simple, the Closure Compiler doesn't rewrite function names, so this problem wouldn't show up. 在:simple下进行编译时,Closure Compiler不会重写函数名称,因此不会出现此问题。

As a side note, you probably shouldn't use aget to get objects from the window, aget is designed for array access only. 附带说明一下,您可能不应该使用aget从窗口获取对象, aget仅设计用于数组访问。 To get objects, you should use goog.object/get . 要获取对象,您应该使用goog.object/get See this post on Checked Array Access for more info on this. 有关更多信息,请参见Checked Array Access上的这篇文章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我使用 -w "watch:sass" 时,SCSS npm 不编译 CSS - SCSS npm is not compiling CSS when I use -w "watch:sass" 在Windows下为R软件包编译Fortran代码:对REXIT,RWARN,RCHKUSR的未定义引用 - Compiling Fortran code for R package under Windows: Undefined reference to REXIT, RWARN, RCHKUSR 在Ubuntu上编译C时没有输入文件或未定义的引用 - No input files or undefined reference when compiling C on Ubuntu 编译FFI示例时libHSghc-prim有未定义的符号错误 - Undefined symbol errors with libHSghc-prim when compiling FFI sample 使用g ++编译单个文件时未定义引用 - Undefined refernece when compiling a single file with g++ 编译python模块扩展时如何静态链接库 - How to statically link a library when compiling a python module extension 启动Meteor应用程序时,如何解决Meteor软件包使用的npm软件包的编译错误? - How to fix compiling error of a npm package used by a Meteor package when starting a Meteor app? 在Ubuntu下编译LibCurl时出错:zlib.h:没有这样的文件或目录 - Error when compiling LibCurl under Ubuntu: zlib.h : no such file or directory Pascal模块编译错误 - Pascal module compiling error 编译时出现未定义的参考错误 - Undefined reference error while compiling
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM