Fork me on GitHub
#shadow-cljs
<
2018-07-05
>
caleb.macdonaldblack01:07:19

------ WARNING #7 --------------------------------------------------------------
 File: /Users/calebmacdonaldblack/Projects/medial/test/cljs/medial_web/components/util_test.cljs:1:5
 Invalid Filename, got cljs/medial_web/components/util_test.cljs but expected medial_web/components/util_test.cljs (or .cljc)
--------------------------------------------------------------------------------

caleb.macdonaldblack01:07:30

Any idea how I can get that warning to go away? There is probably a setting I’m missing or something

caleb.macdonaldblack01:07:33

:source-paths ["src/cljs" "medial-common/src" "src/clj"]
:test-paths ["test/cljs" "test/clj"]

caleb.macdonaldblack01:07:04

I’m using :lein true and those options are in project.clj

thheller06:07:39

@caleb.macdonaldblack something must be adding "test" to the classpath

caleb.macdonaldblack06:07:24

@thheller When you say something do you mean source-paths or test-paths?

caleb.macdonaldblack06:07:37

What else can add "test" to the classpath?

thheller06:07:58

not sure. any plugin can add stuff IIRC

thheller06:07:47

try running lein classpath and check if /Users/calebmacdonaldblack/Projects/medial/test is on there

caleb.macdonaldblack06:07:37

Hmm Im not sure what I’ve done since I sent that message earlier in the day but the warning isn’t showing up anymore

caleb.macdonaldblack06:07:20

I did change my tests-paths form test -> test/cljs but I though I was still getting the warning. Maybe I forgot to restart or something but I’ve definitely no longer getting any warnings. Thanks for the help anyway

hlolli11:07:04

I'm trying to follow the shadow-cljs/examples/webpack example, I'm getting require errors, in the output of :npm-module (I output to "node_modules/shadow-cljs") there are many relative require that fail, for example

ERROR in ./js.reagent.core.js
Module not found: Error: Can't resolve './shadow.js.shim.module$react.js' in '/home/hlolli/Documents/visitor/node_modules/shadow-cljs'
 @ ./js.reagent.core.js 24:0-43
 @ ./visitor.main.js
 @ /home/hlolli/Documents/visitor/index.js
 @ multi ../webpack-dev-server/client? webpack/hot/dev-server /home/hlolli/Documents/visitor/index.js

ERROR in ./js.reagent.dom.js
Module not found: Error: Can't resolve './shadow.js.shim.module$react_dom.js' in '/home/hlolli/Documents/visitor/node_modules/shadow-cljs'
 @ ./js.reagent.dom.js 22:0-47
 @ ./js.reagent.core.js
 @ ./visitor.main.js
 @ /home/hlolli/Documents/visitor/index.js
 @ multi ../webpack-dev-server/client? webpack/hot/dev-server /home/hlolli/Documents/visitor/index.js
so I require it explicitly in one of my cljs source file
(:require ["react"]
            ["react-dom"])
but that wont fly far
symbol shadow.js.shim.module$react already provided by [:shadow.build.classpath/resource "js/shadow.js.shim.module$react.js"], conflict with [:shadow.build.js-support/require "react"]
in general shadow.js.shim.module$react_dom.js and shadow.js.shim.module$react.js are just one of hundreds of requires that webpack complains about being missing. I tried https://www.npmjs.com/package/closure-loader if this was a goog.provide issue, didn't make a difference. I guess these files are reachable for shadow-cljs, but are not spit to files. Maybe this is configureable, or :npm-modules for webpack isn't the right build.

thheller11:07:16

./js.reagent.core.js

thheller11:07:23

that doesn't look valid

thheller11:07:57

why is there a js. in front?

thheller12:07:25

closure-loader is not required and will probably break everything

thheller12:07:49

what files are in node_modules/shadow-cljs

thheller12:07:02

there should be a node_modules/shadow-cljs/reagent.core.js for example

hlolli12:07:39

that one's missing, no reagent.core.js, full stacktrace https://pastebin.com/MjnT4apj

thheller12:07:15

what files are in node_modules/shadow-cljs

thheller12:07:22

just list one

thheller12:07:32

node_modules/shadow-cljs/cljs.core.js

thheller12:07:39

whatever .. there must be something?

hlolli12:07:48

js.reagent.core, cljs.user.js

thheller12:07:32

the js. in front should not be there

thheller12:07:45

no idea how it would get there either

thheller12:07:48

what is your config?

hlolli12:07:51

something wrong here?

:public {:target           :npm-module
                   :output-dir       "node_modules/shadow-cljs"
                   :asset-path       "/"
                   ;; :source-map true
                   :module-loader    true
                   :js-options       {:resolve
                                      {"scroll" {:target :file
                                                 :file   "overrides/scroll_index.js"}}
                                      :js-provider :shadow}
                   :modules          {:main {:entries [visitor.main]}}
                   :compiler-options {;; :source-map true
                                      :source-map    true
                                      :infer-externs :auto
                                      ;; :optimizations :none
                                      }
                   ;; :devtools         {:http-root  "public"
                   ;;                    :http-port  8088
                   ;;                    :after-load visitor.main/init}
                   :open-file-command
                   ["emacsclient" "-n" ["+%s:%s" :line :column] :file]}       

thheller12:07:24

uhm yeah that config is invalid

thheller12:07:34

{:target :npm-module
 :output-dir "node_modules/shadow-cljs"
 :entries [visitor.main]
 :compiler-options {:infer-externs :auto
                    :source-map true}}

thheller12:07:46

:open-file-command is not valid in a build config btw. it should be at the top level

thheller12:07:01

but non of that explains the js. in front

hlolli12:07:11

ok, something from c/p, didnt complain, or do anything 😛

hlolli12:07:25

ok, 1 min, try this...

hlolli12:07:45

still the js. prefixes

hlolli12:07:49

and same error

thheller12:07:53

whats your webpack config? are you sure the loader is not still in there?

thheller12:07:08

webpack doesn't require ANY config whatsoever for this

hlolli12:07:40

yup, I may suspect there's a zombie process running atm... 1 min..

thheller12:07:54

I don't know where the js. in front is coming from. I just tested locally and everything is fine.

hlolli12:07:53

ok, maybe I take the example and move my source over... yes no idea, there was a zombie process there, nukeing the dir, npm i...

hlolli12:07:57

that was it, I realized there was a zombie ps there screwing with me, if I would have read the shadow-cljs logs I should have realized it, that it was always connecting to a server

thheller12:07:28

still doesn't explain the js. but ok

hlolli12:07:30

now the only error is

ERROR in /home/hlolli/Documents/visitor/index.js
Module not found: Error: Can't resolve 'shadow-cljs/visitor.main' in '/home/hlolli/Documents/visitor'
 @ /home/hlolli/Documents/visitor/index.js 1:0-35
 @ multi ../webpack-dev-server/client? webpack/hot/dev-server /home/hlolli/Documents/visitor/index.js
basically my webpack config

thheller12:07:51

did you recompile CLJS after cleaning node_modules?

hlolli12:07:01

could the js. be explained by asset-path, which I had before?

thheller12:07:19

/home/hlolli/Documents/visitor/node_modules/shadow-cljs/visitor.main.js exists?

thheller12:07:03

try restarting webpack? dunno

thheller12:07:18

try node require("shadow-cljs/visitor.main")

hlolli12:07:30

yes, this is now webpack, could be exlusions or lack of includes, just config shit there, I've been changeing it alow

hlolli12:07:58

Error: Cannot find module 'shadow-cljs/visitor.main'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
    at Function.Module._load (internal/modules/cjs/loader.js:475:25)
    at Module.require (internal/modules/cjs/loader.js:598:17)
    at require (internal/modules/cjs/helpers.js:11:18)

thheller12:07:17

are you sure you are in the correct directory? what is __dirname?

thheller12:07:26

nvm. thats not available in the shell

hlolli12:07:50

ahh facepalm

hlolli12:07:58

the directory got empty

hlolli12:07:58

node_modules/shadow-cljs cleared... now

> require("shadow-cljs/visitor.main")
ReferenceError: window is not defined
    at Object.<anonymous> (/home/hlolli/Documents/visitor/node_modules/shadow-cljs/ajax.xml_http_request.js:46:6)
    at Module._compile (internal/modules/cjs/loader.js:654:30)
webpack screwing with me I assume

thheller12:07:07

yeah ok browser only code doesn't load in node

thheller12:07:12

but it resolves properly to get that far

thheller12:07:16

must be webpack then

hlolli12:07:57

yes, I clear the config and view it over, now it's delivering

ERROR in ./ajax.xml_http_request.js
Module not found: Error: Can't resolve 'xmlhttprequest' in '/home/hlolli/Documents/visitor/node_modules/shadow-cljs'
 @ ./ajax.xml_http_request.js 42:160-185
 @ ./ajax.core.js
 @ ./visitor.main.js
 @ /home/hlolli/Documents/visitor/index.js
 @ multi ../webpack-dev-server/client? webpack/hot/dev-server /home/hlolli/Documents/visitor/index.js
but it could be anything at this point, will report if Im still stuck

thheller12:07:21

mussing npm install xmlhttprequest

hlolli12:07:09

ok, next error haha

ERROR in ../xmlhttprequest/lib/XMLHttpRequest.js
Module not found: Error: Can't resolve 'child_process' in '/home/hlolli/Documents/visitor/node_modules/xmlhttprequest/lib'
 @ ../xmlhttprequest/lib/XMLHttpRequest.js 15:12-36
 @ ./ajax.xml_http_request.js
 @ ./ajax.core.js
 @ ./visitor.main.js
 @ /home/hlolli/Documents/visitor/index.js
 @ multi ../webpack-dev-server/client? webpack/hot/dev-server /home/hlolli/Documents/visitor/index.js

ERROR in ../xmlhttprequest/lib/XMLHttpRequest.js
Module not found: Error: Can't resolve 'fs' in '/home/hlolli/Documents/visitor/node_modules/xmlhttprequest/lib'
 @ ../xmlhttprequest/lib/XMLHttpRequest.js 16:9-22
 @ ./ajax.xml_http_request.js
 @ ./ajax.core.js
 @ ./visitor.main.js
 @ /home/hlolli/Documents/visitor/index.js
 @ multi ../webpack-dev-server/client? webpack/hot/dev-server /home/hlolli/Documents/visitor/index.js

thheller12:07:34

set :runtime :browser in the build config

thheller12:07:10

cljs-ajax is using cljs.core/*target*

hlolli12:07:48

yes, thought it was bit node targeted there

{:target           :npm-module
                   :output-dir       "node_modules/shadow-cljs"
                   :entries          [visitor.main]
                   :runtime          :browser
                   :compiler-options {:infer-externs :auto
                                      :source-map    true}}
like this?

hlolli12:07:18

will nuke the dir again, didnt change.. moment..

thheller12:07:26

might need to kill .shadow-cljs/builds/public. not sure if changing that nukes the cache

thheller12:07:41

it should be you never know

hlolli12:07:31

ah ok, will try

thheller12:07:50

otherwise try setting :compiler-options {:closure-defines {cljs.core/*target* "browser"}} in the build config

hlolli12:07:07

ok I try that, because the error wont go

thheller12:07:28

haha no wait ... its a conditional require ... webpack doesn't like those

thheller12:07:50

shadow-cljs hates them too

thheller12:07:24

and replace

(def xmlhttprequest
  (if (= cljs.core/*target* "nodejs")
    (let [xmlhttprequest (.-XMLHttpRequest (js/require "xmlhttprequest"))]
      (goog.object/set js/global "XMLHttpRequest" xmlhttprequest)
      xmlhttprequest)
    (.-XMLHttpRequest js/window)))

thheller12:07:51

with just (def xmlhttprequest (.-XMLHttpRequest js/window))

hlolli12:07:32

ah ok I see, wouldn't it be better then as a macro?

hlolli12:07:51

for future

thheller12:07:29

I never used that lib. I don't know.

hlolli12:07:55

then the condition is resolved before compilation, could add ticket

hlolli12:07:27

voila, all lights are green

hlolli12:07:56

thanks a lot!

thheller12:07:29

they probably don't expect that uncompiled CLJS output gets processed by webpack

thheller12:07:52

compiled the closure compiler will probably have removed the js/require call so it wouldn't fail

hlolli12:07:22

yes, or more reader-macros, like so many are begging for.

hlolli12:07:37

exacly, one of many reasons I prefer shadow-cljs 🙂

thheller12:07:04

yeah that would certainly fix this problem

currentoor18:07:33

I used a template to generate a shadow-cljs app but I see this warning, in development Warning: It looks like you're using a minified copy of the development build of React.

currentoor18:07:02

none of my cljs code or deps is minified

currentoor18:07:34

any idea why this is happening?

justinlee18:07:11

@currentoor it’s harmless (but unfortunately i don’t think you can get rid of it). shadow does some minification that trips that warning, but the warning isn’t accurate. you are using the correct version.

currentoor18:07:34

oh ok well that's a relief simple_smile