Fork me on GitHub
#clojurescript
<
2018-06-29
>
vigilancetech03:06:42

trying to follow the clojurescript quick start and not getting a repl prompt. Any idea how to debug? Get the "hello world!" and the web page but that's where it stops

vigilancetech04:06:39

it goes into repl if I omit both the --main cljs.main and the --compile hello-world.core parts

richiardiandrea04:06:23

@vigilancetech try to add -r at the end of the command without removing compile and main

vigilancetech04:06:40

@richiardiandrea it already has --repl at the end

richiardiandrea04:06:21

Oh ok, in that case I would not know what's wrong then..

vigilancetech04:06:22

probably some corrupt file or library. I've reinstalled everything I can think of

vigilancetech04:06:27

other than the whole OS

bhauman11:06:39

@vigilancetech there are ways to debug this, try cljs --main cljs.main when the browser pops open you should look at the browser console log for errors

bhauman11:06:33

Also I happen to be working on a quick start doc for figwheel.main http://rigsomelight.com/figwheel-main/quick_start.html it may help you get up and running.

bhauman11:06:34

the document is in it's very early stages and isn't complete but you should be able to get a working REPL

andreasklein12:06:44

Can I get om-next to normalise nested lists into its default db format? I currently have a list of persons where each has a list of contact-persons and om-next only normalises the top level person list when loading its app state.

bhauman12:06:48

@andreasklein I don't know the answer but there is an active #om channel

andreasklein12:06:08

@bhauman thank you. I will ask around there. There is also a dead? #om-next channel

bhauman12:06:36

yeah I'm not sure of the status at all

bhauman12:06:45

of #om-next

justinlee16:06:05

question about cljs.main: i’m trying out the ghostwheel tool for the first time and I’m supposed to pass a compiler option to get it to run. is this the right way of doing it? clj --main cljs.main -co "{:ghostwheel true}" --compile tst.core --repl I’ve never passed an arbitrary compiler option to a library like this before

justinlee16:06:42

I’m worried I’m doing this wrong because the cljs.main web page uses it by calling directly to java rather than clj

Bravi16:06:51

Hi. I’m trying to jack-in clojurescript repl. it seems like it’s all working fine - it says connected at the bottom of the screen but when I try to evaluate anything, it says that I need to jack-in clojurescript repl

Garrett Hopper16:06:24

@lee.justin.m That's right. :thumbsup: I didn't realize arbitrary compiler parameters could be used like that, but that matches up to what the ghostwheel readme says to to.

Garrett Hopper16:06:15

Has anyone run across javascript like this:

exports.default = exampleFunction;
module.exports = exports['default'];
I'm not sure why the convention exists, but the cljs compiler doesn't consume it properly: Uncaught TypeError: Cannot set property 'default' of undefined

Garrett Hopper16:06:10

Here's an example of the output it generates. (It tried to define ['default']['default'] and then later define ['default'] as that values.)

goog.provide("module$data$prs$dev$timesheet$node_modules$inline_style_prefixer$utils$isObject");
goog.provide("module$inline_style_prefixer$utils$isObject");
var module$data$prs$dev$timesheet$node_modules$inline_style_prefixer$utils$isObject={};
module$data$prs$dev$timesheet$node_modules$inline_style_prefixer$utils$isObject["default"]["default"]=function(value){return value instanceof Object&&!Array.isArray(value)};
Object.defineProperty(module$data$prs$dev$timesheet$node_modules$inline_style_prefixer$utils$isObject["default"],"__esModule",{value:true});
module$data$prs$dev$timesheet$node_modules$inline_style_prefixer$utils$isObject["default"]=module$data$prs$dev$timesheet$node_modules$inline_style_prefixer$utils$isObject["default"]["default"]

Garrett Hopper16:06:41

Running ClojureScript 1.10.339

justinlee16:06:49

@ghopper thanks for confirming (sadly the library still doesn’t work)

justinlee16:06:22

those two lines of javascript don’t make sense to me. the first line is how you emulate es6 default exports in es5

justinlee16:06:28

the second line just seems wrong.

justinlee16:06:41

either way, I don’t understand why the exports object would be undefined

justinlee16:06:18

is the source from an npm module?

Garrett Hopper17:06:01

@lee.justin.m Right, it definitely seemed wrong to me. It is; I've seen it in a lot of npm module dependencies. Interestingly, I just looked up the code for the dep and it's different from what I got from npm: https://github.com/rofrischmann/inline-style-prefixer/blob/master/modules/static/createPrefixer.js vs http://ix.io/1fpl

Garrett Hopper17:06:40

I guess the latter is the output of babel or something.

justinlee17:06:10

It looks like there is some disagreement as how to do default exports when there is only one export

justinlee17:06:42

I remember @thheller talking about this but I didn’t understand the issue then 🙂

Garrett Hopper17:06:02

Huh, interesting. I'm only vaguely familiar with the es6 export stuff. So the problem here is that the closure compiler can't consume modules using the .default method?

Garrett Hopper17:06:36

I'm still not sure where the ['default']['default'] is coming from.

dnolen17:06:57

@lee.justin.m ClojureScript doesn’t really care what you pass, and yes that should work

justinlee17:06:34

@dnolen thanks. now to figure out why the library doesn’t work for me 🙂

Garrett Hopper17:06:35

@dnolen Alright, I'll try to find the minimum reproducible.

justinlee17:06:40

haven’t people been talking about being able to run gists using clj + cljs.main? i want to make this test case easily reproable without zipping up the deps.edn and source and uploading it to github. this seems like the ideal case where i could just slap it on a gist and then paste a one-liner in the issue

Garrett Hopper17:06:06

The deps.edn could be on the command line, no?

thheller17:06:43

@ghopper the .default.default comes from Closure rewriting ES6 files that were rewritten by babel to be commonjs

Garrett Hopper17:06:37

@thheller Why does closure think it's ES6 if it's already been compiled to commonjs?

thheller17:06:54

no, closure thinks its commonjs

Garrett Hopper17:06:39

Which should be fine, right? Babel already changed it from ES6 to commonjs.

thheller17:06:23

no, closure does not detect the __esModule marker and since commonjs doesn't have a default export it just rewrites it like any other exported property

Garrett Hopper17:06:23

I'll read that issue and try to understand.

thheller17:06:28

leaving you with .default.default

Garrett Hopper17:06:05

@thheller Alright, so I understand the .default.default thing, I think. However, the generated output should still not throw errors, right? I should be able to manually get the default property and use it?

Garrett Hopper17:06:48

Is there any workaround for consuming these modules from clojurescript at the moment?

dnolen17:06:46

@andreasklein #om is the om.next channel - however I’m too swamped with ClojureScript stuff these days to be all that active anymore - note there are lot of alternatives these days Fulcro etc.

vigilancetech19:06:54

@bhauman it says "Uncaught SyntaxError: Invalid or unexpected token" at main.js:1 which is: "#!/usr/bin/env node"

bhauman19:06:55

@vigilancetech I'll need some more context as that doesn't give me much

bhauman20:06:55

main.js shouldn't have #!/usr/bin/env node at all

bhauman20:06:14

@vigilancetech what command are you using?

bhauman20:06:54

cljs --main cljs.main?

vigilancetech20:06:54

clj --main cljs.main

vigilancetech20:06:01

cljs isn't found

bhauman20:06:55

so have you created a deps.edn file and specified clojurescript as a dependency?

vigilancetech20:06:36

{:deps {org.clojure/clojurescript {:mvn/version "1.10.339"}}}

bhauman20:06:43

oh OK I understand what you are saying now

vigilancetech20:06:06

#!/usr/bin/env node
if(typeof Math.imul == "undefined" || (Math.imul(0xffffffff,5) == 0)) {
    Math.imul = function (a, b) {
        var ah  = (a >>> 16) & 0xffff;
        var al = a & 0xffff;
        var bh  = (b >>> 16) & 0xffff;
        var bl = b & 0xffff;
        // the shift by 0 fixes the sign on the high part
        // the final |0 converts the unsigned value into a signed value
        return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
    }
}

var path = require("path");
try {
    require("source-map-support").install();
} catch(err) {
}
require(path.join(path.resolve("."),"out","goog","bootstrap","nodejs.js"));
require(path.join(path.resolve("."),"out","cljs_deps.js"));
goog.global.CLOSURE_UNCOMPILED_DEFINES = {"cljs.core._STAR_target_STAR_":"nodejs"};
goog.require("hello_world.core");
goog.require("cljs.nodejscli");

bhauman20:06:39

OK you will need to delete your out directory

bhauman20:06:25

and delete main.js

bhauman20:06:53

and then run clj -m cljs.main

vigilancetech20:06:11

ah, no more error 🙂 Now to see if it will fire up a repl

bhauman20:06:31

yes cleaning main.js and the out directory while you are trying different commands is important

vigilancetech20:06:45

still waiting on a repl

bhauman20:06:55

@vigilancetech the above command should start a REPL

vigilancetech20:06:18

I added a -r to the end

bhauman20:06:33

you don't need -r to get a REPL

bhauman20:06:41

in this case

bhauman20:06:35

but yes if you are compiling hello-world.core you would need -r as well

vigilancetech20:06:38

clj by itself gives me one. clj -m cljs.main doesn't. It gives me the parking page and just hangs

bhauman20:06:05

let's figure that out

bhauman20:06:14

it sounds like a caching issue

bhauman20:06:38

try it again and and open the browser console to find the error

bhauman20:06:09

shift reload

vigilancetech20:06:11

I did the compile hello_world and printed that to the term, but no repl

bhauman20:06:29

what command did you use?

vigilancetech20:06:40

clj -m cljs.main -c hello_world.core -r

bhauman20:06:53

and what printed to the terminal?

bhauman20:06:01

"hello world"?

vigilancetech20:06:16

2x cuz of the reload

bhauman20:06:35

but no REPL?

bhauman20:06:18

where did it print? in the console or the terminal?

bhauman20:06:47

that means a repl connection was made

bhauman20:06:50

do you not see a cljs.user=> in the terminal?

vigilancetech20:06:16

enter in the terminal just gives blank lines

bhauman20:06:37

and hit enter

vigilancetech20:06:06

the 1 echoed when I typed it, but nothing came back

bhauman20:06:02

What OS and shell are you using?

vigilancetech20:06:12

bash and the latest sabayon

bhauman20:06:41

and what browser?

bhauman20:06:37

had to look up sabayon, man one of these days they are simply going to run out of names for linux distros

vigilancetech20:06:59

lol, yeah, well, its been around for while. Well know to gentooists

bhauman20:06:20

I used gentoo way way back when it started

vigilancetech20:06:49

I was on it for a long time, but I got tired of compiling. Sabayon gives you the best of both

bhauman20:06:07

understandable, OK let's try something different

vigilancetech20:06:39

but I want to move to guixSD cuz I'm sick of collisions/corruption like's most likely causing this

bhauman20:06:04

yeah, it sounds like its connected

bhauman20:06:31

We could quickly try a different tack, and try figwheel.main

bhauman20:06:49

it has better feedback mechanisms to help track down problems

vigilancetech20:06:07

put it in the deps.edn?

bhauman20:06:32

just use that as your deps.edn file

bhauman20:06:41

perhaps in a different fresh directory

bhauman20:06:14

let's just try to get a REPL

bhauman20:06:43

by running clojure -m figwheel.main

vigilancetech20:06:42

I think it doesn't like my hostname. My /etc/hostname only has this machine's name and not the domain. Exception in thread "Thread-1" java.net.UnknownHostException: scuttle: scuttle: Name or service not known

vigilancetech20:06:28

I have systemd. IIRC that handles it somehow

vigilancetech20:06:43

obviously *mis*handling in this case 🙂

vigilancetech20:06:50

probably quickest way to get this is to reboot, brb

bhauman20:06:08

I think that is a bug on my end

bhauman20:06:05

if you get it again you should see figwheel.main.cljc line 933 in the stacktrace

vigilancetech20:06:46

the error message is gone but still no repl (using the same code)

bhauman20:06:54

with figwheel.main?

vigilancetech20:06:03

I deleted my bhauman folder out of .m2/repository and re-ran the command

bhauman20:06:23

what output do you get?

bhauman20:06:44

does it look like a REPL is trying to start

vigilancetech20:06:44

Exception in thread "main" java.io.FileNotFoundException: Could not locate figwheel/main__init.class or figwheel/main.clj on classpath.

vigilancetech20:06:59

drops back to the $ prompt

bhauman21:06:11

OK delete your .cpcache

bhauman21:06:19

in your current directory

bhauman21:06:35

since you deleted stuff from the repo

bhauman21:06:55

your .cpcache is preventing the deps from being refetched

bhauman21:06:04

I think I just fixed the java.net.UnknownHostException

vigilancetech21:06:30

IT WORKED!!! Thanks! BTW, I really liked your "Developing ClojureScript With Figwheel" 2015 speech. You should try some open-mic nite stand-up comedy 😄

vigilancetech21:06:03

will I get that version by just deleting your stuff in the .m2?

bhauman21:06:18

not yet 🙂

bhauman21:06:36

I'll release a snapshot soon

bhauman21:06:48

I'm glad its working

vigilancetech21:06:14

so basically my main problem was cuz my host(s) weren't set up properly (and maybe your code wasn't handling it elegantly)?

bhauman21:06:31

yeah I just pushed a commit

bhauman21:06:49

and you can also learn more about figwheel-main there

vigilancetech21:06:19

👍 Thanks again! I have a big deadline monday eve. This will help A LOT!

bhauman21:06:25

and there is a #figwheel-main channel

vigilancetech21:06:07

thx! Looking forward to using this

bhauman21:06:53

yeah in the helper app that pops up it tells you how to create a "build"

👍 4
bhauman21:06:07

well I wish you luck!

richiardiandrea21:06:34

can I compose anync use-fixtures? the ones with :before and :after. Can they be compose-fixtures-ed?

richiardiandrea21:06:13

oh, I am reading "NOTE: Incompatible with map fixtures." in the doc