Fork me on GitHub
#clojurescript
<
2018-06-04
>
lilactown00:06:16

thereโ€™s something that takes (.-foo-bar! obj) and turns -foo-bar! into "foo_bar_BANG_"

lilactown00:06:31

is there a function that does that transformation?

dpsutton01:06:38

I believe you're looking for munge

8
metacritical01:06:02

Yup thats what he needed!

lilactown01:06:41

awesome thanks

br02:06:57

Hi all, is there an official writeup / explanation of cljs.main anywhere?

br02:06:57

Bruce, you're the bomb, thanks for Figwheel. I was hoping for something more substantive ๐Ÿ™‚

metacritical02:06:58

@benisrood Try figwheel-main you will like it, i just switched yesterday https://github.com/bhauman/lein-figwheel/tree/master/figwheel-main

๐Ÿ‘ 4
br02:06:28

(damn pastebot really doesn't like me)

br02:06:02

I like it, but sometimes โŒ˜-c does not work

metacritical03:06:43

C-c always works.

br03:06:44

I'm not always in Emacs, though ๐Ÿ˜›

br03:06:51

I'm not that far-gone

br03:06:11

It hasn't become my OS (yet)

metacritical04:06:15

๐Ÿ˜‚:rolling_on_the_floor_laughing:

pesterhazy11:06:37

@bhauman just switched to clj+figwheel.main (from lein figwheel), works well for me!

pesterhazy11:06:53

one question, does this give you automatic caching of cljs compiler results?

metacritical13:06:32

@pesterhazy You can have a target directory to output the results by specifying :paths ["target"]

pesterhazy13:06:15

@metacritical so if I add the paths key, code is automatically cached? Where does the key go?

metacritical13:06:36

deps.edn if you use clojure cli tools , in case you use lein https://github.com/bhauman/lein-figwheel/tree/master/figwheel-main

manutter5113:06:22

Transit sits on top of json and encodes/decodes clj data types.

JH14:06:19

Also, I am getting an error when trying to require a node package

rnagpal15:06:13

I upgraded to new version of clojure and clojurescript and when I run lein with-profile test doo chrome-headless test I get this error

Caused by: java.lang.ClassNotFoundException: com.google.javascript.jscomp.ProcessEs6Modules
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

rnagpal15:06:07

Here are my dependencies

:dependencies [[org.clojure/clojure "1.9.0"]
                 [org.clojure/clojurescript "1.10.238"]

dnolen15:06:02

@rnagpal something is pulling in the wrong Google Closure dep, check your dep tree

rnagpal15:06:34

[org.clojure/clojurescript "1.10.238" :exclusions [[cljsjs/react-with-addons] [cljsjs/create-react-class] [cljsjs/react-dom-server] [cljsjs/react-dom] [cljsjs/react]]]
   [com.cognitect/transit-clj "0.8.300" :exclusions [[org.clojure/clojure]]]
     [com.cognitect/transit-java "0.8.324"]
       [com.fasterxml.jackson.core/jackson-core "2.8.7"]
       [commons-codec "1.10"]
       [org.msgpack/msgpack "0.6.12"]
         [com.googlecode.json-simple/json-simple "1.1.1" :exclusions [[junit]]]
         [org.javassist/javassist "3.18.1-GA"]
   [com.google.javascript/closure-compiler-unshaded "v20180204"]
     [args4j "2.33"]
     [com.google.code.findbugs/jsr305 "3.0.1"]
     [com.google.code.gson/gson "2.7"]
     [com.google.errorprone/error_prone_annotations "2.0.18"]
     [com.google.guava/guava "22.0"]
       [com.google.j2objc/j2objc-annotations "1.1"]
       [org.codehaus.mojo/animal-sniffer-annotations "1.14"]
     [com.google.javascript/closure-compiler-externs "v20180204"]
     [com.google.jsinterop/jsinterop-annotations "1.0.0"]
     [com.google.protobuf/protobuf-java "3.0.2"]
   [org.clojure/data.json "0.2.6"]
   [org.clojure/google-closure-library "0.0-20170809-b9c14c6b"]
     [org.clojure/google-closure-library-third-party "0.0-20170809-b9c14c6b"]
`

rnagpal15:06:54

@dnolen [com.google.javascript/closure-compiler-unshaded "v20180204"] are you referring to this

dnolen15:06:15

looks like a version conflict to me

rnagpal15:06:41

Robins-MacBook-Pro-3: rnagpal$ lein deps :why "com.google.javascript/closure-compiler-unshaded"
 [org.clojure/clojurescript 1.10.238]
   [com.google.javascript/closure-compiler-unshaded v20180204]

rnagpal16:06:21

I see reference to ProcessES6Modules in

rnagpal16:06:10

but not in v1.10 and that is what I am using

pesterhazy16:06:21

try lein deps :tree to inspect the jars that you're pulling in

bhauman16:06:40

@pesterhazy did you resolve your question?

bhauman16:06:46

about figwheel.main

pesterhazy16:06:03

@bhauman I don't think so, I was wondering whether compilation caching is enabled by default with figwheel.main

bhauman16:06:21

it depends on how you are using it

pesterhazy16:06:33

I'm using it as described in the readme

pesterhazy16:06:39

{:deps {org.clojure/clojurescript {:mvn/version "1.10.238"}
        reagent {:mvn/version "0.7.0"}
        data-frisk-reagent {:mvn/version "0.4.5"}
        com.bhauman/figwheel-main {:mvn/version "0.1.0-SNAPSHOT"}
        com.bhauman/rebel-readline-cljs {:mvn/version "0.1.3"}}
 :paths ["src" "target" "resources"]}

pesterhazy16:06:10

and then clojure -m figwheel.main -b dev -r

bhauman16:06:17

if you are doing -b dev -r with that setup yes it caches results

bhauman16:06:25

basically if you have a stable target directory and build id i.e. "dev" you are going to get incremental compiles

bhauman16:06:45

and you will need to clean rm -rf target

bhauman16:06:03

if you change a library version or something

pesterhazy16:06:32

so even if I restart figwheel.main, it will still reuse pervious compiler output?

bhauman16:06:44

no auto cleaning

pesterhazy16:06:56

So far using figwheel.main has been smooth! The only thing I didn't figure out immediately was, when I started using my own index.html, to know what script tag url I had to add. It turned out to be <script src="cljs-out/dev-main.js"></script> @bhauman

bhauman16:06:07

@pesterhazy yes I'm wanting to make that more apparent, I got bogged down by try to provide a definitive answer for that given all the different configurations available

bhauman16:06:22

but I should provide the default path at least

pesterhazy16:06:43

I didn't realize it would include the build-id in the filename

bhauman16:06:14

have you tried the -pc arg? its pretty darn helpful when your about curious whats going on

pesterhazy16:06:07

yeah, it's helpful

pesterhazy16:06:29

I was confused for a bit because clojure -m figwheel.main -b dev -pc -r didn't work (you need to move -pc before -b dev)

bhauman16:06:13

yeah because -b is a main opt

bhauman16:06:58

its really hard to provide helpful feedback for all the cli error cases

pesterhazy16:06:00

I understand. It's just that people aren't used to the order of positional arguments mattering

bhauman16:06:13

yeah its semantically difficult

bhauman16:06:29

but it is the same as clojure proper

pesterhazy16:06:42

I also remember that Rich Hickey argues against positional fn parameters, and in favor of keyword args ๐Ÿ™‚

pesterhazy16:06:14

I'm not serious, I know it's not a figwheel.main issue

bhauman16:06:44

@pesterhazy btw I got testing in cljs working pretty quickly with figwheel.main

bhauman16:06:50

very little hassle

pesterhazy16:06:04

testing as in running unit tests?

bhauman16:06:04

both auto testing and one off

bhauman16:06:35

Jesus microsoft is buying github!!

pesterhazy16:06:49

the blue banner of death

bhauman16:06:45

here's an example of a test setup

bhauman16:06:14

leiningen isn't neccessary

bhauman16:06:14

it needs some more work, the --main method needs to support async, and it needs to be able to signal exit(1) for CI platforms, and figwheel.main needs to support chrome-headless

rnagpal19:06:45

I have two projects 1) Styles + Basic components 2) Complex components I want to copy less files as it is from 1 to 2 I have a lein plugin that copies the files from with jar to the project So I want the less files to be copied to the jar. They solution which I found for this is to use resource-paths. But if I mention less in resource paths its copies it as exploded

rnagpal19:06:24

I want it to the less folder to be copied as less straightaway

rnagpal19:06:44

what are the options apart from using resource-paths ?

Garrett Hopper21:06:10

So I copied a regex from some javascript code, and it doesn't work in ClojureScript, because it has an escaped /. (re-find #"\/" "/") This works in Clojure, but in ClojureScript the \ gets double escaped.

ClojureScript 1.10.238
cljs.user=> (re-find #"\/" "/")
repl:1
(function (){try{return cljs.core.pr_str((function (){var ret__6387__auto__ = cljs.core.re_find.call(null,/\\//,"/");
                                                                                                               ^

darwin21:06:33

well, this behaves differently on my mac with 1.10.238

darwin21:06:07

`cljs.user=> (.toString (fn [] (re-find #โ€œ/โ€ โ€œ/โ€))) โ€œfunction (){\nreturn cljs.core.re_find.call(null,/\\//,\โ€œ/\โ€œ);\n}โ€œ`

darwin21:06:31

`cljs.user=> (re-find #โ€œ\/โ€ โ€œ/โ€) SyntaxError: Unexpected token , (<NO_SOURCE_FILE>) clojure$browser$repl$evaluate_javascript (clojure/browser/repl.cljs:118:4) ...`

Garrett Hopper21:06:25

What's different about it?

cljs.user=> (.toString (fn [] (re-find #"\/" "/")))
repl:2
return cljs.core.re_find.call(null,/\\//,"/");
                                        ^

SyntaxError: Unexpected token ,
    at new Script (vm.js:51:7)
    at createScript (vm.js:136:10)
    at Object.runInThisContext (vm.js:197:10)
    at Domain.<anonymous> ([stdin]:76:38)
    at Domain.run (domain.js:323:14)
    at Socket.<anonymous> ([stdin]:73:29)
    at Socket.emit (events.js:180:13)
    at Socket.emit (domain.js:422:20)
    at addChunk (_stream_readable.js:274:12)
    at readableAddChunk (_stream_readable.js:257:13)

darwin22:06:39

several problems: 1) it looks to me that your repl swallowed the syntax error, 2) the javascript code you presented was also generated from #โ€œ/โ€ and that looks correct to me

Garrett Hopper22:06:08

#"/" is fine; #"\/" isn't.

darwin22:06:34

yes, from the behaviour here, it looks like #"\/" produces broken javascript

Garrett Hopper22:06:53

Ok, so it's not different on mac?

darwin22:06:22

ah, now when Iโ€™m looking at your snippet you posted, there is a syntax error, see the hanging ^ there

darwin22:06:07

it behaves the same, only from your post it wasnโ€™t obvious, I thought it just generated /\\//

Garrett Hopper22:06:34

:thumbsup: The issue is that \ is getting escaped to \\, so the / isn't escaped which ends the regex.

darwin22:06:04

as I presented in the first example, the \\ is generated because of / alone

Garrett Hopper22:06:25

Oh... Sorry, I'm following now.

darwin22:06:00

in the broken case of #โ€œ\/โ€ we are probably dealing with some hidden characters, that is confusing us

darwin22:06:35

not sure what cljs compiler generated there, but would be worth looking at physically generated file and its characters I guess

darwin22:06:54

just my $.02

Garrett Hopper22:06:48

Yeah, I'm having trouble following the second regex. :man-shrugging: Oh well; it's an easy workaround. I just figured I'd report it.

darwin22:06:24

wait, now when Iโ€™m looking at it again, my examples are busted, the .toString is showing a string which contains another layer of escaping

darwin22:06:00

I didnโ€™t know how to turn on generated code printing in my repl

darwin22:06:13

ok, now it shows `cljs.user=> (fn [] (re-find #โ€œ/โ€ โ€œ/โ€)) #object[ret__6387__auto__ โ€œfunction (){ return cljs.core.re_find.call(null,/\//,โ€œ/โ€); }โ€œ]`

darwin22:06:25

so I take back my words, you were correct, \ gets emitted into js regex as is and causes unwanted escape of the following character

Garrett Hopper22:06:56

Oh, right; I was thinking it was the other way around. I thought the \ got escaped, but the / didn't.

Garrett Hopper22:06:15

Alright, it's an issue with the Clojure compiler using java.util.regex.Pattern to get the pattern. (re-find #"\/" "/") works fine in self-hosted cljs.

Garrett Hopper21:06:43

This isn't a big deal, because the / doesn't need to be escaped, but I assume this kind of thing shouldn't happen.