Fork me on GitHub
#shadow-cljs
<
2022-07-28
>
thheller05:07:30

@colliderwriter :paths is deps.edn and therefore the rules of tools.deps apply. basically you need to use :local/root if you want to get outside the project

πŸ‘ 1
bbss06:07:32

In my trying to make the smallest reproduction I figured out a rather stupid mistake: had up-to-date shadow-cljs in my clj deps, but in my devDependencies of node it was still on 2.17.4 facepalm

πŸ‘ 1
bbss06:07:54

Getting further now with thes :esm build but hitting:

[webpack-cli] ModuleNotFoundError: Module not found: Error: Can't resolve './cljs-runtime/shadow.module.notebookesm.prepend.js' in '/Users/baruchberger/opt/anaconda3/share/jupyter/lab/staging/node_modules/jupyter.compilation/lib'

bbss06:07:19

and with :npm-module watch build I'm hitting:

Module not provided: shadow.js.shim.module$$babel$runtime$helpers$interopRequireDefault
with :npm-module release build I'm hitting:
ReferenceError: shadow$provide is not defined

thheller08:07:42

@bbss I really cannot comment on any of that without seeing configs/code

bbss08:07:24

Okay, I've added a comment to the issue https://github.com/thheller/shadow-cljs/issues/1039 with a repo

thheller08:07:40

thanks. I'll look at that

bbss08:07:46

thank you very much πŸ™‚

bbss08:07:28

I think the :esm release build is very close. It might be some node dependency of the babel-transpiled library I'm importing?

thheller08:07:33

how do I run jupyter?

bbss08:07:48

tldr: If you have conda installed: conda install -c conda-forge jupyterlab or pip install jupyterlab If you are using a macOS version that comes with Python 2, run pip3 instead of pip.

thheller08:07:59

I don't have conda

bbss08:07:09

then pip3 install jupyterlab should work

thheller08:07:14

or pip3 πŸ˜›

bbss08:07:25

Oh.. Uhm.

thheller08:07:25

or pip I guess

thheller08:07:38

its debian? so just apt-get install python maybe?

bbss08:07:53

Yes, might need to apt-get pip too

thheller08:07:30

still installing I guess

thheller08:07:37

try this build config

{:target :esm
 :output-dir "lib"
 :modules {:notebookesm {:exports-var notebook/extension}}
 :runtime :browser
 :js-options {:js-provider :import}}

thheller08:07:16

$ jupyter lab --watch
[I 2022-07-28 10:45:12.917 ServerApp] jupyterlab | extension was successfully linked.
[I 2022-07-28 10:45:12.927 ServerApp] nbclassic | extension was successfully linked.
[I 2022-07-28 10:45:12.930 ServerApp] Writing Jupyter server cookie secret to /home/thheller/.local/share/jupyter/runtime/jupyter_cookie_secret
[I 2022-07-28 10:45:13.458 ServerApp] notebook_shim | extension was successfully linked.
[I 2022-07-28 10:45:13.600 ServerApp] notebook_shim | extension was successfully loaded.
[I 2022-07-28 10:45:13.601 LabApp] JupyterLab extension loaded from /home/thheller/.local/lib/python3.9/site-packages/jupyterlab
[I 2022-07-28 10:45:13.601 LabApp] JupyterLab application directory is /home/thheller/.local/share/jupyter/lab
[I 2022-07-28 10:45:13.602 LabApp] Starting JupyterLab watch mode...
-

thheller08:07:30

is this supposed to show something more? it just keeps spinning?

thheller08:07:38

no idea what I'm supposed to expect here πŸ˜›

thheller08:07:56

I did the link and started that thing

thheller08:07:59

dunno whats next

bbss08:07:59

It compiled the watch build with that, but again hit the shadow.module.notebookesm.prepend.js issue. After I pressed stop to try the release build I got a

[2022-07-28 17:20:57.673 - INFO] :shadow.build.npm/js-invalid-requires - {:resource-name "node_modules/@jupyterlab/codemirror/lib/mode.js", :requires [{:line 38, :column 20}]}
------ WARNING #1 -  -----------------------------------------------------------
 Resource: node_modules/h3-js/dist/browser/h3-js.js:674:2
 @suppress annotation not allowed here. See 
--------------------------------------------------------------------------------
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGBUS (0xa) at pc=0x00000001042039c4, pid=28319, tid=47875
#
# JRE version: OpenJDK Runtime Environment Homebrew (11.0.12) (build 11.0.12+0)
# Java VM: OpenJDK 64-Bit Server VM Homebrew (11.0.12+0, mixed mode, tiered, compressed oops, g1 gc, bsd-aarch64)
# Problematic frame:
# V  [libjvm.dylib+0x5279c4]  _ZN15PcDescContainer21find_pc_desc_internalEPhbRK12PcDescSearch+0xf4
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/baruchberger/jupyter-compilation-target/hs_err_pid28319.log
Compiled method (c2) 1469217 22524   !   4       clojure.core.async$mult$fn__9046$state_machine__7801__auto____9059$fn__9064::invoke (5095 bytes)
 total in heap  [0x00000001158cc590,0x00000001158e4620] = 98448

bbss08:07:12

Okay, it should open the notebook in your browser

thheller08:07:28

it probably can't because its running in wsl

thheller08:07:40

This site can’t be reached

bbss08:07:07

Hmm, the watch tends to take some time usually but that's probably not it :thinking_face:

thheller08:07:08

the error you just posted cannot happen with the config I just gave you

thheller08:07:18

so maybe thats still the npm-module build or something?

thheller08:07:31

well it has been going for several minutes now?

bbss08:07:40

yeah, not that long πŸ™‚

thheller08:07:45

but its also the first time starting so no clue

thheller08:07:12

the link seems fine though

bbss08:07:22

X Compilation failed.
NullPointerException: 
	clojure.string/index-of (string.clj:327)
	clojure.string/index-of (string.clj:319)
	shadow.build.targets.esm/replace-goog-global* (esm.clj:334)
	shadow.build.targets.esm/replace-goog-global* (esm.clj:328)
	clojure.core/apply (core.clj:669)
	clojure.core/update-in/up--6922 (core.clj:6220)
	clojure.core/update-in/up--6922 (core.clj:6219)
	clojure.core/update-in/up--6922 (core.clj:6219)
	clojure.core/update-in (core.clj:6221)
	clojure.core/update-in (core.clj:6207)
	shadow.build.targets.esm/replace-goog-global (esm.clj:362)
	shadow.build.targets.esm/replace-goog-global (esm.clj:350)
	shadow.build.targets.esm/process (esm.clj:473)
	shadow.build.targets.esm/process (esm.clj:465)
	clojure.lang.Var.invoke (Var.java:384)
	shadow.build/process-stage/fn--15861 (build.clj:163)
	shadow.build/process-stage (build.clj:160)
	shadow.build/process-stage (build.clj:152)
	shadow.build/compile (build.clj:511)
	shadow.build/compile (build.clj:493)
	shadow.cljs.devtools.server.remote-ext/do-build/fn--20767 (remote_ext.clj:104)
	clojure.core/binding-conveyor-fn/fn--5823 (core.clj:2047)
	java.util.concurrent.FutureTask.run (FutureTask.java:264)
	java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1128)
	java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:628)
	java.lang.Thread.run (Thread.java:829)

bbss08:07:33

the link went through building a couple of times as well?

thheller08:07:53

is this in your actual project or in the repro?

thheller08:07:14

that compiles just fine for me

thheller08:07:28

{:deps {:aliases [:dev]}
 :nrepl {:port 12000}
 :builds {:notebook-esm
          {:target :esm
           :output-dir "lib"
           :modules {:notebookesm {:exports-var notebook/extension}}
           :runtime :browser
           :js-options {:js-provider :import}}}}

thheller08:07:39

and changing index.js to include the notebookesm.js

thheller08:07:50

oh something happening

thheller08:07:26

ok jupyter running

thheller08:07:49

how do I see if the extension did anything?

bbss08:07:22

it should print the extension and "extension in index.js"

thheller08:07:42

print it where?

bbss08:07:44

I can build it with watch, but release gives that nullpointer

bbss08:07:50

in the devtools console

bbss08:07:59

And you don't have any errors?

thheller08:07:10

Oh I guess link had errors

thheller08:07:12

ValueError:
"[email protected]" is not compatible with the current JupyterLab
Conflicting Dependencies:
JupyterLab              Extension      Package
>=3.4.4 <3.5.0          3.3.2          @jupyterlab/application
>=3.4.4 <3.5.0          3.3.2          @jupyterlab/apputils
>=3.4.4 <3.5.0          3.3.2          @jupyterlab/launcher
>=3.4.4 <3.5.0          3.3.2          @jupyterlab/notebook


An error occurred.
ValueError:
"[email protected]" is not compatible with the current JupyterLab
Conflicting Dependencies:
JupyterLab              Extension      Package
>=3.4.4 <3.5.0          3.3.2          @jupyterlab/application
>=3.4.4 <3.5.0          3.3.2          @jupyterlab/apputils
>=3.4.4 <3.5.0          3.3.2          @jupyterlab/launcher
>=3.4.4 <3.5.0          3.3.2          @jupyterlab/notebook
See the log file for details:  /tmp/jupyterlab-debug-k6xty04m.log
Exiting application: lab

bbss08:07:49

Hmm okay, my jupyterlab is a bit older.

bbss08:07:04

I guess those npm deps need to be bumped

thheller08:07:53

there are a few, which one?

thheller08:07:00

bumped it all to 3.4.4

thheller08:07:18

which at least gets further than it did before. doing the spinning thing again.

bbss08:07:35

Right.. 🀞:skin-tone-2:

thheller09:07:13

ok getting the

[webpack-cli] ModuleNotFoundError: Module not found: Error: Can't resolve './cljs-runtime/shadow.module.notebookesm.prepend.js' in '/home/thheller/.local/share/jupyter/lab/staging/node_modules/jupyter.compilation/lib'

thheller09:07:29

I don't know why its looking in that directory though?

thheller09:07:16

I'm guessing it didn't copy some files?

thheller09:07:32

do oyu need to configure which files a package has somewhere?

thheller09:07:54

"files": [
    "index.js",
    "lib/*.{js,js.map}"
  ],

thheller09:07:00

are you sure thats valid?

bbss09:07:01

That should be included in the files prop of package.json.

bbss09:07:48

I think so because I’ve had it run files from there :thinking_face:

thheller09:07:51

ah I guess it just doesn't include the cljs-runtime dir?

bbss09:07:00

That makes sense

thheller09:07:21

but yeah I have very little hope of watch and REPL working here πŸ˜›

thheller09:07:59

starting ...

bbss09:07:00

It actually did watch properly with the tip you gave

bbss09:07:08

Just without the third party JS

bbss09:07:14

Watch and even hot reload

thheller09:07:32

well I'll be damned

thheller09:07:35

shadow-cljs: #5 ready!

bbss09:07:42

πŸŽ‰

thheller09:07:44

undefined 'extension in index.js'

thheller09:07:12

hello world from the REPL

thheller09:07:15

well that was easy πŸ˜‰

bbss09:07:48

Yeah should have :default probaly :as doesn't work

bbss09:07:20

I don't have time to test right now but a little later I’ll see where I get with this new info. Hopefully this also solves the third party js issue. Thank you so much 😊

thheller09:07:25

I guess you meant

{:deps {:aliases [:dev]}
 :nrepl {:port 12000}
 :builds {:notebook-esm
          {:target :esm
           :output-dir "lib"
           :modules {:notebookesm {:exports {extension notebook/extension}}}
           :runtime :browser
           :js-options {:js-provider :import}}}}
?

thheller09:07:11

what is viv.es.js and why is it on the classpath?

thheller09:07:15

is it not a npm lib?

bbss09:07:04

It's not, made some adjustments to that codebase. Although we are in the process of adding this as an npm package.

thheller09:07:01

well it shouldn't be part of the build I guess

thheller09:07:01

is this link really necessary always?

thheller09:07:03

takes forever

bbss09:07:15

It works for our normal web-app. It’s compiled with babel.

bbss09:07:34

I think it actually links to the directory for watch builds, so maybe not?

thheller09:07:28

well its not actually a ES file so the viv.es.js is confusing

thheller09:07:26

and since its commonjs it doesn't play too well with the ESM build

thheller09:07:37

but it shouldn't be part of the build in the first place

thheller09:07:44

it should just be a npm package

thheller09:07:53

this experience is frustratingly slow πŸ˜›

thheller09:07:32

but yeah the problem is the viv file

thheller09:07:07

ok, just removed the viv thing and now everthing appears to log what it should

thheller09:07:15

{id: 'jupyter-compilation-target.notebook', autoStart: true, optional: Array(1), requires: Array(2), activate: Ζ’} 'extension in index.js'

thheller09:07:22

activate W {_started: true, _pluginMap: {…}, _serviceMap: Map(60), _delegate: e, commands: e, …} _e {_currentChanged: e, _isDisposed: false, _widgetAdded: e, _widgetUpdated: e, _focusTracker: e, …}

flowthing11:07:43

Noticed that v2.19.7 and newer seem to ship a version of the Closure Compiler that's not compatible with Java 8:

Ξ» java -version
openjdk version "1.8.0_272"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_272-b10)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.272-b10, mixed mode)
Ξ» clj -Srepro -Sdeps '{:deps {thheller/shadow-cljs {:mvn/version "2.19.7"}}}' -M -m shadow.cljs.devtools.cli browser-repl
...
Caused by: java.lang.UnsupportedClassVersionError: com/google/javascript/jscomp/CompilerOptions has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
...
From the Closure Compiler release notes (https://github.com/google/closure-compiler/wiki/Releases#june-1st-2022-v20220601): > Java 11 or newer is now required to run Closure Compiler. Just a heads up. Guess there's little to be done about that.

flowthing11:07:10

(The Closure Compiler that comes with v2.19.6 works fine with Java 8.)

thheller15:07:29

yeah, can't do anything about that.

Drew Verlee16:07:22

In the error messsage below, it seems like the shadow server is trying to call a method that doesn't exist. I assume this is because that method's library is set to a version that doesn't have it due to another project dependency. But i can't figure out where, is there a way to get more information? "com.google.javascript" or ".protobuf" doesn't appear in my package-json.lock or my deps file. For java based builds i can use clj -Stree what is the equivalent for shadow projects?

[:app] Compiling ...
[2022-07-28 11:42:00.658 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:type :start-autobuild}}
NoSuchMethodError com.google.javascript.jscomp.serialization.ObjectTypeProto.emptyIntList()Lcom/google/protobuf/Internal$IntList;
	com.google.javascript.jscomp.serialization.ObjectTypeProto.<init> (ObjectTypeProto.java:24)
	com.google.javascript.jscomp.serialization.ObjectTypeProto.<clinit> (ObjectTypeProto.java:2379)
	com.google.javascript.jscomp.serialization.TypeProto.<init> (TypeProto.java:63)
	com.google.javascript.jscomp.serialization.TypeProto.<init> (TypeProto.java:15)
	com.google.javascript.jscomp.serialization.TypeProto$1.parsePartialFrom (TypeProto.java:909)
	com.google.javascript.jscomp.serialization.TypeProto$1.parsePartialFrom (TypeProto.java:903)
	com.google.protobuf.CodedInputStream$StreamDecoder.readMessage (CodedInputStream.java:2315)
	com.google.javascript.jscomp.serialization.TypePool.<init> (TypePool.java:66)
	com.google.javascript.jscomp.serialization.TypePool.<init> (TypePool.java:15)
	com.google.javascript.jscomp.serialization.TypePool$1.parsePartialFrom (TypePool.java:3283)
	com.google.javascript.jscomp.serialization.TypePool$1.parsePartialFrom (TypePool.java:3277)
	com.google.protobuf.CodedInputStream$StreamDecoder.readMessage (CodedInputStream.java:2315)

Drew Verlee16:07:18

i'm going to bumb shadow to the latest to start...

thheller17:07:43

whats the full stacktrace?

thheller17:07:08

this is most likely a dependency conflict ys, no clue which one though

thheller17:07:17

com.google.javascript is the closure-compiler

Drew Verlee17:07:26

that's all that i see in my terminal.

thheller17:07:45

open a REPL and run (shadow.cljs.devtools.api/compile! :app) I guess

πŸ‘€ 1
Stef Coetzee16:09:37

@U0DJ4T5U1: did you manage to resolve this error?

thheller17:09:41

most likely a dependency conflict on protobuf?

Drew Verlee20:09:47

@U03CPPKDXBL i was, though i can't recall at this point what I did specifically. Probably just updated a dependency.

Stef Coetzee04:09:38

Glad to hear it, thanks @U0DJ4T5U1. Good call, @U05224H0W. In my case, it was mysql/mysql-connector-java 8.0.19 that depended on com.google.protobuf/protobuf-java 3.6.1 . Upgraded to mysql/mysql-connector-java 8.0.30 , which seems to have done the trick.

Stef Coetzee05:09:38

@U05224H0W, thanks for putting together the guide. The https://shadow-cljs.github.io/docs/UsersGuide.html#_troubleshooting's recommendation to list all active dependencies using clj -A:dev:cljs -Stree was really helpful! I'm starting to appreciate your recommendation to manage all CLJS dependencies exclusively with Shadow CLJS. For others interested, learn more here: https://github.com/thheller/shadow-cljs/issues/983#issuecomment-1041190965

πŸ‘ 1
Eric Dvorsak12:10:43

I am going to hijack this thread and add my stackstrace for future lost souls, I had:

NoSuchMethodError 'com.google.protobuf.Internal$IntList com.google.javascript.jscomp.serialization.ObjectTypeProto.emptyIntList()'
	com.google.javascript.jscomp.serialization.ObjectTypeProto.<init> (ObjectTypeProto.java:24)
	com.google.javascript.jscomp.serialization.ObjectTypeProto.<clinit> (ObjectTypeProto.java:2391)
	com.google.javascript.jscomp.serialization.TypeProto.<init> (TypeProto.java:63)
	com.google.javascript.jscomp.serialization.TypeProto.<init> (TypeProto.java:15)
	com.google.javascript.jscomp.serialization.TypeProto$1.parsePartialFrom (TypeProto.java:909)
	com.google.javascript.jscomp.serialization.TypeProto$1.parsePartialFrom (TypeProto.java:903)
	com.google.protobuf.CodedInputStream$StreamDecoder.readMessage (CodedInputStream.java:2424)
	com.google.javascript.jscomp.serialization.TypePool.<init> (TypePool.java:66)
	com.google.javascript.jscomp.serialization.TypePool.<init> (TypePool.java:15)
	com.google.javascript.jscomp.serialization.TypePool$1.parsePartialFrom (TypePool.java:3283)
	com.google.javascript.jscomp.serialization.TypePool$1.parsePartialFrom (TypePool.java:3277)
	com.google.protobuf.CodedInputStream$StreamDecoder.readMessage (CodedInputStream.java:2424)
and it was caused by an older version of the mysql-connector as well, upgrading to mysql/mysql-connector-java 8.0.30 fixed it I would have never suspected this one

πŸ™Œ 1