Fork me on GitHub
#shadow-cljs
<
2019-07-23
>
tianshu00:07:53

what situation may cause this, when calling a function in repl it's said to be undefined, but it actually works. SOLVED, solved this by hard reload browser.

currentoor04:07:03

anyone figure out how to use moment.js with shadow-cljs?

thheller08:07:02

@currentoor what is there to figure out?

romain08:07:20

@thheller oh yes! it seems pretty cool, thanks 😄

currentoor16:07:07

@thheller

["moment" :default moment]
doesn’t work but it turns out they intentionally have the ES6 importable code in
["moment/src/moment" :default moment]

currentoor16:07:14

which works as expected

thheller20:07:50

@currentoor ["moment" :as m] probably works too. :default is kinda dependent on how the package is packaged

wilkerlucio20:07:04

@currentoor I suggest you check https://date-fns.org/ too, its a more modern and functional friendly time API

currentoor20:07:07

@U066U8JQJ this is a legacy project that i’m upgrading to shadow-cljs and newer fulcro

currentoor20:07:26

personally i like this

currentoor20:07:50

if i have clj on the backend, then i can write my logic in cljc

tianshu20:07:51

@thheller I have a cljs file whenever I save the file it will recompile but only generating the code of ns form in javascript

tianshu20:07:03

looks very wierd

tianshu20:07:12

This is the code generated, but actually there should be a very simple hello function.

goog.provide('xycp.frontend.event.http');
goog.require('cljs.core');
goog.require('cljs_http.client');
goog.require('cljs.core.async');
goog.require('re_frame.core');

//# sourceMappingURL=xycp.frontend.event.http.js.map

tianshu20:07:23

what define means? you mean where is the file?

thheller20:07:12

what is the actual CLJS code ?

tianshu20:07:02

(ns xycp.frontend.event.http
  (:require [cljs-http.client :as http]
            [cljs.core.async :refer [<! go]]
            [re-frame.core :as re-frame :refer [reg-fx]]))

(defn hello [] 1)
this is the code

tianshu20:07:18

and I think the file path is correct, matching the namespace.

tianshu20:07:47

even I change the requires, the generated file will totally not change

tianshu20:07:58

but the modify time will be updated

thheller20:07:33

dunno. hard to say. it should definitely contain that function

thheller20:07:09

maybe you have some weird special character in the file? some unicode characters don't show up but can cause all kinds of weird stuff to happen sometimes

tianshu20:07:30

If I delete this file, it will not be regenerated

tianshu20:07:02

@thheller no unicode I think, just tried delete very thing in this file

tianshu20:07:20

how can I investigate deeper?

thheller20:07:56

not a clue. did you try a proper restart?

tianshu20:07:39

let me have a try. It definitely have some cache stuf

tianshu20:07:49

it regenerate the js

tianshu20:07:58

but still with old content

tianshu20:07:27

Restart will generate a proper content. @thheller

tianshu20:07:41

I think I found something.

thheller20:07:01

FWIW there are known race conditions and other problems if you combine the REPL with the regular live-reload

thheller20:07:10

so using both can definitely cause issues

tianshu20:07:33

emm, looks like once the graph is created, it will not change

thheller20:07:01

if you create it via the REPL first that is possible yes

tianshu20:07:05

If add :dev/always in an non-toplevel namespace, will cause the similar issue

thheller20:07:16

because it will not have a file associated with it then

tianshu20:07:30

no need for a fix, but like me, I don't know this and run into this kind of issue twice today...

thheller20:07:55

well having a reproducible example would certainly help

thheller20:07:20

I'm only guessing here. I don't know about any actual reproducible issue. otherwise I'd fix that.

tianshu20:07:23

should evaluating a ns form being supported?

tianshu20:07:56

basically it's not necessary, but editors allow this.

tianshu20:07:02

anyway I can continue my work it's good news for me.