Fork me on GitHub
#shadow-cljs
<
2023-07-17
>
borkdude16:07:10

I'm loading a .js file from the classpath in a shadow project:

["/squint/core" :as squint-core]
Compiler says no though:
Closure compilation failed with 1 errors
--- squint/core.js:456
Transpilation of 'Computed fields' is not yet implemented.
What's going on here again?

thheller16:07:07

pretty self explanatory no? using something the closure compiler doesnt support

borkdude18:07:48

sure, but how do I get the Closure compiler to not process this JS at all? I just want to use it as is

borkdude18:07:12

for npm libs I know how to do this, but with code from the classpath I don't

thheller18:07:05

it must be processed so it can be loaded

borkdude18:07:28

There was a :keep-as-import setting right?

thheller18:07:42

if this is within a normal :esm build you can use ["esm:./squint/core" :as squint-core] instead as the require

thheller18:07:01

that will leave it exactly as is and let the runtime load it at actual runtime, so not part of the build

thheller18:07:13

(not on the classpath then obviously)

thheller18:07:38

or just rewrite the code it doesn't understand 😛

borkdude15:07:18

The offending bit is this:

// class LazyIterable {
//   constructor(gen) {
//     this.gen = gen;
//   }
//   [IIterable] = true;
//   [Symbol.iterator]() {
//     return this.gen();
//   }
// }
I'm not sure if I can rewrite this to something that Closure understands

borkdude15:07:28

If I remove this, the compilation works

borkdude15:07:40

It seems that this is the offending line:

[IIterable] = true;

thheller15:07:04

you can do LazyIterable.prototype[IIterable] = true after the class definition. that should behave exactly the same.

borkdude15:07:22

amazing, thanks

AJ Snow17:07:29

hey beginner question I'm starting a new cljs project and following along with the docs when I just try running shadow-cljs commands I get a could not find error here's a snippet

shadow-cljs - dependency update failed - Could not find artifact com.sun:tools:jar:1.8.0 at specified path C:\Program Files\Java\jre1.8.0_341/../lib/tools.jar
DependencyResolutionException Could not find artifact com.sun:tools:jar:1.8.0 at specified path C:\Program Files\Java\jre1.8.0_341/../lib/tools.jar
org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies (DefaultRepositorySystem.java:355)
I assume this is some sort of problem related to finding java on the classpath but I'm not sure how to fix it. has anyone seen this issue before?

thheller18:07:07

looks like you have the JRE installed when you need the full JDK

thheller18:07:24

also java 1.8 is no longer support and you need java 11 minimum

thheller18:07:14

try installing the latest version from https://adoptium.net/

thheller18:07:29

11+ is all good, doesn't really matter which

AJ Snow18:07:20

thank you! I will follow up with more info about my findings

AJ Snow19:07:39

It worked! Thanks Thomas. Problem: Could not find artifact ... Solution: Uninstall java 1.8 if you still have it. Install newer versions of java, at least 11. example: https://adoptium.net/

👍 2
AJ Snow19:07:44

Problem: I run shadow-cjs run <namespace/function> and it says namespace not found (possible) Solution: Make sure the filetype is .clj not cljs. I don't think you can run .cljs files

AJ Snow19:07:38

yeah i didn't realize it was only for clj mb