Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn users CLJS loading from resource files isn't supported #5

Closed
pld opened this issue Dec 19, 2016 · 2 comments
Closed

Warn users CLJS loading from resource files isn't supported #5

pld opened this issue Dec 19, 2016 · 2 comments

Comments

@pld
Copy link

pld commented Dec 19, 2016

It isn't obvious from the README that CLJS loading from resource files isn't supported, https://github.com/ptaoussanis/tempura/blob/master/src/taoensso/tempura/impl.cljc#L347

We got around this in tower, and now in tempura, by loading the resources into a dict at compile-time for the CLJS,

(ns i18n
  #?(:cljs
     (:require-macros [i18n :refer [compile-dictionary]]))
  (:require [taoensso.tempura.impl :as impl]))

(def dictionary {:en {:__load-resource "translations/en.clj"}})

#?(:clj
   (defmacro compile-dictionary
     "Macro for a compile-time dictionary from resources files to use in CLJS."
     []
     (impl/compile-dictionary false dictionary)))

(def opts
  "Reload files from disk in CLJ, load precompiled files in CLJS."
  {:dict #?(:clj dictionary
            :cljs (compile-dictionary))})

using something similar to the snippet above.

It'd be great to have external resources work in CLJS without the above. @ptaoussanis is there a principled reason this wasn't included? Would you be interested in a PR for this? I don't have the time right now, but I'd like to see this in a release and would try to make time for it when I could.

@ptaoussanis
Copy link
Member

Hi Peter, appreciate you pinging about this. Would be happy to see a PR if you have a specific approach in mind that you think would work well - thanks! :-)

Cheers

@ptaoussanis
Copy link
Member

Will offer some guidance on this, and an alternative on the next Tempura release - cheers! :-)

ptaoussanis added a commit that referenced this issue Feb 13, 2017
Big thing here is to try make the confusing compile-time/runtime
distinction a little clearer to folks.
ptaoussanis added a commit that referenced this issue Feb 16, 2017
Big thing here is to try make the confusing compile-time/runtime
distinction a little clearer to folks.
ptaoussanis added a commit that referenced this issue Feb 16, 2017
Big thing here is to try make the confusing compile-time/runtime
distinction a little clearer to folks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants