Fork me on GitHub
#shadow-cljs
<
2020-08-04
>
robert-stuttaford07:08:22

curious @thheller -- if somehow a module ended up having exactly the same code in it between two builds, will the resultant js cache between builds as well? or does shadow/cljs/gclosure do something to prevent it from being the same bytes/etag/whatever

thheller07:08:47

@robert-stuttaford it is somewhat unlikely for modules to be compatible between builds. it can happen but I wouldn't rely on it.

robert-stuttaford07:08:18

thought as much; just thought i'd confirm it with you

robert-stuttaford07:08:30

well done on modules, by the way. it's fantastic

thheller07:08:22

given hot macros work with (gensym) and foo# they may be using different names in each build, which then may get different names in :advanced and so on

thheller07:08:31

:modules is why all this exists in the first place 😉

EmmanuelOga08:08:02

sup! is there any guidance around using node 12 vs 14?

EmmanuelOga08:08:13

shadow docs just say "(v6.0.0+, most recent version preferred)"

thheller08:08:24

any issues with either? it pretty much shouldn't matter at all?

EmmanuelOga08:08:01

well.... hahah yeah there are issues on my system, but who knows may be completely unrelated. I installed nodejs with scoop on windows then copy the shadow-cljs.edn file from the front page of shadow site, then npm install sahdow, etc... I just get a single error "? ? is not ISeqable", so kind of those impenetrable messages that don't really tell you much. So I began wondering if the node version mattered. Anyway, I removed the scoop node and I'm trying the official installer see if it makes any difference

EmmanuelOga08:08:47

I suspect is more of a problem of how my system is configured more than any shadow issue, but yeah I was wondering if 12 v 14 made any difference

thheller08:08:20

node does not make a difference regarding shadow-cljs

thheller08:08:39

it may make a difference for the code you are running on it

thheller08:08:16

its not that impenetrable error message wise

EmmanuelOga08:08:06

this is what I saw:

EmmanuelOga08:08:23

also found it suspicious that shadow had those "..." instead of actual help

thheller08:08:45

I guess I never tried to handle a typo?

EmmanuelOga08:08:38

the command line help typo is not the actual problem I think

EmmanuelOga08:08:41

here's a better example:

thheller08:08:46

thats odd indeed. I'd guess that there are maybe some invalid "hidden" chars in the config?

EmmanuelOga08:08:24

hmmm yeah, let me try delete the file and try copy-paste again from the front page

thheller08:08:57

there was a command to easily show such things but I can't remember what it was

thheller08:08:20

if you send me the actual file I can check it out

thheller08:08:38

and maybe improve the error message in the process

EmmanuelOga08:08:03

noooo just deleted it, yeah that was the problem, I think the file had the wrong encoding. So nothing to do with the nodejs scoop installed

EmmanuelOga08:08:16

maybe I can replicate that file... let me try

EmmanuelOga08:08:12

TF I think my emacs is loosing it

EmmanuelOga08:08:15

ok cool, there's something wrong with my emacs. I could replicate the file.

thheller08:08:40

$ cat shadow-cljs.edn
��{:source-paths ["src"]
 :dependencies [[reagent "0.8.1"]]
 :builds {:app {:target :browser
                :output-dir "public/js"
                :asset-path "/js"
                :modules {:main {:init-fn app.main/main!}}}}}

thheller08:08:18

thx. can reproduce the error, will try to improve it 😛

👍 3
EmmanuelOga08:08:55

thx! was really jarring, although it was my mistake, I'm sure it can help other ppl too

Old account08:08:57

how you run re-frisk on react native? :thinking_face:

EmmanuelOga08:08:25

I know nothing on the subject but it seems like the readme has some info: https://github.com/flexsurfer/re-frisk#react-native-electron-or-web-applications

👍 3
thheller10:08:49

@stebokas I think you better ask those questions in #react-native.

✔️ 3
Mikko Harju12:08:24

I'm experiencing some weird issues with classpath override.. We basically have overridden a library with our own patches in src that shadow-cljs has previously used instead of the sources from the library. Now I'm getting:

[2020-08-04 14:47:11.441 - INFO] duplicate resource graphql_builder/generators/shared.cljc on classpath, using file:/Users/harri/.gitlibs/libs/floatingpointio/graphql-builder/7e8311225d5595e4456b8fd6338b127a80b7aab6/src/graphql_builder/generators/shared.cljc over file:/Users/harri/Development/hesburger/core-client/src/graphql_builder/generators/shared.cljc
for each of the overridden files, and they are not patched. This is only affecting 1 machine out of 4 working ones.

Mikko Harju12:08:01

We are not getting this INFO notice in our other dev machines.

Mikko Harju12:08:24

clj -Spath returns a proper classpath, but it is in a different order

Mikko Harju12:08:53

my machine for instance, has src:test:.... and in the failing machine, they are somewhere in the middle

thheller12:08:26

maybe different tools.deps versions?

Mikko Harju12:08:35

Nope. 1.3.2 in all machines...

Mikko Harju12:08:56

I removed .cpcache and other suspects as well, but still it produces them in a different order.

Mikko Harju13:08:29

I am so baffled by this. What can it be 😄

Mikko Harju13:08:51

Oh... clojure got an update when I upgraded it from homebrew...

Mikko Harju13:08:10

depends in openjdk14 and all that... maybe this is the root cause?

Mikko Harju13:08:43

Nope. Still works on my machine 😞

Mikko Harju13:08:34

Now the classpath is "messed up" similarly on my machine as well but it does not produce that error on conflict

thheller13:08:06

no clue. if you use deps.edn then that is solely responsible for constructing the classpath and nothing shadow-cljs does affects that

Mikko Harju13:08:02

This is just one of those days...

Mikko Harju13:08:45

I just removed the updates we had made, and put them to a new branch in our fork and refer to that new SHA in deps.edn. Now it works, but if we want to use that feature again this will have to be revisited...

kommen12:08:08

is there a way to dissoc build options via the :`config-merge` option? use case: for the release build, we have set up ns-aliases. but for a specific release build, I want to remove one of those ns-aliases

thheller12:08:51

@kommen there is not currently

kommen13:08:47

ok, thanks

kommen13:08:54

will look for another solution then

kommen07:08:37

fwiw: I’m now using a build hook for the :configure stage to bend the configuration of the release build to my will. the hooks really provide a lot of flexibility @thheller, very nice!

awb9919:08:05

I just upgraded shadow-cljs from nashorn-js to graal-js and now I am getting problems in the compiled bundles. Compilation works, but vega npm dependencies cannot load when used in in transient project. this is the package that was making problems with polyfills (buffer / process) before. Is there any change in regards to this with the graal versions?

awb9919:08:39

shadow-cljs - failed to load 131 main.js:10793:82 shadow-cljs - failed to load 133 main.js:10793:82

awb9919:08:17

It works in my project where I use shadow dev server

awb9919:08:27

but when I use jetty it does not work

awb9919:08:54

I have two projects: gorilla-ui

awb9919:08:12

which uses vega modules and shadow dev server

awb9919:08:26

and notebook-ui which uses gorilla-ui

awb9919:08:30

and uses jetty.

thheller19:08:59

looks like a polyfill issue. not sure why you are suspecting graal-js

thheller19:08:09

jetty also isn't relevant

awb9919:08:11

I juess the issue is elated to either transient dependencies that use vega, OR jetty vs shadow dev server

awb9919:08:32

I had it working.

awb9919:08:42

and I only updated to new shadow version.

thheller19:08:51

ok .. start with that next time 😛

awb9919:08:03

what is the best pproach?

thheller19:08:10

this is :target :browser?

awb9919:08:17

add buffer and process to deps.cljs ?

awb9919:08:23

target browser

thheller19:08:40

as long as you have shadow-cljs installed IN THE PROJECT

thheller19:08:50

you do not need to worry about process or buffer at all

thheller19:08:21

you can fix this easily by bumping :compiler-options {:output-feature-set :es6} or whatever language level is appropriate

thheller19:08:44

:es8 is good if you have bunch of async/await code in libs

awb9919:08:12

testing...

awb9919:08:16

many thanks!

awb9919:08:31

Your new version works like charm BTW!

awb9919:08:41

It feels 5x faster

awb9919:08:58

I LOVE it!

awb9919:08:57

Thank you so much for your work!

awb9920:08:07

I honestly have no idea how you do it!

awb9920:08:18

New versions all the time

awb9920:08:22

plus new features

awb9920:08:35

I have only one explaination you must be an alien!

awb9920:08:26

compiler optionsdoes not fix it.

awb9920:08:43

I guess I have to remove all buffer and process dependencies in all parent projects...

awb9920:08:51

This will take a while...

awb9920:08:33

shadow-cljs - watching build :webly [:webly] Configuring build. [:webly] Compiling ... [:webly] Build failure: The required JS dependency "buffer" is not available, it was required by "node_modules/vega-loader/build/vega-loader.js". Dependency Trace: demo/app.cljs pinkgorilla/ui/default_renderer.cljs pinkgorilla/ui/data/vega.cljs node_modules/vega-embed/build/vega-embed.js node_modules/vega/build/vega-node.js node_modules/vega-dataflow/build/vega-dataflow.js node_modules/vega-loader/build/vega-loader.js Searched for npm packages in: /home/andreas/Documents/gorilla/gorilla-ui/node_modules See: https://shadow-cljs.github.io/docs/UsersGuide.html#npm-install

awb9920:08:45

Now I have compile errors

awb9920:08:51

before I had runtime error

awb9920:08:32

{:lein {:profile "+demo"}, :dev-http {9000 {:handler http://demo.app/handler}}, :http {:port 9001, :host "localhost"}, :nrepl {:port 9002}, :builds {:webly {:target :browser, :output-dir "target/webly/public", :asset-path "/r", :modules {:main {:entries [http://demo.app]}}, :compiler-options {:optimizations :simple :output-feature-set :es8 }}, :ci {:target :karma, :output-to "target/ci.js", :ns-regexp "-test$"}}}

awb9920:08:05

I have removed .shadow-cljs , node-modules and target

awb9920:08:23

to be sure that I am starting from a clean slate

awb9920:08:38

so only :output-feature set without package.json including shadow-cljs does NOT work.

thheller20:08:07

never said that it should

thheller20:08:52

installing shadow-cljs in the project ensures that all node polyfills are available so it should always be done

thheller20:08:09

new version should even be warning when its not

awb9920:08:08

so what is the difference with output-feature set ?

awb9920:08:27

Perhaps this feedback is helpful to you:

awb9920:08:45

I struggled in understanding shadow-cljsjs and shadow-cljs

awb9920:08:02

with some learning I remember why I need cljsjs

awb9920:08:09

But when I update dependencies

awb9920:08:21

whn I update shadow-cljs dependency version,

awb9920:08:38

it is VERY easy to forget that I have to update shadow-cljs not only in project.clj but also in package.json.

awb9920:08:45

I think this is a potential problem

awb9920:08:51

because it is not easy to see it.

thheller20:08:53

well its your choice to use project.clj not mine

thheller20:08:51

its also not super critical to keep the versions in sync. the package.json version can stay older usually, just need to have it at all.

thheller20:08:44

:output-feature-set controls which JS features are transpiled away

awb9920:08:06

the other problem is,

thheller20:08:14

the higher version you set the more modern browser is required to run it

thheller20:08:35

whereas "modern" is something like 3 years old ...

awb9920:08:00

when I update deps.cljs to "shadow-cljs" "^2.10.19"

awb9920:08:13

then in projects that depend on this project

awb9920:08:30

they will not update the package.jsn to the new version

thheller20:08:39

deps.cljs has nothing to do with this and shadow-cljs should *NEVER* be in there

thheller20:08:09

I actually mean never. I may make it a hard error if it finds it in there.

thheller20:08:22

thats like saying clojure depends on leiningen

awb9920:08:27

otherwise transitive dependencies do not flow throygh

awb9920:08:19

it is a little different for my usecase

thheller20:08:40

no it isn't

awb9920:08:44

I need to make it easy for notebook users to add their cljs / npm deps to the notebook

thheller20:08:47

shadow-cljs is not a transitive dependency

thheller20:08:59

I'm not joking here. I will add a check that deps.cljs does not contain shadow-cljs if I find that becoming a thing.

awb9920:08:15

I would like to manage the npm deps only via deps.cljs

awb9920:08:49

The whole thing of maven + npm

awb9920:08:56

is already complicated enough.

thheller20:08:01

yes I understand that but deps.cljs is not the place to do this for shadow-cljs

awb9920:08:12

And in deps.edn I can add comments (a HUGE plus)

thheller20:08:19

just run npm install shadow-cljs when the notebook CLJ launches or whatever

thheller20:08:37

(if not already in package.json)

awb9920:08:00

thanks for making this clear!

awb9920:08:09

your order has been obeyed 🙂

👍 3
benny21:08:28

Trying to test my project and I’m getting the following, any suggestions where to look?

❯ shadow-cljs compile test
shadow-cljs - config: /Users/benny/projects/client/shadow-cljs.edn
shadow-cljs - connected to server
[:test] Compiling ...
========= Running Tests =======================
SHADOW import error /Users/benny/projects/client/.shadow-cljs/builds/test/dev/out/cljs-runtime/shadow.js.shim.module$$react_navigation$native.js
/Users/benny/projects/client/node_modules/react-native/index.js:13
import typeof AccessibilityInfo from './Libraries/Components/AccessibilityInfo/AccessibilityInfo';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:1047:16)
    at Module._compile (internal/modules/cjs/loader.js:1097:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Module.require (internal/modules/cjs/loader.js:1019:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/Users/benny/projects/client/node_modules/@react-navigation/native/lib/commonjs/useBackButton.tsx:2:1)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
===============================================
[:test] Build completed. (164 files, 163 compiled, 0 warnings, 7.45s)

thheller21:08:38

you cannot import regular react-native packages without running through metro

thheller21:08:01

only the :target :react-native works for react-native

thheller21:08:24

no clue what to do testing with react-native

benny21:08:36

ok, so just to clarify, there’s no known way to test react native with shadow?

thheller22:08:51

I don't know any. I'm sure there are but I don't use react-native so I have no clue how testing works there

thheller22:08:09

whatever works with other tools will also work with shadow-cljs

benny22:08:30

i’ll check over in #cljsrn thanks @thheller

benny22:08:52

is there a way to break out the tested code so to ignore the rn-specific code during test execution?

benny22:08:35

one way would be to use a different source root for tests, but afaik you can only set the source root at the project root which breaks that theory

thheller22:08:51

don't know what you mean

benny22:08:21

if i just want to test re-frame code for example, is there a way i could make my test target compile and test just that code?

thheller22:08:53

that depends on your code

thheller22:08:16

if its all in namespaces that don't otherwise use react-native stuff then sure

benny22:08:50

how would i configure shadow to look only at those namespaces though?

benny22:08:12

this isn’t legal:

:test
          {:target    :node-test
           :source-paths ["src/client/re-frame" "test"]
           :output-to "out/node-tests.js"
           :autorun   true}

thheller22:08:11

source-paths are not relevant for what you are trying to do

thheller22:08:21

shadow-cljs ONLY includes files that are directly referenced somewhere

thheller22:08:39

it doesn't matter if files are other files on the classpath

benny22:08:26

then when i run shadow-cljs compile test why does it try to compile the react native specific code if i’m not referencing it in my test sources?

thheller22:08:02

test defaults to including namespaces that end in -test

thheller22:08:18

so if any of those (or those they require) require react-native stuff it will end up including it

benny22:08:14

that’s pretty great, something somewhere is pulling in native code, but i will figure out what, it’s great to know it’ll only get pulled in if it’s referenced!

kommen07:08:37

fwiw: I’m now using a build hook for the :configure stage to bend the configuration of the release build to my will. the hooks really provide a lot of flexibility @thheller, very nice!