在:prod配置文件下使用NPM模块编译cljs prj时,“ a未定义” [英] 'a is undefined' when compiling a cljs prj with an NPM module under :prod profile

查看:167
本文介绍了在:prod配置文件下使用NPM模块编译cljs prj时,“ a未定义”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循以下方法: http://blob.tomerweller。 com / reagent-import-react-components-from-npm ,效果很好。我什至设法在重新构建此示例应用程序的顶部使用自己的NPM模块之一: https://github.com/Day8/re-frame/tree/master/examples/simple/

I followed this howto: http://blob.tomerweller.com/reagent-import-react-components-from-npm and it worked great. 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/

生成的应用程序具有以下内容:

Starting the resulting app with:

lein clean && lein figwheel

一切正常,但是当我这样做时:

everything works ok, but when I do:

lein do clean, with-profile prod compile

我收到 TypeError:a未定义。想解决这个问题吗?

I get a TypeError: a is undefined. Any idea to fix this?

让我为您提供代码:错误的提交是此处
,而同时:dev :prod 配置文件可以正常运行在之前的提交中

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.

更新:我设法修复了编译后的版本(请参见提交):

Update: I managed to fix the compiled version like this (see the 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,[…]

我是编译错误或错误。

更新2 :如果我设置了:optimizations :simple (以前是:advanced )。请参见有关此选项的cljs编译器文档

Update 2: my code compiles OK if I set :optimizations to :simple (was :advanced). See the cljs compiler doc about this option.

谢谢。

推荐答案

失败的代码是此处

您似乎需要提供 externs for c lubexpr,以便Closure编译器知道不将 renderLispAsLatex 重写为 kf 。在:simple下进行编译时,Closure Compiler不会重写函数名称,因此不会出现此问题。

It looks like you might need to provide externs for clubexpr, so that the Closure Compiler knows not to rewrite renderLispAsLatex as kf. When compiling under :simple, the Closure Compiler doesn't rewrite function names, so this problem wouldn't show up.

作为补充,您可能不应该这样做使用 aget 从窗口获取对象, aget 仅用于数组访问。要获取对象,您应该使用 goog.object / get 。请参阅已检查阵列访问上的这篇文章,以了解更多信息

As a side note, you probably shouldn't use aget to get objects from the window, aget is designed for array access only. To get objects, you should use goog.object/get. See this post on Checked Array Access for more info on this.

这篇关于在:prod配置文件下使用NPM模块编译cljs prj时,“ a未定义”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆