如何/我可以从ClojureScript编译器输出中排除继承的外部库?

时间:2015-05-19 06:33:04

标签: leiningen clojurescript reagent cljsbuild

我使用reagent 0.5.0取决于cljsjs/react。后者带有以下deps.cljs

{:foreign-libs [{
 :file "cljsjs/development/react.inc.js",
 :file-min "cljsjs/production/react.min.inc.js",
 :provides ["cljsjs.react"]}],
 :externs ["cljsjs/common/react.ext.js"]}

使得React的JavaScript最终出现在编译器输出中。

我想阻止这种情况发生,因为我也想在纯JavaScript页面中使用React。

此外,reagent/core.cljs有一个:require [cljsjs.react]指令(强制包含?)所以不能简单地省略依赖。

有没有办法防止React在编译器输出中结束?

1 个答案:

答案 0 :(得分:1)

来自试剂自述文件(https://github.com/reagent-project/reagent):

If you want the version of React with addons, you'd use something like this instead:

[reagent "0.5.0" :exclusions [cljsjs/react]]
[cljsjs/react-with-addons "0.12.2-4"]

If you want to use your own build of React (or React from a CDN), you have to use :exclusions variant of the dependency, and also provide a file named "cljsjs/react.cljs", containing just (ns cljsjs.react), in your project.

因此,只需在依赖项中使用:exclusions选项,并提供自己的cljsjs / react命名空间,这样你就可以了。在那时,由您决定确保在Reagent之前加载React。

相关问题