[英]How/Can I exclude inherited foreign libs from ClojureScript compiler output?
I am using reagent 0.5.0
which depends on cljsjs/react
. 我使用的
reagent 0.5.0
取决于cljsjs/react
。 The latter comes with the following deps.cljs
后者随附以下
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"]}
which makes the React's JavaScript end up in the compiler output. 这使得React的JavaScript最终出现在编译器输出中。
I would like to prevent this from happening, because I also want to use React in plain JavaScript pages. 我想防止这种情况的发生,因为我也想在普通的JavaScript页面中使用React。
Besides, reagent/core.cljs
has a :require [cljsjs.react]
directive (To force the inclusion?) so the dependency cannot simply be omitted. 此外,
reagent/core.cljs
具有:require [cljsjs.react]
指令(要强制包含吗?),因此不能简单地忽略依赖项。
Is there a way to prevent React from ending up in the compiler output? 有没有办法阻止React在编译器输出中结束?
From the Reagent Readme ( https://github.com/reagent-project/reagent ): 从Reagent自述文件( 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.
So, just use the :exclusions option in your dependencies, and provide your own cljsjs/react namespace and your good to go. 因此,只需在依赖项中使用:exclusions选项,并提供自己的cljsjs / react名称空间即可。 It's up to you at that point to ensure React is loaded before Reagent however.
此时要确保由React加载,然后由Reagent加载。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.