Fork me on GitHub
#shadow-cljs
<
2019-06-05
>
exit200:06:04

@lilactown after running my main, I’m trying to call (start) in the browser repl

lilactown03:06:10

What namespace?

exit203:06:45

its saying “user” for the ns, but none of my functions are available

lilactown03:06:42

What ns is your functions in?

exit204:06:52

(ns user)

exit204:06:22

which is in dev/server/user.clj

lilactown04:06:49

That's a clj file. Your trying to use it in cljs?

exit204:06:21

yes, I wasn’t sure if that mattered or not

mitchelkuijpers09:06:43

It seems I am running into this bug: https://github.com/thheller/shadow-cljs/issues/502 Does anyone know if there is workaround for this?

thheller09:06:17

depends on the lib that is using that?

thheller12:06:35

try 2.8.38. should work now

mitchelkuijpers12:06:31

Works you are an absolute legend

mitchelkuijpers09:06:08

I am trying to use the readoc React component and I get this error:

Error: Error downloading  
process.nextTick is not a function
    at eval (/js/cljs-runtime/module$node_modules$ono$lib$ono.js:2:90)
    at eval (/js/cljs-runtime/module$node_modules$json_schema_ref_parser$lib$resolvers$http.js:2:397)

TypeError: process.nextTick is not a function
    at Object.nextTick (/js/cljs-runtime/module$node_modules$process_nextick_args$index.js:1:413)
    at addChunk (/js/cljs-runtime/module$node_modules$readable_stream$lib$_stream_readable.js:8:88)
    at readableAddChunk (/js/cljs-runtime/module$node_modules$readable_stream$lib$_stream_readable.js:7:118)
    at exports.IncomingMessage.Readable.push (/js/cljs-runtime/module$node_modules$readable_stream$lib$_stream_readable.js:18:68)
    at eval (/js/cljs-runtime/module$node_modules$stream_http$lib$response.js:3:393)
    at new Promise (<anonymous>)
    at Object.write (/js/cljs-runtime/module$node_modules$stream_http$lib$response.js:3:326)

mitchelkuijpers09:06:14

I am trying to use the redoc React component and I get this error:

Error: Error downloading  
process.nextTick is not a function
    at eval (/js/cljs-runtime/module$node_modules$ono$lib$ono.js:2:90)
    at eval (/js/cljs-runtime/module$node_modules$json_schema_ref_parser$lib$resolvers$http.js:2:397)

TypeError: process.nextTick is not a function
    at Object.nextTick (/js/cljs-runtime/module$node_modules$process_nextick_args$index.js:1:413)
    at addChunk (/js/cljs-runtime/module$node_modules$readable_stream$lib$_stream_readable.js:8:88)
    at readableAddChunk (/js/cljs-runtime/module$node_modules$readable_stream$lib$_stream_readable.js:7:118)
    at exports.IncomingMessage.Readable.push (/js/cljs-runtime/module$node_modules$readable_stream$lib$_stream_readable.js:18:68)
    at eval (/js/cljs-runtime/module$node_modules$stream_http$lib$response.js:3:393)
    at new Promise (<anonymous>)
    at Object.write (/js/cljs-runtime/module$node_modules$stream_http$lib$response.js:3:326)

lxsameer10:06:41

hey folks, is there any way to instruct shadow-cljs to not include a namespace in the final build ?

thheller10:06:08

depends on what you mean by that

thheller10:06:13

:preloads already deal with that

lxsameer10:06:43

let me describe what I'm trying to do

lxsameer10:06:34

I have like several functions in my cljs code, i have a macro which reads a configuration file and create a new function that calls two of these functions in cljs

lxsameer10:06:18

those cljs functions spread through several NSs, in order for the macro to work i need to either require all of those namespaces

lxsameer10:06:53

or i have to be able to manipulate the ns form ( for requirements ) on compile time to avoid having all the functions in the final build

lxsameer10:06:22

now I'm looking for my options to deal with this problem

thheller10:06:52

I don't get it?

thheller10:06:20

I mean why do you need to "un-require" one namespace?

lxsameer10:06:10

to avoid having it in my final build.

thheller10:06:27

but you said the created function needs it?

lxsameer10:06:04

created functions uses only two function out of possible 10 ( based on the configuration ).

lxsameer10:06:43

so for example i have these functions: ns-a/A , ns-b/b, ..... ns-z/Z.

lxsameer10:06:16

I create a function using a macro based on some configuration that may only use two of them

lxsameer10:06:05

since in cljs app i don't know which before hand and I can't manipulate the ns form of the main namespace ( the one which i use the macro in it )

lxsameer10:06:21

i have to require all the namespaces from ns-a to ns-z

lxsameer10:06:40

this way all of them are going to end up in my build

thheller10:06:07

I still don't get it sorry.

thheller10:06:14

why is it a problem that those namespaces are included

lxsameer10:06:21

they're big

thheller10:06:36

what does the macro do that requires functions from separate namespaces?

thheller10:06:02

why are they big?

thheller10:06:14

why not just move the code the macro uses to a "better" place?

lxsameer10:06:28

each of those namespaces are a different SPA application by themselves

thheller10:06:43

would help if you have an example I can look at

lxsameer10:06:02

send you a link

lxsameer10:06:11

this is the macro

lxsameer10:06:28

I included it's expansion in the comment below it as well

lxsameer10:06:04

and here i tried to use the macro

thheller10:06:53

so what I would suggest here is not using a macro in the first place

thheller10:06:14

option a) generate a .cljs files from your config and just compile that file normally

thheller10:06:38

option b) use the build config to control which namespaces go into a build

thheller10:06:57

and have the namespaces "register" themselves in some kind of registry on load

lxsameer10:06:30

a) seems simple and easy, can i do this with preloads ?

lxsameer10:06:46

b) do you mean via modules ?

thheller10:06:51

just do it via a clojure function (completely outside the build process)

thheller10:06:10

b) could be modules but doesn't have to be

lxsameer10:06:37

so can you please explain it a bit more

thheller10:06:00

:modules {:app {:init-fn webman.core/init :entries [webman.page.foo webman.page.bar]}}

thheller10:06:54

(ns webman.page.foo (:require [some.registry :as reg])) (reg/add-page ::foo {:bla "blubb"})

thheller10:06:57

in the build config you just control which namespaces are used in the build

lxsameer10:06:10

so what will happen if webman.core requires a ns which is not in the :app entries ?

thheller10:06:12

and the namespaces sort of configure themselves

thheller10:06:28

it doesn't require anything. thats the point

thheller10:06:33

it never calls anything directly

thheller10:06:44

if calls things only through the registry

thheller10:06:53

registry could be just an atom

lxsameer10:06:02

Ahhhhhh, i got it now

lxsameer10:06:45

thanks a lot man

lxsameer11:06:26

@thheller it's totally possible to alter the build configuration via a hook for :configure stage, right ?

thheller11:06:56

depends on what you mean by alter

thheller11:06:24

you can adjust the configuration yes

lxsameer11:06:03

like adding more entries to a module

thheller11:06:22

yes that would be possible although not really recommended

thheller11:06:03

if you are thinking about doing that I would STRONGLY suggest going with option a) instead

thheller11:06:19

build-hooks are several orders of magnitude more complex than a simple clojure function that spits out something like (ns app.main (:require [foo.bar])) with all the namespaces you are trying to dynamically add

thheller11:06:42

only because you can in theory solve the problem using the build tool doesn't mean you should

lxsameer11:06:27

you have a very good point

thheller11:06:42

you can use the clj-run feature to generate it so shadow-cljs run webman.generate path/to/config.edn path/to/output.cljs

lxsameer11:06:36

thanks for your time man

thheller11:06:56

could of course just run it via clj directly. no need to involve shadow-cljs

thheller11:06:40

but its much easier to verify that the output you wanted is correct just by looking at the generated output

thheller11:06:07

and just compiling it as a normal file will be much more reliable as well

thheller11:06:45

build hooks that deal with configuration aspects always get problematic since you are then responsible to keeping everything in sync

thheller11:06:54

eg. retrigger a recompile if the extra build config changes etc

lxsameer11:06:39

i see what you mean, I'll go with the option A. thanks friend

ShaneLester15:06:34

Anyone else all of a sudden getting Use of undeclared Var cljs.core/destructure-map on compiles today?

Justin19:06:21

Just wonder if you by chance figured this out? I'm also getting the same warnings.

carkh15:06:38

i have a strange behavior here ... In dev mode I require [datascript.transit :as dst] the namespace compiles fine, but when i try to make use of it, it says datascript.transit is null... which it is : (log js/datascript.transit) indeed is null, while (log js/datascript) has the whole datascript namespaces showing

carkh15:06:54

where should i look ?

carkh16:06:24

ok scratch that, that's again the lack of refresh of the extension for added namespaces to a background page

thheller18:06:59

@shanelester55 uhm did I mess something up? I was working on a CLJS patch that changes destructuring a bit

thheller18:06:11

that change was not supposed to be part of the release 😛

thheller18:06:17

hmm where do you get that?

thheller18:06:57

wow yeah the AOT release contained my patched clojurescript version for some reason

thheller18:06:25

sorry about that .. fixed in 2.8.39

stefan19:06:57

If your project uses React 16 and Reagent 0.8.0-alpha2 (or higher) then you will need to add the qualifier -react16 to the version, e.g. [day8.re-frame/re-frame-10x "VERSION-react16"]

ShaneLester19:06:58

awesome, thanks for the quick response. I am giving it a shot right now

stefan19:06:18

Would the syntax for the above be something like in my shadow-cljs.edn

...
:dependencies
 [[day8.re-frame/re-frame-10x "0.4.0-react16"]]
...

stefan19:06:32

I receive an error when I try to build that

stefan19:06:03

cli version: 2.8.37  node: v12.3.1
shadow-cljs - updating dependencies
shadow-cljs - dependency update failed - Could not find artifact day8.re-frame:re-frame-10x:jar:0.4.0-react16 in central ()
DependencyResolutionException Could not find artifact day8.re-frame:re-frame-10x:jar:0.4.0-react16 in central ()
	org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies (DefaultRepositorySystem.java:355)
	sun.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
	sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
	sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke (Method.java:498)
	clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:93)
	clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:28)
	cemerick.pomegranate.aether/resolve-dependencies* (aether.clj:806)
	cemerick.pomegranate.aether/resolve-dependencies* (aether.clj:707)
	clojure.core/apply (core.clj:657)
	clojure.core/apply (core.clj:652)
	cemerick.pomegranate.aether/resolve-dependencies (aether.clj:815)

stefan19:06:29

I’m trying to install re-frame-10x. If I ignore the -react16 qualifier I can see the re-frame-10x panel but it is not reflecting the info in the app-db, it is just empty

stefan19:06:39

ah ok, maybe that instruction doesn’t apply to 0.4.0

devo22:06:05

How do polyfills work with shadow-cljs? Been having an issue recently trying to play around with a browser js dependency from cljs due to a dependency requiring util and stream.

devo22:06:04

actually looks like I can just resolve those from the window. Now running into closure compilation complaints about duplicate classnames in dependencies. Search goes on :man-shrugging:

Justin19:06:21

Just wonder if you by chance figured this out? I'm also getting the same warnings.