This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-08
Channels
- # aleph (9)
- # announcements (42)
- # babashka (13)
- # babashka-sci-dev (9)
- # beginners (38)
- # biff (1)
- # calva (4)
- # cider (5)
- # clj-kondo (39)
- # cljdoc (4)
- # cljsrn (3)
- # clojure (93)
- # clojure-bay-area (1)
- # clojure-czech (1)
- # clojure-dev (4)
- # clojure-europe (65)
- # clojure-finland (3)
- # clojure-nl (2)
- # clojure-norway (7)
- # clojure-portugal (1)
- # clojure-uk (2)
- # clojurescript (73)
- # cloverage (1)
- # cursive (5)
- # data-science (1)
- # datahike (22)
- # emacs (51)
- # graalvm (6)
- # introduce-yourself (8)
- # jobs-discuss (14)
- # kaocha (6)
- # mount (5)
- # nbb (19)
- # off-topic (19)
- # reagent (5)
- # releases (1)
- # sci (19)
- # scittle (4)
- # shadow-cljs (6)
- # tools-deps (9)
- # xtdb (2)
How can I rewrite this import { datetime, RRule, RRuleSet, rrulestr } from 'rrule'
in nbb (https://github.com/jakubroztocil/rrule)? I am interested in the datetime
as I can't seem to get it work using e.g (require '["rrule$default" :as rrule :refer [datetime]])
I am a bit lost here. Without the default, e.g. (rrule.RRule.parseString "DTSTART:20120201T093000Z\nRRULE:FREQ=WEEKLY")
stops working with the error "TypeError: Cannot use 'in' operator to search for 'parseString' in undefined"
.
so first try this approach in a Node REPL, the structure should be similar in nbb. Use node 17.8.0 for await + import in the repl
When I try this in a foo.mjs
file, I get an error:
import { datetime, RRule, RRuleSet, rrulestr } from 'rrule'
$ node foo.mjs
file:///private/tmp/rrule/foo.mjs:1
import { datetime, RRule, RRuleSet, rrulestr } from 'rrule'
^^^^^
SyntaxError: Named export 'RRule' not found. The requested module 'rrule' is a CommonJS module, which may not support all module.exports as named exports.
@adam.kalisz This is a but f** up, but it works:
$ nbb -e "(require '[\"rrule$default\" :as rrule]) rrule.default.RRule"
#object[t]
here is an issue about datetime https://github.com/jakubroztocil/rrule/issues/551
Good tips. Thank you! I still don't understand much but some good pointers here! I will try my best to dig deeper.
Got this:
(require '["rrule$default" :as rrule])
(def event-spec (.fromString rrule.RRule. "DTSTART:20120201T093000Z\nRRULE:FREQ=WEEKLY"))
(.between event-spec (js/Date. (.UTC js/Date 2012 2 31)) (js/Date. (.UTC js/Date 2013 01 02)))
That works!I think in that case (require '["rrule$default" :as rrule :refer [RRule]])
should have worked, so this may be a bug in nbb as well. Feel free to post an issue
I think I was ever only writing about :refer [datetime]
which we have clarified is probably a different issue. So I am not sure what to file as I think the problem is not in nbb but in my understanding of the subtle interactions in and with JS/ TS libraries. 🙂