我一直追踪一个问题,在某些开发者的机器上编译 CLJS 项目时会看到栈溢出错误,而在其他机器上则不会有。
我认为这主要是因为在执行依赖项的拓扑排序时,cljs.js-deps/dependency-order
添加了一个额外的 require。
(require '[cljs.js-deps :as deps])
=> nil
(deps/dependency-order
'({:file "libs.js", :provides ["react" "cljsjs.react"], :requires [] :foreign true}
{:file "libs.js", :provides ["react" "react-dom" "webpack.bundle"] :foreign true}
{:file "libs.js" :provides ["react-dom" "cljsjs.react.dom"], :requires ["react"] :foreign true}))
=>
({:file "libs.js", :provides ["react" "cljsjs.react"], :requires [], :foreign true}
{:file "libs.js", :provides ["react" "react-dom" "webpack.bundle"], :foreign true, :requires ["react"]}
{:file "libs.js", :provides ["react-dom" "cljsjs.react.dom"], :requires ["react"], :foreign true})
注意输出中的第二个映射中多出的 :requires ["react"]
,它没有出现在输入中。
如果输入顺序被交换,则不会添加额外的 require
(deps/dependency-order
'({:file "libs.js", :provides ["react" "react-dom" "webpack.bundle"] :foreign true}
{:file "libs.js", :provides ["react" "cljsjs.react"], :requires [] :foreign true}
{:file "libs.js" :provides ["react-dom" "cljsjs.react.dom"], :requires ["react"] :foreign true}))
=>
({:file "libs.js", :provides ["react" "react-dom" "webpack.bundle"], :foreign true, :requires []}
{:file "libs.js", :provides ["react" "cljsjs.react"], :requires [], :foreign true}
{:file "libs.js", :provides ["react-dom" "cljsjs.react.dom"], :requires ["react"], :foreign true})
这是一个有效的问题吗?