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

tick on shadow-cljs #21

Closed
eerohele opened this issue Oct 31, 2018 · 8 comments
Closed

tick on shadow-cljs #21

eerohele opened this issue Oct 31, 2018 · 8 comments
Assignees

Comments

@eerohele
Copy link

Evaluating (require '[tick.alpha.api: as tick]) in a ClojureScript environment fails with this error:

The required namespace "cljsjs.js-joda" is not available, it was required by "java/time.cljs".

I tried adding an explicit dependency to cljsjs/js-joda {:mvn/version "1.9.2-0"} in my deps.edn, but that didn't have any effect.

@henryw374
Copy link
Collaborator

Hi, that's strange. Which tick version are you on? And can you try the latest (released today) 0.4.6-alpha from clojars https://clojars.org/tick. Let me know if that fixes

Thanks!

@eerohele
Copy link
Author

eerohele commented Nov 1, 2018

I honestly have absolutely no idea why, but I gave it another try today and everything works fine even with 0.4.5-alpha.

It must've been some weird issue related to my project. This minimal repro also works fine:

$ clj -Srepro -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "RELEASE"} tick {:mvn/version "0.4.5-alpha"}}}' -m cljs.main
ClojureScript 1.10.339
cljs.user=> (require '[tick.alpha.api :as tick])

cljs.user=> (tick/now)
#jsr310/instant "2018-11-01T10:41:28.034Z"

I'll close this issue. If it resurfaces, I'll try to look into it and post any findings here.

@eerohele eerohele closed this as completed Nov 1, 2018
@eerohele
Copy link
Author

eerohele commented Nov 6, 2018

I bumped into this again. I don't know why, but it appears that the issue only occurs with shadow-cljs.

tick-issue-21.zip contains a minimal repro. To run it, extract the ZIP file, cd into the directory, and run:

$ npx shadow-cljs watch app

I'm not sure whether this is an issue with shadow-cljs or this library (or one of its dependencies).

@eerohele
Copy link
Author

eerohele commented Nov 6, 2018

Ah. According to thheller/shadow-cljs#162, shadow-cljs doesn't support cljsjs dependencies.

I suppose one possible way to fix the issue would be to migrate https://github.com/henryw374/cljs.java-time to shadow-cljs and use the js-joda NPM dependency instead of the cljsjs package, but I'm not sure whether that's feasible.

@henryw374 henryw374 reopened this Nov 6, 2018
@henryw374
Copy link
Collaborator

ok thanks. I've got that compiling, see https://github.com/henryw374/tick-on-shadow-cljs-demo

wip of course. any comments welcome

@henryw374
Copy link
Collaborator

I've been reading about npm-deps... sounds like it shouldn't be too hard to use that instead of cljsjs

@henryw374 henryw374 self-assigned this Nov 6, 2018
@eerohele
Copy link
Author

eerohele commented Nov 7, 2018

Yeah, I ended up using the same solution as in your demo: I included src/cljsjs/js_joda.cljs like the one you have in your demo in my own project. It's a valid workaround, but perhaps using an NPM dependency — if feasible — would be a better long-term solution.

@henryw374 henryw374 changed the title cljsjs.js-joda namespace not available tick on shadow-cljs Nov 13, 2018
@henryw374
Copy link
Collaborator

I've looked into npm-deps and had a branch working fine using it, but I think for now I'm not too happy requiring library users to have to have npm installed and part of their build. If npm-deps becomes more standard then perhaps. documented that here: 49cc67f

I've updated the shadow demo project to use shadow-cljsjs and included the addon libs (timezone and locale) into the demo

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