Fork me on GitHub
#shadow-cljs
<
2022-07-30
>
tianshu09:07:19

ExceptionInfo: failed to convert sources
        shadow.build.closure/convert-sources-simple*/fn--14006 (closure.clj:1993)
        shadow.build.closure/convert-sources-simple* (closure.clj:1980)
        shadow.build.closure/convert-sources-simple* (closure.clj:1849)
        shadow.build.closure/convert-sources-simple (closure.clj:2154)
        shadow.build.closure/convert-sources-simple (closure.clj:2104)
        shadow.build.compiler/maybe-closure-convert (compiler.clj:1218)
        shadow.build.compiler/maybe-closure-convert (compiler.clj:1211)
        shadow.build.compiler/compile-all (compiler.clj:1467)
        shadow.build.compiler/compile-all (compiler.clj:1330)
        shadow.build.api/compile-sources (api.clj:261)
        shadow.build.api/compile-sources (api.clj:253)
        shadow.build/compile (build.clj:492)
        shadow.build/compile (build.clj:482)
        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/eval17461/fn--17463 (impl.clj:448)
        clojure.lang.MultiFn.invoke (MultiFn.java:234)
        shadow.cljs.devtools.server.util/server-thread/fn--17219/fn--17220/fn--17228 (util.clj:269)
        shadow.cljs.devtools.server.util/server-thread/fn--17219/fn--17220 (util.clj:268)
        shadow.cljs.devtools.server.util/server-thread/fn--17219 (util.clj:241)
        java.lang.Thread.run (Thread.java:836)
Caused by:
RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.

null
  Node(SHEQ): node_modules/noble-ed25519/index.js:292:23
        const isXOdd = (x & 1n) === 1n;
  Parent(SHNE): node_modules/noble-ed25519/index.js:293:12
        if (isLastByteOdd !== isXOdd) {

        com.google.javascript.jscomp.Compiler.throwInternalError (Compiler.java:2882)
        com.google.javascript.jscomp.NodeTraversal.throwUnexpectedException (NodeTraversal.java:442)
        com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:462)
        com.google.javascript.jscomp.NodeTraversal.access$200 (NodeTraversal.java:38)
        com.google.javascript.jscomp.NodeTraversal$Builder.traverse (NodeTraversal.java:398)
        com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:468)
        com.google.javascript.jscomp.NodeTraversal.traverseScopeRoots (NodeTraversal.java:636)
        com.google.javascript.jscomp.PeepholeOptimizationsPass.process (PeepholeOptimizationsPass.java:67)
        com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:267)
        com.google.javascript.jscomp.PhaseOptimizer$Loop.process (PhaseOptimizer.java:405)
        com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:186)
        com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2572)
        com.google.javascript.jscomp.Compiler.lambda$stage2Passes$5 (Compiler.java:936)
        com.google.javascript.jscomp.Compiler$$Lambda$376/000000000000000000.call (:-1)
        com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127)
        com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:984)
        com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:933)
        com.google.javascript.jscomp.Compiler.compile (Compiler.java:816)
        jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
        jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
        jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
        java.lang.reflect.Method.invoke (Method.java:566)
        clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
        clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
        shadow.build.closure/convert-sources-simple*/fn--14006/fn--14007 (closure.clj:1983)
        shadow.build.closure/convert-sources-simple*/fn--14006 (closure.clj:1981)
        shadow.build.closure/convert-sources-simple* (closure.clj:1980)
        shadow.build.closure/convert-sources-simple* (closure.clj:1849)
        shadow.build.closure/convert-sources-simple (closure.clj:2154)
        shadow.build.closure/convert-sources-simple (closure.clj:2104)
        shadow.build.compiler/maybe-closure-convert (compiler.clj:1218)
        shadow.build.compiler/maybe-closure-convert (compiler.clj:1211)
        shadow.build.compiler/compile-all (compiler.clj:1467)
        shadow.build.compiler/compile-all (compiler.clj:1330)
        shadow.build.api/compile-sources (api.clj:261)
        shadow.build.api/compile-sources (api.clj:253)
        shadow.build/compile (build.clj:492)
        shadow.build/compile (build.clj:482)
        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/eval17461/fn--17463 (impl.clj:448)
        clojure.lang.MultiFn.invoke (MultiFn.java:234)
        shadow.cljs.devtools.server.util/server-thread/fn--17219/fn--17220/fn--17228 (util.clj:269)
        shadow.cljs.devtools.server.util/server-thread/fn--17219/fn--17220 (util.clj:268)
        shadow.cljs.devtools.server.util/server-thread/fn--17219 (util.clj:241)
        java.lang.Thread.run (Thread.java:836)
Caused by:
NullPointerException:
        com.google.javascript.jscomp.PeepholeFoldConstants.tryStrictEqualityComparison (PeepholeFoldConstants.java:1387)
        com.google.javascript.jscomp.PeepholeFoldConstants.evaluateComparison (PeepholeFoldConstants.java:1416)
        com.google.javascript.jscomp.PeepholeFoldConstants.tryFoldComparison (PeepholeFoldConstants.java:1160)
        com.google.javascript.jscomp.PeepholeFoldConstants.tryFoldBinaryOperator (PeepholeFoldConstants.java:188)
        com.google.javascript.jscomp.PeepholeFoldConstants.optimizeSubtree (PeepholeFoldConstants.java:104)
        com.google.javascript.jscomp.PeepholeOptimizationsPass$PeepCallback.visit (PeepholeOptimizationsPass.java:82)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:856)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
        com.google.javascript.jscomp.NodeTraversal.traverseFunction (NodeTraversal.java:895)
        com.google.javascript.jscomp.NodeTraversal.handleFunction (NodeTraversal.java:760)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:803)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
        com.google.javascript.jscomp.NodeTraversal.handleClassMembers (NodeTraversal.java:970)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:812)
        com.google.javascript.jscomp.NodeTraversal.handleClass (NodeTraversal.java:945)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:809)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
        com.google.javascript.jscomp.NodeTraversal.traverseFunction (NodeTraversal.java:895)
        com.google.javascript.jscomp.NodeTraversal.handleFunction (NodeTraversal.java:760)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:803)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
        com.google.javascript.jscomp.NodeTraversal.traverseChildren (NodeTraversal.java:984)
        com.google.javascript.jscomp.NodeTraversal.handleScript (NodeTraversal.java:748)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:800)
        com.google.javascript.jscomp.NodeTraversal.traverseBranch (NodeTraversal.java:847)
        com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:459)
        com.google.javascript.jscomp.NodeTraversal.access$200 (NodeTraversal.java:38)
        com.google.javascript.jscomp.NodeTraversal$Builder.traverse (NodeTraversal.java:398)
        com.google.javascript.jscomp.NodeTraversal.traverse (NodeTraversal.java:468)
        com.google.javascript.jscomp.NodeTraversal.traverseScopeRoots (NodeTraversal.java:636)
        com.google.javascript.jscomp.PeepholeOptimizationsPass.process (PeepholeOptimizationsPass.java:67)
        com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process (PhaseOptimizer.java:267)
        com.google.javascript.jscomp.PhaseOptimizer$Loop.process (PhaseOptimizer.java:405)
        com.google.javascript.jscomp.PhaseOptimizer.process (PhaseOptimizer.java:186)
        com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations (Compiler.java:2572)
        com.google.javascript.jscomp.Compiler.lambda$stage2Passes$5 (Compiler.java:936)
        com.google.javascript.jscomp.Compiler$$Lambda$376/000000000000000000.call (:-1)
        com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread (CompilerExecutor.java:127)
        com.google.javascript.jscomp.Compiler.runInCompilerThread (Compiler.java:984)
        com.google.javascript.jscomp.Compiler.stage2Passes (Compiler.java:933)
        com.google.javascript.jscomp.Compiler.compile (Compiler.java:816)
        jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (NativeMethodAccessorImpl.java:-2)
        jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
        jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
        java.lang.reflect.Method.invoke (Method.java:566)
        clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:167)
        clojure.lang.Reflector.invokeInstanceMethod (Reflector.java:102)
        shadow.build.closure/convert-sources-simple*/fn--14006/fn--14007 (closure.clj:1983)
        shadow.build.closure/convert-sources-simple*/fn--14006 (closure.clj:1981)
        shadow.build.closure/convert-sources-simple* (closure.clj:1980)
        shadow.build.closure/convert-sources-simple* (closure.clj:1849)
        shadow.build.closure/convert-sources-simple (closure.clj:2154)
        shadow.build.closure/convert-sources-simple (closure.clj:2104)
        shadow.build.compiler/maybe-closure-convert (compiler.clj:1218)
        shadow.build.compiler/maybe-closure-convert (compiler.clj:1211)
        shadow.build.compiler/compile-all (compiler.clj:1467)
        shadow.build.compiler/compile-all (compiler.clj:1330)
        shadow.build.api/compile-sources (api.clj:261)
        shadow.build.api/compile-sources (api.clj:253)
        shadow.build/compile (build.clj:492)
        shadow.build/compile (build.clj:482)
        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/eval17461/fn--17463 (impl.clj:448)
        clojure.lang.MultiFn.invoke (MultiFn.java:234)
        shadow.cljs.devtools.server.util/server-thread/fn--17219/fn--17220/fn--17228 (util.clj:269)
        shadow.cljs.devtools.server.util/server-thread/fn--17219/fn--17220 (util.clj:268)
        shadow.cljs.devtools.server.util/server-thread/fn--17219 (util.clj:241)
        java.lang.Thread.run (Thread.java:836)

tianshu09:07:50

I think it can be reproduced by this dependency: https://www.npmjs.com/package/@metaplex-foundation/js

thheller09:07:21

@doglooksgood again unfortunately an error in the closure compiler I cannot do anything about

tianshu09:07:54

So the best idea here would be avoid these things going to the closure compiler?

thheller09:07:01

its also this npm package node_modules/noble-ed25519 not the one you linked

thheller09:07:21

well the closure compiler is sometimes picky about certain code. sometimes its a bug sometimes its intended

tianshu09:07:35

Maybe I should start a side javascript project, to deal with these dependencies?

thheller09:07:24

or as far as I can tell these packages seem to be intended for node? the error above you only get for build where shadow-cljs tries to package everything (ie. browser)

thheller09:07:29

for node it doesn't need to do that so the error would just disappear on its own

tianshu09:07:40

But those are libraries for browser, I guess it's not well-written.

tianshu09:07:54

So with js-provider, I should bundle the dependencies with webpack?

thheller09:07:17

or any other JS bundler you want

thheller09:07:26

rollup, esbuild, all the same really

tianshu09:07:12

(ns 
  (:require ["react" :as react]))
So I can have this in my CLJS codes, if I bundle the react in a lib.js? But what code I should provide in that target/index.js?

tianshu09:07:29

Oh, it's generated

thheller09:07:52

yes, you feed the generated :external-index file to webpack or whatever

thheller09:07:00

and then load the output that generates in your HTML, before the output of shadow-cljs

tianshu09:07:08

Ahhh, webpack5 changed their api again.

tianshu09:07:18

--output no longer available

tianshu09:07:40

shadow-cljs is so flexible, feel super nice about it

alex16:07:51

Does shadow-cljs support specifying a remote sourcemap location e.g. ... rather than at the :asset-path relative to the origin? We store our compiled JS files & sourcemap files on a cloud storage bucket

alex16:07:38

Ah great, looks like I might be able to just use :source-map-asset-path or :source-map-path. https://clojurescript.org/reference/compiler-options Not entirely sure of the difference between those two quite yet...

alex16:07:18

Hmm though the shadow-cljs user guide says this is an unsupported option. Should I explore a different path?

thheller20:07:06

asset-path is just prepended, so just put the full url in it

thheller20:07:37

although I don't understand the question. why are the maps not just in the same folder als the js?

alex20:07:31

The maps are in the same folder as the compiled JS files - both sets are uploaded to GCS after compilation.

thheller20:07:58

ok, then everything should be good by default? it uses a relative path by default?

thheller20:07:05

no need to configure anything?

alex23:07:16

Confirmed that the sourceMappingUrl is a relative path. However, when I open up dev tools, I'm seeing some "Devtools failed to load source map. Could not parse content for <some-url>.js.map", with that url being the page origin rather than the Google Cloud Storage url. It seems like the sourceMappingUrl relative path is being appended to the page origin rather than the GCS origin

thheller07:08:59

hmm that is odd? the spec says the url is relative to the .js file not the document?

thheller07:08:43

how are you loading the scripts?

alex13:08:17

I'm loading the initial bundle via

<script src=""></script>
The other modules are then lazy-loaded as users interact with the app (those are also requested and served from the Google cloud storage bucket) Interestingly, for the initial client.js bundle, I don't see a "Devtools failed to load source map" warning, perhaps suggesting that the initial one is loaded correctly? For all of the subsequent lazy-loaded modules, I see a corresponding warning about not being able to load that module's source map

thheller17:08:24

hmm yeah the lazy loading might be the issue. I think then it uses the document location as a reference

alex17:08:36

Ah that's interesting and good to know. In that case, would you suggest using one of the compiler options to set an absolute path pointing to the GCS origin?

thheller17:08:58

there is no setting for this currently since it normally isn't needed

thheller17:08:08

how are you lazy loading the sources?

thheller18:08:53

hmm but using exactly that loading mechanism?

thheller18:08:19

it is supposed to inject the source url, so the browser knows how to resolve the relative path for the source map

thheller18:08:34

if you use a different loading mechanism that might not be done

thheller18:08:29

which :asset-path do you use?

alex18:08:20

Yep, using the loading mechanism from your article i.e. lazy-component , shadow.lazy, etc

:asset-path "/js/compiled"

thheller18:08:40

but how is that loading the JS then? I mean that is pointing to the wrong location?

thheller18:08:57

or is the HTML also coming from that location?

thheller18:08:37

note that :asset-path is a little misleading in the name. should be :asset-prefix or something. you can put an entire URL in there

thheller18:08:52

but this should all be working by default and not require any other special settings

thheller18:08:04

unless you are manually fiddling with things in other ways of course

alex19:08:56

> but how is that loading the JS then? I mean that is pointing to the wrong location? Ah! Looks like our main GCS-hosted client.js bundle is lazy-loading the other modules from a relative path appended to our document location. This isn't erroring because those relative paths resolve to actual files that are hosted on the server (during the switchover from Firebase hosting to GCS, we continued to upload the compiled JS files to both locations). However, we are not uploading the source maps to Firebase hosting, which explains the initial "Devtools failed to load source map." issue from the lazy-loaded modules User error on my part - thanks for patiently helping me work through the issue. To resolve this, sounds like I'd want to update the :asset-path to the GCS asset path

👍 1