簡體   English   中英

如何/可以從ClojureScript編譯器輸出中排除繼承的外部庫?

[英]How/Can I exclude inherited foreign libs from ClojureScript compiler output?

我使用的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在編譯器輸出中結束?

從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.

因此,只需在依賴項中使用:exclusions選項,並提供自己的cljsjs / react名稱空間即可。 此時要確保由React加載,然后由Reagent加載。

暫無
暫無

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

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