簡體   English   中英

在:prod配置文件下使用NPM模塊編譯cljs prj時,“ a未定義”

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

我遵循了此方法: http//blob.tomerweller.com/reagent-import-react-components-from-npm ,它的效果很好。 在這個重新設計的示例應用程序的頂部,我什至設法使用了我自己的NPM模塊之一: https : //github.com/Day8/re-frame/tree/master/examples/simple/

使用以下命令啟動生成的應用程序:

lein clean && lein figwheel

一切正常,但是當我這樣做時:

lein do clean, with-profile prod compile

我收到TypeError: a is undefined 有解決這個問題的主意嗎?

讓我為您提供代碼:錯誤的提交在這里 ,而:dev:prod配置文件在上一次提交時都可以正常工作。

更新 :我設法修復了這樣的編譯版本(請參閱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編譯器文檔

謝謝。

失敗的代碼在這里

看來您可能需要為clubexpr提供extern,以便Closure編譯器知道不將renderLispAsLatex重寫為kf 在:simple下進行編譯時,Closure Compiler不會重寫函數名稱,因此不會出現此問題。

附帶說明一下,您可能不應該使用aget從窗口獲取對象, aget僅設計用於數組訪問。 要獲取對象,您應該使用goog.object/get 有關更多信息,請參見Checked Array Access上的這篇文章。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM