Fork me on GitHub
#clojurescript
<
2017-08-21
>
jrychter01:08:46

@anmonteiro I'll try to figure out how to use it and get some results.

anmonteiro01:08:11

@jrychter npm install -g source-map-explorer

anmonteiro01:08:20

then just point it at your advanced compiled files

anmonteiro01:08:31

source-map-explorer my-bundle.js my-bundle.js.map

anmonteiro01:08:40

take a screenshot of both for me

anmonteiro01:08:32

(assuming you have :output-to "my-bundle.js" :source-map "my-bundle.js.map" :optimizations :advanced in your CLJS compiler options)

jrychter01:08:20

I think my advanced compilation settings do not produce a map file. But that should be easy to add.

anmonteiro01:08:49

must be a pain to debug runtime errors in prod for you

jrychter01:08:09

I don't 🙂

jrychter01:08:40

Well that is actually a really nice tool. Thanks for introducing me to this. Working on the reports now.

jrychter01:08:03

Unfortunately, the results (at least the HTML visualization) seem suspect. I can't see some of the modules in there. Anyway, I'll DM the details.

iku00088807:08:08

Are there things to check when you have a macros.clj name space (which contains macros) but you get a

WARNING: No such namespace: macros, could not locate macros.cljs, macros.cljc, or JavaScript source providing "macros" at line 1400 /home/ikuchan/fun/schema/src/cljx/schema/core.cljc

iku00088807:08:03

I was trying to move schema to cljc and got stuck while trying to remove the warnings

miikka09:08:13

Hey, I'm trying upgrade to ClojureScript 1.9.908 from 1.9.660 and when doing advanced compilation with :infer-externs true, I'm getting this NPE from Closure.

java.lang.Thread.run              Thread.java:  748
           java.util.concurrent.ThreadPoolExecutor$Worker.run  ThreadPoolExecutor.java:  617
            java.util.concurrent.ThreadPoolExecutor.runWorker  ThreadPoolExecutor.java: 1142
                          java.util.concurrent.FutureTask.run          FutureTask.java:  266
         com.google.javascript.jscomp.CompilerExecutor$2.call    CompilerExecutor.java:  101
                 com.google.javascript.jscomp.Compiler$3.call            Compiler.java:  830
                 com.google.javascript.jscomp.Compiler$3.call            Compiler.java:  834
   com.google.javascript.jscomp.Compiler.performOptimizations            Compiler.java: 2421
          com.google.javascript.jscomp.PhaseOptimizer.process      PhaseOptimizer.java:  231
com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process      PhaseOptimizer.java:  305
  com.google.javascript.jscomp.DefaultPassConfig$57$1.process   DefaultPassConfig.java: 2154
          com.google.javascript.jscomp.ProcessDefines.process      ProcessDefines.java:  120
  com.google.javascript.jscomp.ProcessDefines.overrideDefines      ProcessDefines.java:  134
java.lang.NullPointerException: 
    clojure.lang.ExceptionInfo: 
    from: :boot-cljs
    clojure.lang.ExceptionInfo: 
    line: 190

kommen15:08:14

I’m running into the same issue. filed an issue here: https://github.com/google/closure-compiler/issues/2629

kommen15:08:37

and just now found your message here

miikka06:09:52

Hey, thanks for notifying me about this!

miikka09:08:34

Anyone have seen this before? It goes away if I disable :infer-externs

udit09:08:31

Hey there! X-posting from #testing I know how to write tests in clojure(script) however I am not so sure on what to test, especially on the frontend side of things. What are the typical things that one should test in a Clojurescript app? I have a cljs app which uses reagent which has unit tests in place for the API calls. What other things should I unit test for? What things should be tested end to end (Components? JS library integration?) Should components have unit tests? If so how do I go about them

iku00088809:08:48

@udit Only a partial answer to your question, but this is a good tool for unit testing components https://github.com/bhauman/devcards

udit13:08:07

Thanks @iku000888 Have gone through this and seems interesting to setup. However this answers the “How to test” part and not “What to test”

akiroz11:08:10

hello~ I was trying to use npm-deps when I encountered this error when compiling:

TypeError: Path must be a string. Received { './locale-data/complete': false, './locale-data/complete.js': false }
    at assertPath (path.js:28:11)
    at Object.join (path.js:1239:7)
    at Deps.<anonymous> ([eval]:115:32)
    at emitOne (events.js:115:13)
    at Deps.emit (events.js:210:7)
    at <my project>/node_modules/@cljs-oss/module-deps/index.js:338:18
    at onresolve (<my project>/node_modules/@cljs-oss/module-deps/index.js:198:14)
    at <my project>/node_modules/@cljs-oss/module-deps/index.js:192:17
    at onpkg (<my project>/node_modules/@cljs-oss/module-deps/index.js:542:27)
    at <my project>/node_modules/@cljs-oss/module-deps/index.js:539:44
Any idea how to find out which JS file it was processing when this happened? Does this error mean someone passed an object to the js require()?

mfikes12:08:24

@iku000888 On line 82 you are unconditionally requiring [schema.macros :as macros]

mfikes12:08:53

(I think perhaps you want to delete that line… it wasn’t in the original implementation.)

alex-dixon15:08:19

Anyone have a general idea about the performance of read-string?

noisesmith15:08:52

if perf matters, there are good alternatives (eg. transit) that are meant to be fast

anmonteiro16:08:22

@akiroz sorry for your trouble, that's fixed in master

amitayh16:08:20

added explanations: a purely functional cljs app with the elm architecture https://github.com/amitayh/elm-cljs

borkdude16:08:03

Maybe a naive question, but it is possible to get this package with the usages of other packages inlined, as one standalone js file? https://github.com/d3/d3-force We are using d3 version 3.5, but I can get away with using a new function from 4, although we would like to keep imported code from 4 as little as possible. Since d3 version 4 splits everything in modules, this opens up maybe importing only a little bit.

djanus17:08:48

@anmonteiro with current cljs master (1.9.916), I'm getting the following while trying to build an app that uses react-dnd:

WARNING: JSC_JS_MODULE_LOAD_WARNING. Failed to load module "./raw" at /home/nathell/projects/toy/node_modules/asap/browser-asap.js line 4 : 4

djanus17:08:04

I'm thinking that the npm-deps interop doesn't (yet?) support libraries doing relative requires, is that right?

juhoteperi17:08:50

@djanus Probably not. Asap uses browser field to replace files in browser use (https://github.com/kriskowal/asap/blob/master/package.json#L19), and current Closure release doesn't yes support this, but it will in the next version: https://github.com/google/closure-compiler/pull/2604

djanus17:08:15

@juhoteperi Awesome, thanks! It's interesting, though, that it already mentions browser-asap.js in the warning

juhoteperi17:08:01

@djanus IIRC Closure releases snapshot version nightly, so you could try adding [com.google.javascript/closure-compiler-unshaded "1.0-SNAPSHOT"] dep to your project and see if that helps, not sure if Cljs already has the necessary changes for this

anmonteiro17:08:08

@juhoteperi that’s actually released in Closure

anmonteiro17:08:16

1.9.908 has browser field support

anmonteiro17:08:30

I’ll try out that package later

juhoteperi17:08:08

Hmh, okay, I didn't see it was included in the release as I was looking at the orginal commit, and the Closure versioning is confusing.

anmonteiro17:08:56

they cut a Maven release that has more commits than the other one

anmonteiro17:08:16

@djanus I do see a bug here, thanks for bringing this up

djanus17:08:12

@anmonteiro thanks for looking at this. Anything I can do to help out?

anmonteiro17:08:32

@djanus maybe try a patch once I figure it out 🙂

anmonteiro17:08:36

looking into it

anmonteiro18:08:40

I suspect there’s a bug in the Closure Compiler now though

anmonteiro18:08:26

I’ll look into that in Closure soon. I just submitted a patch during the weekend that should make it easier to fix (https://github.com/google/closure-compiler/pull/2622)

djanus18:08:51

@anmonteiro I've applied the patch, and it doesn't fix the problem for me. Here's my full build log:

[email protected]:/tmp/gridlock$ lein cljsbuild once
Compiling ClojureScript...
Compiling ["target/cljsbuild/public/js/app.js"] from ["src/cljs"]...
WARNING: JSC_JS_MODULE_LOAD_WARNING. Failed to load module "./raw" at /tmp/gridlock/node_modules/asap/browser-asap.js line 4 : 4
WARNING: JSC_JS_MODULE_LOAD_WARNING. Failed to load module "./raw" at /tmp/gridlock/node_modules/asap/browser-asap.js line 4 : 14
WARNING: JSC_JS_MODULE_LOAD_WARNING. Failed to load module "asap" at /tmp/gridlock/node_modules/dnd-core/lib/HandlerRegistry.js line 19 : 4
WARNING: JSC_JS_MODULE_LOAD_WARNING. Failed to load module "asap" at /tmp/gridlock/node_modules/dnd-core/lib/HandlerRegistry.js line 19 : 12
WARNING: Protocol IFn implements method -invoke with variadic signature (&) at line 61 target/cljsbuild/public/js/out/reagent/impl/util.cljs
Successfully compiled ["target/cljsbuild/public/js/app.js"] in 19.171 seconds.
The project is at https://github.com/nathell/gridlock if you'd like to try it out. Checkout the npm-deps branch and do a lein cljsbuild once

anmonteiro18:08:42

@djanus the module load failures are expected

anmonteiro18:08:50

that’s the Closure Compiler bug I’m referring to

richiardiandrea20:08:40

Javascript module interop question, what would be the way, with the new Cljs, to require BasicParser in https://www.npmjs.com/package/posix-getopt ?

richiardiandrea20:08:28

I am trying (require '"posix-getopt/BasicParser") but it is complaining and I am guessing it is not the right way

noisesmith20:08:30

'"foo" is pretty weird = ' prevents evaluation, and strings already self-evaluate

mfikes20:08:56

Yeah, you should arguably be able to do (require ['clojure.set :as 'set]) if you wanted to as well. Things are just presuming a certain pattern right now.

noisesmith20:08:03

wow, TIL - cljs is weird sometimes

mfikes20:08:19

It cut corners in implementation, IMHO

anmonteiro20:08:43

@richiardiandrea (:require [posix-getop :as go])

anmonteiro20:08:51

then use go/BasicParser

anmonteiro20:08:08

BasicParser is an export, not a module inside the package

richiardiandrea20:08:44

this works too, which is great: (require '[posix-getopt :refer [BasicParser]])

anmonteiro20:08:48

yeah, forgot about that one

bendlas22:08:29

Has anybody tried http://prepack.io on a larger cljs project? I've just tried it on hello world ... it is achieving optimal dead-code removal when logging a string and it even manages to shave off 3K from logging a vector.

bendlas22:08:09

I'll try it on my react project tomorrow.

anmonteiro22:08:10

@bendlas I tried it in Lumo

anmonteiro22:08:32

I have a branch where it was working at some point: https://github.com/anmonteiro/lumo/tree/prepack

bendlas22:08:00

@anmonteiro I guess binary size is not a primary concern for lumo, but did you measure any space savings by chance?

bendlas22:08:38

they have made definite progress, though. last time i checked, prepack couldn't even compile clojurescript

anmonteiro22:08:36

@bendlas right it was about startup time but it didn’t help much

anmonteiro22:08:08

if you see the commit in that branch I had to wrap some CLJS code in functions for Prepack to run on the codebase

anmonteiro22:08:26

I haven’t looked at it in a while though

bendlas22:08:41

oh, that's what those wrappers are for