Fork me on GitHub
#shadow-cljs
<
2023-10-28
>
itaied09:10:33

Hey all, I want to export my project as a lib. How can I set which namespaces to be exported? In the docs I could only find exporting symbols in namespaces https://shadow-cljs.github.io/docs/UsersGuide.html#_module_exports

thheller09:10:38

as a lib for who? CLJS consumers or JS consumers?

thheller09:10:25

CLJS libs are not built and published as source only, so there are no options for shadow-cljs since it has nothing to do

itaied09:10:42

thanks 👍

itaied10:10:44

how can i add dependencies from a private repository with authentication?

thheller10:10:30

best to use deps.edn or leiningen for that, assuming you mean maven dependencies. npm you just use npm

👍 1
itaied11:10:10

Hi again, I have successfully configured deps.edn and I could see that the package has been downloaded both in console and in my m2 folder. I'm having difficulties to import from the package tho. I have built it with maven with the following pom.xml:

...
<groupId>io.acme</groupId>
<artifactId>lib</artifactId>
<version>1.0.0-SNAPSHOT</version>
...
I have set a variable name VARIABLE in the ns lib. I have tried the following, and none worked: :require • [io.acme.lib :refer [VARIABLE]][io.acme][lib] It's all failed with "the required namespace is not available". I think that I might have forgot something in the build maybe?

thheller14:10:58

the name of the artifact does not need to match the code namespaces that are in it

thheller14:10:34

for example there is thheller/shadow-cljs but the namespaces are shadow.*

thheller14:10:12

I guess you can list the contents of the jar via jar -tvf the-actual.jar and find the namespaces that way?

itaied15:10:46

0 Tue Oct 31 10:58:00 IST 2023 META-INF/
   128 Tue Oct 31 10:57:58 IST 2023 META-INF/MANIFEST.MF
     0 Tue Oct 31 10:58:00 IST 2023 META-INF/maven/
     0 Tue Oct 31 10:58:00 IST 2023 META-INF/maven/io.acme/
     0 Tue Oct 31 10:58:00 IST 2023 META-INF/maven/io.acme/lib/
   970 Tue Oct 31 10:57:48 IST 2023 META-INF/maven/io.acme/lib/pom.xml
   116 Tue Oct 31 10:58:00 IST 2023 META-INF/maven/io.acme/lib/pom.properties

thheller15:10:03

so there are no actual source files included I guess?

thheller15:10:25

thats just the META-INF dir, which only contains metadata info about the jar itself

thheller15:10:57

if this is a .cljs lib then there should be .cljs files

itaied15:10:33

I understand. Can you help me find what did I do wrong? I built it using the following pom.xml

<project xmlns=""
    xmlns:xsi=""
    xsi:schemaLocation=" ">
    <modelVersion>4.0.0</modelVersion>
    <groupId>io.acme</groupId>
    <artifactId>lib</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    
    <repositories>
        <repository>
            <id>gitlab-maven</id>
            <url>${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven</url>
        </repository>
    </repositories>

    <distributionManagement>
        <repository>
            <id>gitlab-maven</id>
            <url>${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven</url>
        </repository>
        <snapshotRepository>
            <id>gitlab-maven</id>
            <url>${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven</url>
        </snapshotRepository>
    </distributionManagement>
</project>
and settings xml:
<settings xmlns=""
    xmlns:xsi=""
    xsi:schemaLocation=" ">
    <servers>
        <server>
            <id>gitlab-maven</id>
            <configuration>
                <httpHeaders>
                    <property>
                        <name>Job-Token</name>
                        <value>${CI_JOB_TOKEN}</value>
                    </property>
                </httpHeaders>
            </configuration>
        </server>
    </servers>
</settings>

itaied15:10:16

is there anything else required for publishing a lib other than pom.xml?

thheller15:10:47

sorry I never published a library using only maven, and have no clue what that would look like. to me it looks like there are no source paths included. can't tell you how to get that though.

itaied15:10:58

ok thank you very much! Ill dig deeper

thheller15:10:59

:source-paths ["src/main"] lein will take the files found in that dir and put them into the jar

itaied15:10:17

yea just found about it...https://www.baeldung.com/maven-add-src-directories By default, Maven uses the /project-path/src/main/java directory as the only source directory. I'll probably transfer to lein soon tho Thanks again

thheller15:10:10

tools.build can also easily build jars

itaied16:10:05

When using lein to deploy to a maven repo, do I need to duplicate the deps from deps.edn?

thheller16:10:51

yes, lein does not use deps.edn

itaied17:10:16

do you have a suggestion how to handle both publishing and managing dependencies with a single source of truth?

thheller18:10:41

I use leiningen

thheller18:10:59

if you use deps.edn it might be good to use tools.build, but I never tried that yet

itaied18:10:20

ok thanks 👍

jsn19:10:28

Hi everyone. Is there a way for shadow-cljs :dev-http to proxy websocket requests to :proxy-url ? In my tests it just responds like the request was basically a GET / w/o Upgrade headers.