Fork me on GitHub
#shadow-cljs
<
2017-11-03
>
eveko12:11:49

how does the compiled js go about referencing node modules?

thheller13:11:31

:browser builds bundle the code

thheller13:11:56

node targets just use require

eveko13:11:22

i am getting this error

thheller13:11:27

no immediate idea

eveko13:11:54

I thought maybe it could have been that the js has no access to the node modules

eveko13:11:10

as http://asp.net core only serves the wwwroot directory to the public

thheller13:11:41

nah its all bundled into the <output-dir>/cljs-runtime/... directory

thheller13:11:52

and you’d get an error if something failed to load there

thheller13:11:02

do you get any other errors in the browser console?

thheller13:11:47

there should be a <output-dir>/cljs-runtime/module$node_modules$create_react_class$index.js file

eveko13:11:07

it is there

eveko13:11:18

i can even browse to it from the sources in the console

eveko13:11:37

this is the full error

thheller13:11:06

can you paste the first few lines of <output-dir>/cljs-runtime/reagent.impl.component.js?

thheller13:11:34

should have goog.provide and goog.require + shadow.js.require

eveko13:11:34

only see goog ones

eveko13:11:37

not shadow js

thheller13:11:30

ok, its missing for me too

thheller13:11:32

looking into it

thheller13:11:48

which part of reagent are you using?

thheller13:11:36

well I guess the create-class fn

eveko13:11:03

i am trying to make the simple example to work

thheller13:11:33

strange, I used that exact example when testing myself

thheller13:11:02

but yeah its broken

thheller13:11:48

I think I know why …

thheller13:11:27

yep .. those darn symbols … fixing …

thheller13:11:04

wonder how https://mhuebert.github.io/shadow-re-frame/ worked without running into that 😛

eveko14:11:54

black magic?

eveko15:11:22

cheers it works

thheller16:11:08

@mhuebert you have used (set! *warn-on-infer* true) before. do you think it would be useful to always enable that for files with JS requires?

thheller16:11:37

currently fixing it for shadow-cljs and removing a few false positives so it should be more reliable

mhuebert19:11:44

@thheller I find these instructions (from https://clojurescript.org/guides/externs#externs-inference) a bit confusing:

However this alone isn't enough to have the compiler generate warnings around externs. Because of the large number of libraries written before this feature existed, we cannot enable this capability in a global way. Instead there is a new file local compiler flag *warn-on-infer* which is somewhat analogous to *warn-on-reflection* in Clojure. Once set the compiler will warn for the remainder of the file anytime it cannot determine the types involved in a dot form, whether property access or method invocation.

mhuebert19:11:29

from that, I understood that somehow enabling :infer-externs is not enough, and I also had to put *warn-on-infer* in my files to enable the inference

mhuebert19:11:55

I think I’d like inference to happen automatically on all my projects where I import JS stuff (unless there are tradeoffs i’m not aware of)

mhuebert19:11:00

so I am not entirely sure if I understand the question 🙂

thheller20:11:03

yeah basically what you said

thheller20:11:11

currently you need to enable it once per file

thheller20:11:15

which I find annoying as well

thheller20:11:43

but enabling it for everyhing may cause too many warnings

thheller20:11:05

dunno yet, I get like 600 warnings if I enable it for cljs.core

thheller20:11:02

so I though I just set the *warn-on-infer* for every file with a JS import

thheller20:11:56

*warn-on-infer* was broken until today but now you’ll get proper warning again

mhuebert21:11:52

So just to confirm, does warn-on-infer only affect warnings or also extern generation?