File tree Expand file tree Collapse file tree 3 files changed +32
-7
lines changed Expand file tree Collapse file tree 3 files changed +32
-7
lines changed Original file line number Diff line number Diff line change 1071
1071
1072
1072
(defmethod resolve* :node
1073
1073
[env sym full-ns current-ns]
1074
- {:name (symbol (str current-ns) (str (munge-node-lib full-ns) " ." (name sym)))
1074
+ {:ns current-ns
1075
+ :name (symbol (str current-ns) (str (munge-node-lib full-ns) " ." (name sym)))
1075
1076
:op :js-var
1076
- :ns current-ns
1077
- :tag 'js})
1077
+ :foreign true })
1078
1078
1079
1079
(defmethod resolve* :global
1080
1080
[env sym full-ns current-ns]
1081
1081
(let [pre (into '[Object] (->> (string/split (name sym) #"\. " ) (map symbol) vec))]
1082
1082
(when-not (has-extern? pre)
1083
1083
(swap! env/*compiler* update-in
1084
1084
(into [::namespaces current-ns :externs ] pre) merge {}))
1085
- {:name (symbol (str current-ns) (str (munge-global-export full-ns) " ." (name sym)))
1085
+ {:ns current-ns
1086
+ :name (symbol (str current-ns) (str (munge-global-export full-ns) " ." (name sym)))
1086
1087
:op :js-var
1087
- :ns current-ns
1088
- :tag ( with-meta 'js { :prefix pre}) }))
1088
+ :tag ( with-meta 'js { :prefix pre})
1089
+ :foreign true }))
1089
1090
1090
1091
(def ^:private private-var-access-exceptions
1091
1092
" Specially-treated symbols for which we don't trigger :private-var-access warnings."
Original file line number Diff line number Diff line change 1142
1142
opt-count? (and (= (:name info) 'cljs.core/count)
1143
1143
(boolean ('#{string array} first-arg-tag)))
1144
1144
ns (:ns info)
1145
- js? (or (= ns 'js) (= ns 'Math) (= tag 'js))
1145
+ js? (or (= ns 'js) (= ns 'Math) (:foreign info)) ; ; foreign - i.e. global / Node.js library
1146
1146
goog? (when ns
1147
1147
(or (= ns 'goog)
1148
1148
(when-let [ns-str (str ns )]
Original file line number Diff line number Diff line change 286
286
(.delete (io/file " package.json" ))
287
287
(test/delete-node-modules ))
288
288
289
+ (deftest test-npm-deps-invoke-cljs-3144
290
+ (test/delete-node-modules )
291
+ (spit (io/file " package.json" ) " {}" )
292
+ (let [cenv (env/default-compiler-env )
293
+ out (.getPath (io/file " test-out" #_(test/tmp-dir ) " npm-deps-test-out" ))
294
+ {:keys [inputs opts]} {:inputs (str (io/file " src" " test" " cljs_build" ))
295
+ :opts {:main 'npm-deps-test.invoke
296
+ :output-dir out
297
+ :optimizations :none
298
+ :install-deps true
299
+ :npm-deps {:react " 15.6.1"
300
+ :react-dom " 15.6.1"
301
+ :lodash-es " 4.17.4"
302
+ :lodash " 4.17.4" }
303
+ :closure-warnings {:check-types :off
304
+ :non-standard-jsdoc :off }}}]
305
+ (test/delete-out-files out)
306
+ (testing " invoking fns from Node.js libraries should not emit .call convention"
307
+ (build/build (build/inputs (io/file inputs " npm_deps_test/invoke.cljs" )) opts cenv)
308
+ (is (.exists (io/file out " node_modules/react/react.js" )))
309
+ (is (not (string/includes? (slurp (io/file out " npm_deps_test/invoke.cljs" )) " call" )))))
310
+ (.delete (io/file " package.json" ))
311
+ (test/delete-node-modules ))
312
+
289
313
(deftest test-preloads
290
314
(let [out (.getPath (io/file (test/tmp-dir ) " preloads-test-out" ))
291
315
{:keys [inputs opts]} {:inputs (str (io/file " src" " test" " cljs" ))
You can’t perform that action at this time.
0 commit comments