|
1160 | 1160 |
|
1161 | 1161 | #?(:clj |
1162 | 1162 | (defmacro ^:private elide-require |
1163 | | - "Experimental. The presence of `js/require` calls can cause issues with |
1164 | | - React Native, even if they never execute. Currently no other known |
1165 | | - workarounds. Ref. https://github.com/ptaoussanis/sente/issues/247." |
| 1163 | + "`js/require` calls can cause issues with React Native static analysis even |
| 1164 | + if they never execute, Ref. <https://github.com/ptaoussanis/sente/issues/247>." |
1166 | 1165 | [& body] |
1167 | 1166 | (when-not (enc/get-env {:as :bool} :sente-elide-js-require) |
1168 | 1167 | `(do ~@body)))) |
|
1174 | 1173 | 1. Add the lein-npm[2] plugin to your `project.clj`, |
1175 | 1174 | 2. Add: `:npm {:dependencies [[websocket \"1.0.23\"]]}` |
1176 | 1175 |
|
1177 | | - [1] Ref. https://www.npmjs.com/package/websocket |
1178 | | - [2] Ref. https://github.com/RyanMcG/lein-npm" |
| 1176 | + [1] Ref. <https://www.npmjs.com/package/websocket> |
| 1177 | + [2] Ref. <https://github.com/RyanMcG/lein-npm>" |
1179 | 1178 |
|
1180 | | - ;; This `let` silliness intended to work around React Native's |
1181 | | - ;; static analysis tool, to prevent it from detecting a |
1182 | | - ;; missing package. |
1183 | | - ;; |
1184 | | - ;; Ref. https://github.com/ptaoussanis/sente/issues/247#issuecomment-555219121 |
1185 | | - ;; |
1186 | 1179 | (let [make-package-name (fn [prefix] (str prefix "socket")) |
1187 | | - require-fn |
1188 | | - (if (exists? js/require) |
1189 | | - js/require |
1190 | | - (constantly :no-op))] |
| 1180 | + require-fn (if (exists? js/require) js/require (constantly :no-op))] |
1191 | 1181 |
|
1192 | | - (delay ; Eager eval causes issues with React Native, Ref. #247, |
1193 | | - (elide-require ; TODO is this now safe to remove? |
| 1182 | + (delay ; For React Native, Ref. #247 |
| 1183 | + (elide-require ; For React Native, Ref. #247 |
1194 | 1184 | (when (and node-target? (exists? js/require)) |
1195 | 1185 | (try |
1196 | 1186 | (require-fn (make-package-name "web")) |
|
0 commit comments