Fork me on GitHub
#shadow-cljs
<
2022-07-26
>
Samuel McHugh09:07:38

Hi, I'm trying to require a shadow-cljs project A into another shadow-cljs project B. Project A has an npm dependency on a git repo as described https://stackoverflow.com/questions/14187956/npm-install-from-git-in-a-specific-version. Project B doesn't seem to download this dependency when built. I also tried using the :npm-deps approach but it doesn't make a difference. I know I can just add the dependency manually to B but it increases the likelihood I update the npm package in one project but not the other. I was wondering if this is a known issue. Maybe it's a specific to this git approach of declaring an npm dependency.

thheller09:07:16

where did you put :npm-deps? likely just in the wrong place?

Samuel McHugh09:07:23

I put in my src folder in a file called deps.cljs

thheller09:07:29

and the src folder is actually the classpath root? not something like src/main?

thheller09:07:14

I never tested git dependencies myself so no clue if there is some special care that needs to be taken regarding those

Samuel McHugh11:07:16

When in the course of building project B does shadow prompt an npm install my-package given that a required library A, requires some package my-package?

thheller12:07:52

not "in the source of building project B" no. when starting shadow-cljs in project B is collects all deps.cljs files on the classpaths and then runs npm install for the packages found there, unless they are already declared as dependencies in the project B package.json

👌 1
Oliver Marks18:07:59

can shadow support more complicated layouts where shadow.edn is not in the root and some of the sources are located relative to its location, think polylith where you would have shadow-cljs.edn in the project folder but the src's will be located in component or bases folder so this type of layout https://polylith.gitbook.io/poly/architecture/workspace

thheller18:07:48

shadow-cljs.edn needs to be in the place where you run it. it doesn't care how you construct your classpath otherwise if you use deps.edn, so it doesn't matter at all where the sources are

thheller18:07:05

I don't know polylith otherwise to answer more specifically but looks to me like shadow-cljs.edn should be next to the workspace.edn? or whereever you run your project normally

Oliver Marks18:07:45

given the architecture you could have multiple seperate shadow projects so you would create a project for each and include the components you want to share, so i believe project would be the correct place then to add ../../bases/base1/ and ../../components/ perhaps to the :source path key in shadow ?

Oliver Marks18:07:32

currently my project works but I don't get the hot reloading on any components, only on code inside the base

thheller18:07:17

yeah sorry I do not understand what you are saying because I'm not familiar with the polylith terms

thheller18:07:07

I would assume that you just use deps.edn to manage dependencies and only control builds in shadow-cljs.edn

Oliver Marks18:07:31

perhaps the issue is that you have multiple deps.edn files, so a project has a deps.edn which includes the bases and components it uses, bases and components can also have there own separate deps.edn

Oliver Marks18:07:31

so the projects deps.edn does not specify the src in :paths key its specified in the bases and components deps.edn files if that makes sense

thheller18:07:17

I assume the deps.edn you are references has a bunch of :deps that use :local/root?

Oliver Marks18:07:46

yes correct so entries like this poly/web-ui {:local/root "../../components/web-ui"}

thheller18:07:10

ok, and that deps.edn file is in the same dir as the shadow-cljs.edn file and you also run shadow-cljs in that dir?

thheller18:07:32

and you have :deps {:aliases [:whatever :aliases :you :need]} in said shadow-cljs.edn

Oliver Marks18:07:51

yeah well i actually have it in bases as wel but thats from trying to make it work how I expect 🙂

thheller18:07:09

sorry don't know what bases is

Oliver Marks18:07:46

so a project has no code its just build files, bases is more like the curated app code built from components

Oliver Marks18:07:33

or another way of thinking about it is the project pulls together the src from the base and components into a buildable artifact,

Oliver Marks18:07:45

I may not be explaing this overly well 😕

Oliver Marks18:07:41

part of the reason I have a shadow-cljs.edn file is actually for jack-in because when you jackin to a src file it search up the tree, there may be a better way than this though I would be happy to use the shadow file from a base anyway, its more about how I can make the code reload work on components

Oliver Marks18:07:08

I was hoping some one had walked this path previously 😕

thheller19:07:29

@olymk2 shadow-cljs is only interested in the classpath. and it should reload all files from the classpath, excluding all .jar files or git deps. so it should just work

thheller19:07:45

but I cannot piece together how you actual setup looks so can't say

FlavaDave19:07:19

I’m having a hard time getting a repl going in a pulumi project. shadow-cljs watch works and I can connect to it. But am having difficulty getting a runtime for it. I have tried https://stackoverflow.com/questions/58060822/how-to-connect-a-clojurescript-node-repl-to-my-node-library-shadow-cljs-project but it then tells me that i need to run it with pulumi then when I run pulumi watch I get the error pulumi watch is not currently supported on darwin/arm64 . Can anyone think of a way around this?

Oliver Marks19:07:13

okay thanks I will play around a bit more see where I get to, could be something I have done

thheller19:07:16

if a base looks something like this then it doesn't seem like something runnable? https://github.com/seancorfield/usermanager-example/tree/polylith/bases/web

thheller19:07:40

so I guess thats where shadow-cljs.edn would be?

thheller19:07:57

I'm really not a fan of this entire setup so can't say for sure

Oliver Marks05:07:14

yeah exactly that, it seems like the shadow-cljs.edn should sit in project, I know it has been gaining some traction of late as a way of organizing code but the cljs version is not as smooth as the clj code from my own experience, especially when it comes to things like jacking in to a cljs project, I know calva got support for polylith so that could be a cider issue

thheller19:07:04

@dgonsalves22 sorry, I don't even know what pulumi is. could be that it just runs the code in such a containerized way that the actual runtime isn't able to connect back to shadow-cljs, which is required for the REPL to work

FlavaDave20:07:47

all good, If i figure out a solution i’ll post it in a thread of my original question

Nikolas Pafitis21:07:27

I'm getting this weird error for any shadow-cljs version >= 2.17.8 and it happens on two different projects as well.

➜  domo git:(develop) ✗ npm run shadow:watch:app

> [email protected] shadow:watch:app
> shadow-cljs -A:cljs:dev-cljs:test-cljs watch app

shadow-cljs - config: /home/albertobalsalm/IdeaProjects/domo/shadow-cljs.edn
shadow-cljs - starting via "clojure"
shadow-cljs - HTTP server available at 
shadow-cljs - HTTP server available at 
shadow-cljs - server version: 2.19.8 running at 
shadow-cljs - nREPL server started on port 7002
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build failure:
Failed to inspect file
  /home/albertobalsalm/IdeaProjects/domo/node_modules/highlight.js/lib/languages/isbl.js

it was required from
  /home/albertobalsalm/IdeaProjects/domo/node_modules/highlight.js/lib/index.js

Errors encountered while trying to parse file
  /home/albertobalsalm/IdeaProjects/domo/node_modules/highlight.js/lib/languages/isbl.js
  {:line 1, :column 1, :message "The file could not be parsed as JavaScript."}

RuntimeException: Exception parsing "/home/albertobalsalm/IdeaProjects/domo/node_modules/highlight.js/lib/languages/isbl.js"
	com.google.javascript.jscomp.parsing.ParserRunner.parse (ParserRunner.java:148)
	com.google.javascript.jscomp.JsAst.parse (JsAst.java:156)
	com.google.javascript.jscomp.JsAst.getAstRoot (JsAst.java:62)
	shadow.build.closure.JsInspector.getFileInfo (JsInspector.java:180)
	shadow.build.closure.JsInspector.getFileInfoMap (JsInspector.java:194)
	shadow.build.npm/get-file-info*/fn--12302 (npm.clj:452)
	shadow.build.npm/get-file-info* (npm.clj:451)
	shadow.build.npm/get-file-info* (npm.clj:401)
	shadow.build.npm/get-file-info (npm.clj:512)
	shadow.build.npm/get-file-info (npm.clj:509)
	shadow.build.npm/find-resource-in-package (npm.clj:726)
	shadow.build.npm/find-resource-in-package (npm.clj:686)
	shadow.build.npm/find-resource (npm.clj:776)
	shadow.build.npm/find-resource (npm.clj:739)
	shadow.build.resolve/find-npm-resource (resolve.clj:122)
	shadow.build.resolve/find-npm-resource (resolve.clj:93)
	shadow.build.resolve/eval14402/fn--14405 (resolve.clj:262)
	clojure.lang.MultiFn.invoke (MultiFn.java:244)
	shadow.build.resolve/find-resource-for-string (resolve.clj:80)
	shadow.build.resolve/find-resource-for-string (resolve.clj:69)
	shadow.build.resolve/resolve-string-require (resolve.clj:453)
	shadow.build.resolve/resolve-string-require (resolve.clj:436)
	shadow.build.resolve/resolve-require (resolve.clj:668)
	shadow.build.resolve/resolve-require (resolve.clj:661)
	shadow.build.resolve/resolve-deps/fn--14351 (resolve.clj:51)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6885)
	clojure.core/reduce (core.clj:6868)
	shadow.cljs.util/reduce-> (util.clj:42)
	shadow.cljs.util/reduce-> (util.clj:41)
	shadow.build.resolve/resolve-deps (resolve.clj:49)
	shadow.build.resolve/resolve-deps (resolve.clj:33)
	shadow.build.resolve/resolve-string-require (resolve.clj:478)
	shadow.build.resolve/resolve-string-require (resolve.clj:436)
	shadow.build.resolve/resolve-require (resolve.clj:668)
	shadow.build.resolve/resolve-require (resolve.clj:661)
	shadow.build.resolve/resolve-deps/fn--14351 (resolve.clj:51)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6885)
	clojure.core/reduce (core.clj:6868)
	shadow.cljs.util/reduce-> (util.clj:42)
	shadow.cljs.util/reduce-> (util.clj:41)
	shadow.build.resolve/resolve-deps (resolve.clj:49)
	shadow.build.resolve/resolve-deps (resolve.clj:33)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:655)
	shadow.build.resolve/resolve-symbol-require (resolve.clj:615)
	shadow.build.resolve/resolve-require (resolve.clj:665)
	shadow.build.resolve/resolve-require (resolve.clj:661)
	shadow.build.resolve/resolve-entry (resolve.clj:675)
	shadow.build.resolve/resolve-entry (resolve.clj:674)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6885)
	clojure.core/reduce (core.clj:6868)
	shadow.cljs.util/reduce-> (util.clj:42)
	shadow.cljs.util/reduce-> (util.clj:41)
	shadow.build.resolve/resolve-entries (resolve.clj:689)
	shadow.build.resolve/resolve-entries (resolve.clj:680)
	shadow.build.modules/resolve-module/fn--15659 (modules.clj:252)
	shadow.build.modules/resolve-module (modules.clj:248)
	shadow.build.modules/resolve-module (modules.clj:238)
	clojure.lang.PersistentVector.reduce (PersistentVector.java:343)
	clojure.core/reduce (core.clj:6885)
	clojure.core/reduce (core.clj:6868)
	shadow.build.modules/resolve-modules (modules.clj:258)
	shadow.build.modules/resolve-modules (modules.clj:257)
	shadow.build.modules/analyze (modules.clj:312)
	shadow.build.modules/analyze (modules.clj:303)
	shadow.build/resolve (build.clj:459)
	shadow.build/resolve (build.clj:453)
	shadow.build/compile (build.clj:509)
	shadow.build/compile (build.clj:493)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:368)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:349)
	shadow.cljs.devtools.server.worker.impl/eval17412/fn--17414 (impl.clj:448)
	clojure.lang.MultiFn.invoke (MultiFn.java:234)
	shadow.cljs.devtools.server.util/server-thread/fn--17170/fn--17171/fn--17179 (util.clj:269)
	shadow.cljs.devtools.server.util/server-thread/fn--17170/fn--17171 (util.clj:268)
	shadow.cljs.devtools.server.util/server-thread/fn--17170 (util.clj:241)
	java.lang.Thread.run (Thread.java:829)
Caused by:
StackOverflowError:
	com.google.javascript.jscomp.parsing.IRFactory.parseJSDocInfoOnTree (IRFactory.java:695)
	com.google.javascript.jscomp.parsing.IRFactory.transform (IRFactory.java:784)
	com.google.javascript.jscomp.parsing.IRFactory$TransformDispatcher.processBinaryExpression (IRFactory.java:1800)
	...
From what I understand re-frame-10x depends on re-highlight which in turn depends on highlight.js. I tried with multiple versions of highlight in my package.json as well but with no success.

thheller21:07:11

@silencioseu its not the highlight.js version you need to change. its the re-frame-10x or re-highlight version

Nikolas Pafitis22:07:45

@thheller You were right, I've fixed this by bumping both re-frame-10x and re-highlight version to their latest versions (re-highlight was a transitive dependency now I have it explicitly)

Nikolas Pafitis22:07:33

@thheller When i tried to bump on re-frame-10x only it didn't work.

Nikolas Pafitis22:07:53

Nvm it looks like it still happens

thheller22:07:42

you can just bump the default stack size

thheller22:07:04

if you use shadow-cljs.edn to run things :jvm-opts ["-Xss16m"] at the root

thheller22:07:18

if you use deps.edn/project.clj you'll need to set it there somewhere

Nikolas Pafitis22:07:16

@thheller Yep bumping the stack size in my deps.edn seems to have done the trick

thheller22:07:47

its probably still worth investigating what is including that file, best via a build report https://shadow-cljs.github.io/docs/UsersGuide.html#build-report. if its actually still in the release build that is.

thheller22:07:02

it includes a few huge files by default that you most likely don't need

Nikolas Pafitis22:07:52

Why would that be a non issue with older shadow versions though?

thheller22:07:23

its not an issue with shadow

thheller22:07:12

its an issue with the closure compiler. dunno what change there caused this problem to happen, but can't go back to older versions of it since we want some of the newer fixes fixing other problems 😛

thheller22:07:43

technically yes, I could be fixing it on the shadow-cljs side

thheller22:07:06

but I had hoped that just not include the file in the first place would be a better fix

thheller22:07:31

turns out that it comes up much more often than anticipated. so I might have to work around it after all

thheller22:07:38

but not tonight. gn8 🙂

Nikolas Pafitis22:07:21

Goodnight, fix 8s good enough for me

Nikolas Pafitis22:07:47

I don't know how to exclude files from highlight js, even though I'm probably using only one of them