Fork me on GitHub
#shadow-cljs
<
2018-11-23
>
miridius10:11:27

@thheller where does the :resource-name field come from in the rc map that the various shadow-cljs compiler functions use? I have a weird issue where increasingly large numbers of letters are being dropped from the beginning of the :resource-name for my cljs source files, which eventually causes the path to start with a /, which causes IllegalArgumentException: /middle-of-my-namespace/core.cljs.cache.transit.json is not a relative path when interacting with the cache. I scoured the source to try to figure out where the issue is coming from but I can't for the life of me figure out where the details for the source files are coming from.

thheller11:11:39

:resource-name is just a name. it is never used in any file ops.

thheller11:11:08

constructed like that for filesystem paths for example

thheller11:11:43

for classpath jars

thheller11:11:00

oh right its used there

thheller11:11:28

yeah forgot about those πŸ˜›

πŸ˜€ 4
miridius11:11:33

that's the function that's throwing an exception for me. I've figured out how to reproduce the issue as well, it happens if any of the source paths involve symlinks

thheller11:11:46

still the resource-name generation is pretty simple. not sure why it would mess up

thheller11:11:17

hmm what kind of symlink?

thheller11:11:41

windows/mac/linux?

miridius11:11:57

toy example:

.
β”œβ”€β”€ client
β”‚   └── core.cljs
└── src
    └── main
        └── my
            └── namespace
                └── client -> ../../../../client

thheller11:11:07

ah ok that makes sense

thheller11:11:59

this assumes that the canonical path of the file is always a child of the root

thheller11:11:03

which it is not in this case

miridius11:11:07

ah πŸ™‚

thheller11:11:44

ok. easy fix

thheller11:11:35

hmm not sure how well this plays with file watching though

thheller11:11:50

@miridius can you just swap the links around so that client -> src/main/my/namespace/client?

miridius11:11:13

not really, the reason for the links is that I'm trying to use polylith architecture (https://polylith.gitbook.io/polylith/), where the source is broken into components that are then symlinked into various systems as needed

miridius11:11:28

ideally the symlinked paths should be watched as well

thheller11:11:52

hmm yeah I just tested the fix and while it finds the file properly

thheller11:11:55

file watching does not work

thheller11:11:09

hmm polylith doesn't seems to make much sense for CLJS?

thheller11:11:26

since you can't build the system like that

miridius11:11:13

well I'm building a full stack app (with Fulcro) so there are server components, client components, and also shared components like the UI (used by server for SSR) and the API

thheller11:11:44

hmm by why is the direction of the link relevant?

thheller11:11:57

the end result from a file system perspective is the same?

miridius11:11:05

because it needs to be one-to-many so that one component can be in multiple systems

miridius11:11:29

although to be fair there will only ever be a single cljs system since as you said it can't really be split up

miridius11:11:37

so maybe it makes sense to do it that way

thheller11:11:46

not sure I understand you can still have as many links as you want?

miridius11:11:07

let's say I have a component "api", which is used by both the "server" system and the "client" system, but not by other systems. So it must have its source stored at /components/api/src, and then /systems/client/src/api and systems/server/src/api will link to it

miridius11:11:25

I do feel though that symlinks are kind of a pain, I'm wondering if the same result can be achieved by just using a more monolithic source folder and then having fine grained source-path settings in the build files for each system

thheller11:11:35

talk about making things uneccessary complex πŸ˜›

miridius11:11:39

haha πŸ™‚

miridius11:11:51

there's a leiningen plugin which does all the work for you

miridius11:11:40

it works great for pure clojure projects... clojurescript not so much πŸ˜„

thheller11:11:54

yeah because CLJS has a real build system unlinke CLJ

thheller11:11:04

so it doesn't matter how many files you have on the classpath

thheller11:11:13

the build will only include whatever was actually used

thheller11:11:42

alright. I think I got links working properly with watch

miridius11:11:20

awesome! and yeah I think you're right it doesn't make sense to use polylith for cljs. But since there's a lot of .cljc source files I'm not sure there's a way I could use polylith for the backend but then also have all the cljs source in one place. I'll have to think about it!

thheller11:11:49

@miridius try it with 2.7.6. I think it should work properly now

miridius12:11:53

@thheller it works! you're a legend :star-struck:

lilactown17:11:53

I wonder if we’ll ever get tree shaking on the JVM/CLJ

littleli17:11:40

It has little value on JVM

lilactown17:11:58

we’ll see once people are trying to create wasm modules from JVM languages πŸ˜‰

lilactown18:11:14

I’m kind of joking, but many of the langs who have attempted to positions themselves to take advantage of wasm have run into this problem where suddenly their ability to prune unused lib code is very important

littleli18:11:42

I would expect graalvm to provide solution for that.

thheller20:11:44

wasm is never gonna be a good target for JVM

thheller20:11:59

too much the JVM offers you'd need to replicate which makes files too large

gklijs20:11:05

When you create a native image with graalVM it sort of happens. And now you no longer need the whole JDK, for running Java it might become more important to also decrease the size of fat jars

littleli20:11:42

I believe there will be wasm interpreter for graalvm

gklijs22:11:01

I actually asked at Devoxx, and that do what some web output, but most lively this will be JavaScript. Also they are looking for some Electron integration also.

thheller20:11:02

maybe but if it requires a 10mb download to bootstrap its not gonna be very useful (for the web)

lilactown21:11:50

I wonder if you could download the necessary bootstrapping once and cache it for every website thereafter

richiardiandrea22:11:07

hi all! Question time! Do we have a way to enable *check-assert* in a shadow release compilation step?

thheller22:11:01

what is *check-asserts*?

thheller22:11:54

the only assert related option you have is :compiler-options {:elide-asserts false}. not aware of any other.