Fork me on GitHub
#clojurescript
<
2017-06-10
>
sophiago01:06:09

It's been a very long time since I've had to deploy cljs and I'm (rather oddly) having trouble getting all the js to compile to one file, i.e. without needing a dependency on goog. The project.clj is from a figwheel template, but I'm using cljsbuild and have :optimizations set to :advanced so not sure what's going wrong. Any ideas?

lsenta07:06:13

Hi #clojurescript do you have examples of distributing a clojurescript library as a regular javascript library?

thheller07:06:41

what kind of library? for the browser or node?

lsenta07:06:42

Nice I'll look into these, thanks @thheller

thheller07:06:59

it isn’t very practical to publish libraries like that since they all include cljs.core by themselves and cannot share it

thheller07:06:15

so they get larger than typical js libs otherwise would be

lsenta07:06:55

But there's no better way, right? Since cljs use the closure goog.require, it'll break with other packaging/import system?

thheller07:06:32

:advanced compiled code doesn’t contain goog.require anymore but yes

thheller07:06:18

closure wants to optimize your whole program, which includes all the libraries you use

thheller07:06:36

that doesn’t work too well if you want to just ship a library

thheller07:06:00

if you want to build a lib for node you can use

thheller07:06:33

in theory this can be used for browsers but I don’t think its a good idea to do so

dnolen12:06:13

@roman01la then that’s contradictory to what you said earlier

dnolen12:06:57

there’s just no way to accomplish what you want unless you want to go bootstrapped

youngleehua13:06:50

hi, does anyone has an idea on how to import a scoped npm package in clojurescript? I tried something like "{:npm-deps {:@dp/whatever "2.0.10"..." but failed with the message "java.lang.RuntimeException: Invalid token: :"

youngleehua14:06:08

And it fails even when I use something like "(keyword "@dp/whatever") "2.0.10"..."

curlyfry14:06:39

@chrisdavies @metametadata @shaunlebron I use ‘humane-test-output‘ for prettifying my test output, works well

chrisdavies14:06:59

@curlyfry I wasn't able to get it to play nice with cljs.test, but I must have been configuring it improperly.

chrisdavies14:06:22

Do you have a sample project.clj where you've configured it?

curlyfry15:06:49

@chrisdavies Could this be the problem? https://github.com/pjstadig/humane-test-output/issues/15 Solution in the issue!

chrisdavies16:06:22

That helped! Thanks. It wasn't exactly right, but it got me the rest of the way. :thumbsup:

chrisdavies14:06:32

(Oh, and thanks! :)

rauh14:06:19

@thheller Could shadow cljs rewrite something like new cljs.core.Keyword(...) to cljs.core.keyword_intern?

thheller15:06:07

@rauh why would it? it rewrites to cljs$cst$keyword$… and only allocates once?

thheller15:06:27

basically :optimize-constants?

rauh15:06:29

@thheller Yeah, but if I create one at runtime with the same name I have two keyword instances. I can't get the global constant in any way.

thheller15:06:36

but no there is no generic rewrite facility in place

rauh15:06:10

Hmm I see, I'd have to hack on the emitter. Kinda don't wanna do that.

thheller15:06:25

yeah should still be easier than writing a closure compiler pass to do it 😛

thheller15:06:24

@rauh whats the state of weak refs in JS engines? maybe we can default to interning at some point

rauh15:06:11

Still no-go, even with the Weak Sets/Maps. I'd like an option in cljs but it'd def be big undertaking. For browser JS I don't need any weak refs since there is no attack vector. Only really needed for server side JS.

thheller15:06:05

all it would take is a simple change in the compiler to not emit new cljs.core.Keyword but actually calling the keyword fn

thheller15:06:14

then you could replace that fn and be done

thheller15:06:54

maybe a special keyword fn so the pre-hash works

rauh15:06:57

Yeah, I could also hack the deftype and replace it with real constructor. But it's too hacky.

thheller15:06:55

IIRC its a simple change though

thheller15:06:24

just replace that fn 😉

rauh15:06:33

Yeah I know, but I kinda wanted to stay out of cljs.compiler namespace changes

thheller15:06:28

yeah it isn’t pretty but I do it in some places

thheller15:06:33

it works well enough

gmercer15:06:31

but it works in

Planck 2.5.0
ClojureScript 1.9.562
and
Lumo 1.5.0
ClojureScript 1.9.542

gmercer16:06:58

caching it was!! but of old devtools 😢