diff --git a/README.md b/README.md index 2c7a558..9eec108 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,11 @@ The default configuration for Tern is the browser environment `(:lt.plugins.tern (:lt.plugins.tern/plugin :node true)]} :- {:tern.config [:lt.plugins.tern/libs]}} +To setup a configuration for RequireJS: + + {:+ {:tern.config [(:lt.plugins.tern/plugin :requirejs {:baseURL "/home/path/to/project/dir"}) + :lt.plugins.tern/lazy-loading]}} + Arguments to `:lt.plugins.tern/libs` can be: 1. One or many built in libs: `:ecma5 :browser :jquery :underscore` diff --git a/src/lt/plugins/tern.cljs b/src/lt/plugins/tern.cljs index 29280c7..335bdb5 100644 --- a/src/lt/plugins/tern.cljs +++ b/src/lt/plugins/tern.cljs @@ -325,7 +325,9 @@ (.on worker "message" msg) (.on worker "disconnect" dis) (.on worker "exit" dis) - (current-ws-jsfiles init-cb) + (if (object/raise-reduce config :lazy-loading+ false) + (init-cb nil []) + (current-ws-jsfiles init-cb)) (object/merge! this {::worker worker}))))) (behavior ::error @@ -432,6 +434,11 @@ (object/update! this [:options :plugins] conj value))))) +(behavior ::lazy-loading + :triggers #{:lazy-loading+} + :reaction (fn [this _ _] + true)) + (object/object* ::tern.config :tags #{:tern.config} :options {:libs #{}