Fork me on GitHub
#shadow-cljs
<
2017-11-01
>
cmal04:11:39

Hi, it seems I touched nothing but suddenly went into a lot of errors such as

index.js:1 Uncaught TypeError: shadow.js.provide is not a function
    at index.js:1
(anonymous) @ index.js:1
emptyObject.js:1 Uncaught TypeError: shadow.js.provide is not a function
    at emptyObject.js:1
(anonymous) @ emptyObject.js:1
invariant.js:1 Uncaught TypeError: shadow.js.provide is not a function
    at invariant.js:1

cmal04:11:54

Reinstall shadow-cljs solves this. It may because of I run git pull in the shadow-cljs repo. 😕

cmal04:11:14

...
[CACHED] doumi/bottomnav.cljs
-> JS Cache read: 32 JS files
<- JS Cache read: 32 JS files (24 ms)
-> Closure - Optimizing ...
Closure compilation failed with 1 errors
--- EXTERNS:/Users/yuzhao/.m2/repository/cljsjs/d3/4.2.2-0/d3-4.2.2-0.jar!/cljsjs/d3/common/d3.ext.js:670
Object literal contains illegal duplicate key "scaleSequential", disallowed in strict mode
I've already removed d3 from shadow-cljs.edn and deleted the d3 folder from ~/.m2/repository/cljsjs, but shadow-cljs still gives me this error.

cmal04:11:55

10774 ± : ls /Users/yuzhao/.m2/repository/cljsjs/d3/                                                                         ⏎ [43m] ✹
ls: /Users/yuzhao/.m2/repository/cljsjs/d3/: No such file or directory

cmal04:11:39

Does shadow-cljs need to do some "clean" work?

cmal04:11:29

It is weird I already have removed all about d3 from my code.

cmal05:11:06

===> Hi, I removed the target folder , removed [braintripping/re-frame-trace "0.1.9"] and run shadow-cljs release app again and it works now!

mhuebert09:11:33

@cmal that error I believe is from an old version of braintripping/re-frame-trace

cmal09:11:23

OK. I've switched re-frame-trace to re-frisk now.

cmal09:11:41

And it works well in wechat simulator.

thheller09:11:20

@cmal that error is from an old cljsjs/d3 release, not directly related to shadow-cljs

cmal09:11:27

@thheller I update shadow-cljs version. And after that I find the old target prevent me from re-compiling the new code until I removed target folder when it begins to work.

thheller09:11:53

yes, that is due to AOT. I do not recommend working with a checkout of shadow-cljs

thheller09:11:36

I can probably add a config option to disable AOT, but then startup will be very slow

thheller09:11:33

only need to delete target/shadow-cljs/aot-classes, the rest is ok to keep

cmal09:11:35

OK. Maybe a shadow-cljs clean-aot to clean the aot. I stared at the [CACHED] things for a while and finally found out removing target will work. 😄

thheller09:11:55

that is not related

thheller09:11:34

[CACHED] cljs/core.cljs means that the CLJS compilation output is cached

thheller09:11:00

I do all kinds of checks to ensure that is properly invalidated

thheller09:11:18

the AOT cache is wiped whenever a new shadow-cljs release is used

cmal09:11:36

Yes. I remembered I got the error message when Optimizing....

thheller09:11:37

but that doesn’t work of you use a checkout

cmal09:11:43

-> Closure - Optimizing ...
Closure compilation failed with 1 errors
--- EXTERNS:/Users/yuzhao/.m2/repository/cljsjs/d3/4.2.2-0/d3-4.2.2-0.jar!/cljsjs/d3/common/d3.ext.js:670
Object literal contains illegal duplicate key "scaleSequential", disallowed in strict mode

cmal09:11:08

No. I did not use a checkout. Not yet find out how to work with a checkout. 😆

thheller09:11:38

do shadow-cljs --cli-info | grep d3

cmal09:11:47

just in case because I lein install once weeks before.

thheller09:11:16

oh wait .. it already has all the info 😉

thheller09:11:27

you are using cljsjs/d3/4.2.2-0

thheller09:11:48

(probably not you, but one of your dependencies)

cmal09:11:11

yep. @mhuebert says it was [braintripping/re-frame-trace "0.1.9"]

cmal09:11:24

I removed that and it works.

thheller09:11:28

this was fixed a while ago

thheller09:11:36

you just need the updated cljsjs/d3 version

thheller09:11:38

add [cljsjs/d3 "4.3.0-5"] as your first :dependencies

mhuebert09:11:50

(a newer re-frame-trace version)

cmal09:11:50

Never mind. I do not use that any more. But I will write that down, in case later I will use d3 again. 😆

thheller09:11:00

ah its a fork ok

mhuebert09:11:03

oh… you are right though I think

mhuebert09:11:34

I had removed d3 from the build because that feature doesn’t work anyway, but then was trying to get my fork to be closer to master and forgot about this whole d3 extern fiasco

mhuebert09:11:25

going to submit a PR to re-frame-trace

mhuebert09:11:00

I didn’t notice because I am not doing an :advanced build for the demo anymore as it causes too many problems with trace

thheller09:11:57

wonder which hacks trace is doing 🙂

thheller10:11:21

@mhuebert about circleci, if there is something I could add to make integration easier let me know

thheller10:11:43

still need to figure out this cljs.test stuff

mhuebert10:11:50

@thheller I happened to make my attempt last night when circleci itself began having reliability problems

thheller10:11:01

ah hehe doh

mhuebert10:11:03

their 1.0 platform is way too slow and underresourced so the builds fail

mhuebert10:11:13

and their 2.0 platform wasn’t working properly last night

mhuebert10:11:58

unfortunately i didn’t realize that their platform wasn’t working until later so I gave up on some of the config stuff that might have worked

thheller10:11:11

shadow-cljs happily eats up all the resources it can get since everything is threaded/parallel

thheller10:11:48

might need an option to turn that off for things like CI

thheller10:11:33

2 builds in parallel = 2x memory requirement

mhuebert10:11:47

it looks like parallelism in circleci means ‘multiple machines’ instead of providing multiple cores or more memory in one machine: https://circleci.com/docs/2.0/parallelism-faster-jobs/

mhuebert10:11:10

and not sure if it helps us at all. they do give 4 instances for free for open source projects

thheller10:11:50

hmm so each “job” only gets one core?

thheller11:11:44

hmm can’t find any info on how much resources each job gets

thheller11:11:55

OSS probably = small?

thheller11:11:20

yuck .. definitely need a “use less resources” option then, parallel builds will actually be slower on one core

mhuebert11:11:41

2CPU/4096MB

mhuebert11:11:45

that’s what my build gets

thheller11:11:17

ah ok, that should be ok then

mhuebert11:11:49

circleci 2.0 is based on docker vs. their old config system

mhuebert11:11:59

which means it is no longer simple to specify an environment that has both nodejs and java

mhuebert11:11:24

it used to be as simple as specifying a version for both. now, because they only have prebuilt docker images for each individually, you have to make or find your own

mhuebert11:11:32

the one i found has an old version of node

mhuebert11:11:46

equals pain.

thheller11:11:44

I have to confess that I have never used docker … or rather never could get it running.

thheller11:11:26

I take a plain old linux box over this container crap any day 🙂

mhuebert11:11:36

now i found a docker image that has java and recent node, but no git

mhuebert11:11:21

apparently i already have a docker account

thheller11:11:49

you could probably use the lein image they provide

thheller11:11:57

ah no wait .. need npm 😛

thheller11:11:40

wait .. circleci is using clojurescript? how do they not have a pre-built image for this

mhuebert11:11:29

maybe they do

mhuebert11:11:43

there is an official clojure image but it appears to only include lein and boot

thheller11:11:25

hmm yeah thats enough if you only use cljsjs, guess I need to sell them on shadow-cljs 😉

eveko16:11:52

I cannot get shadow cljs to compile my cljs, I get the error could not find or load main class clojure.main... Google does not give any usefull hints. Going through lein it works , but I don't want to use lein for this project.

thheller18:11:22

@eveko which error do you get?

eveko18:11:11

Just that it cannot find clojure.main

thheller18:11:25

full error + command you used would help

eveko18:11:47

Give me a moment need to fish my laptop

thheller18:11:04

which OS are you on? windows by any chance?

eveko18:11:11

Yeah Windows

thheller18:11:27

hmm yeah thats probably it. I never tried running windows before.

thheller18:11:45

have you considered the linux subsystem stuff for windows? that works pretty well

eveko18:11:55

I will try that in a moment

eveko18:11:25

The command is shadow-cljs watch app

eveko18:11:58

Then error: could not find or load main class clojure.main

thheller18:11:02

let me check if there is an easy way to figure out if running in windows

eveko19:11:27

Ok i got a different error now

eveko19:11:44

It is namespace related, so I think I can resolve it with some tinkering

thheller19:11:23

I really recommend the linux subsystem stuff, that just works out of the box

thheller19:11:44

I’m not 100% I handle everything correctly when it comes to windows, I should be in most cases

thheller19:11:17

otherwise just report the errors and I’ll see if I can fix it

eveko19:11:21

I had the same error though from the wsl a moment ago

eveko19:11:34

The clojure main one

thheller19:11:14

hmm thats odd

eveko19:11:16

But then again, it does flip out having both windows and Linux version of commands

thheller19:11:18

maybe old node version?

eveko19:11:30

I am on node 9

thheller19:11:23

booting my windows machine now 🙂

eveko19:11:51

It is a pity though, I wanted to experiment with some cljs front end, our backend at work is http://asp.net framework on windows

thheller19:11:46

I tried keeping everything windows compatible, just might have missed a few things

eveko19:11:35

Current error I get is failed to inspect resource

eveko19:11:07

Then the path of my cljs file

thheller19:11:26

I really need the full error

thheller19:11:18

trying it on my windows machine now but almost everything is outdated there

thheller19:11:27

updates gonna take a while

thheller19:11:38

running it via wsl works fine

eveko19:11:17

[:app] Compiling ... Nov 01, 2017 8:04:01 PM clojure.tools.logging$eval761$fn__764 invoke WARNING: failed to inspect resource "C:\Users\*\Documents\Visual Studio 2017\Projects\techtest\techtest\src-cljs\main\app.cljs", it will not be available. The required namespace "techtest.app" is not available.

eveko19:11:42

this is the console output from windows

eveko19:11:36

the wsl one also has the same error, but I believe that is because wsl tends to sometimes use the windows binary of noder/yarn

eveko19:11:34

I will try making this work on my home desktop where i can be sure that wsl wont use windows binaries

thheller19:11:40

it sort of works in windows directly

thheller19:11:52

the compiled succeeded but the watch failed, I can fix that

thheller19:11:55

the above error just looks like a namespace violation?

thheller19:11:19

techtest.app should be in src-cljs\main\techtest\app.cljs

thheller19:11:34

if src-cljs/main is your source path

thheller19:11:55

main\app.cljs would be main.app

eveko19:11:13

oh hold on

thheller19:11:25

not sure why the inspect fails though, there should be a proper message for that

thheller19:11:44

oh hmm … might be me packing this mistake

eveko19:11:09

ok i think i am overlooking how to set up the module in the edn

eveko19:11:27

if I have src-cljs/main/app.cljs

thheller19:11:46

:source-paths ["src-cljs"] in the shadow-cljs.edn

eveko19:11:47

the namespace in app.cljs is techtest.app

thheller19:11:11

then it should be in src-cljs/techtest/app.cljs

thheller19:11:06

ah maybe its empty or doesn’t start with (ns techtest.app)?

thheller19:11:33

everything in CLJS is namespaced and it must always be first in each sourcefile

eveko19:11:43

(ns techtest.app)

eveko19:11:41

maybe something wrong here?

thheller19:11:23

do you have :source-paths ["src-cljs"]? besides that it looks correct

thheller19:11:16

hmm let me check if it chokes because of the spaces in the file path, eg. Visual Studio 2017

thheller19:11:22

it really shouldn’t but you never know

eveko19:11:05

so I am getitng that clojure main error

thheller19:11:06

npm install + npx shadow-cljs watch app

thheller19:11:37

didn’t bump the version

thheller19:11:36

compiling should work fine

thheller19:11:41

just file watching is broken

eveko19:11:33

yeah exception and then build complete

thheller19:11:41

trying to make sense of this error but I’ll get that fixed

eveko19:11:23

I go try get my cljs to compile

eveko19:11:47

cause the one I just pulled worked, It also had the visual studio path, so the spaces are not the issue

thheller19:11:10

ok good to know

thheller19:11:50

I got no immediate idea what might be causing your issue. does it dump a full stacktrace?

eveko19:11:24

no it does not.

eveko19:11:44

it did dump one when doign the browser one

eveko19:11:03

the required namespace is not available... 😕

thheller19:11:53

if you can post the contents of the project I can take a look

eveko20:11:41

I have it on local git only atm

eveko20:11:02

unless you don't mind opening a zip

thheller20:11:29

sure that works

thheller20:11:07

skip the node_modules and target folders, don’t need those 🙂

eveko20:11:04

here you go

eveko20:11:16

you propably also don't want the microsoft packages 😛

thheller20:11:41

(ns techtest.app
    :require [reagent.cor :as r])

thheller20:11:49

thats missing a ( before :require

eveko20:11:05

dirt in my eyes

eveko20:11:36

and typo at core as well

thheller20:11:48

(ns techtest.app
  (:require [reagent.core :as r]
            [clojure.string :as str]))

thheller20:11:10

as the reagent example for some reason doesn’t have a proper require for clojure.string

thheller20:11:21

besides that it looks ok

eveko20:11:47

it still does not find the namespace though

eveko20:11:36

also if it seems that the watch is trying to do something

thheller20:11:26

hmm yeah it doesn’t work on my machine as well … investigating

thheller20:11:57

<U+FEFF>(ns techtest.app
  (:require [reagent.core :as r]
            [clojure.string :as str]))

thheller20:11:16

there is a bad character in front

thheller20:11:56

I can’t rid of it in my editor

eveko20:11:31

but I don't have that , why would there be font info?

thheller20:11:44

dunno, my editor doesn’t show it either

thheller20:11:45

looking at it with less shows it (the linux tool, not the css thing)

eveko20:11:31

but nano can't see it

thheller20:11:49

yeah I tried vscode, atom, intellij, vim, emacs

thheller20:11:00

not a single one is able to show or remove it

thheller20:11:03

super weird

thheller20:11:33

vim -b app.cljs worked

eveko20:11:54

i just made an other file

eveko20:11:59

copied the contents

eveko20:11:05

delete old and rename

eveko20:11:52

but now it cannot find react

thheller20:11:19

npm install react react-dom

eveko20:11:38

create-react-class

eveko20:11:45

can i just not yarn add react?

thheller20:11:44

yes yarn works too

eveko20:11:48

it does but now I get namespace error for create-react-class

thheller20:11:01

also yarn add create-react-class

thheller20:11:21

its a bit unfortunate how reagent is bundled currently, the alpha is a bit in flux and doesn’t properly declare some deps

eveko20:11:35

woot done 😛

eveko20:11:38

it compiled

thheller20:11:27

I “fixed” the watch issue … well it doesn’t error out anymore, but doesn’t update either 😉

thheller20:11:03

not quite sure why

eveko21:11:29

now i need to figure out how to make http://asp.net serve the correct path for js

eveko21:11:36

it is trying to find the other compiled js in the views folder

eveko21:11:42

but they are in the public

thheller21:11:10

hmm no idea how that works in http://asp.net, never used it

thheller21:11:30

should be easy to just serve one directory, its just static files

thheller21:11:41

use the public directory?

eveko21:11:53

very easy really

eveko21:11:13

:asset-path "../js"

eveko21:11:15

in the edn

thheller21:11:28

be careful with relative paths in JS

thheller21:11:46

if you try to do that in it won’t work

eveko21:11:35

it adds the asset-path at the end of the url for the lookup

eveko21:11:39

why is that so?

eveko21:11:12

/public/views/public/js/cljs-runtime/module$node_modules$fbjs$lib$getActiveElement.j

eveko21:11:22

instead of public/js/cljs-runtime/module$node_modules$fbjs$lib$getActiveElement.js

thheller21:11:48

:output-dir and :asset-path sort of belong together

thheller21:11:13

:asset-path is where the files are reachable when using a http server

thheller21:11:29

public all files from :output-dir must be reachable there

thheller21:11:56

:asset-path should basically always be an absolute path

thheller21:11:04

everything else is just asking for trouble

thheller21:11:30

the asp link about mentions a wwwroot? so maybe use :output-dir "wwwroot/js"?

eveko21:11:59

i will have to check around,

thheller21:11:20

but I really don’t know .. the article looks like it should work if configured correctly

eveko21:11:34

i am using .net framework.

thheller21:11:36

its just static files, not the typical “view”

eveko21:11:49

that is so

eveko21:11:10

oh well i will tinker arround. the ../js will be my dirty temporary solution

eveko21:11:25

should work fine if i treat the project as a spa

thheller22:11:59

@eveko just published [email protected] which has fixes for all the obvious windows issues I could find

thheller22:11:04

reloading works properly now

thheller22:11:21

let me know if you run into any other issues