Fork me on GitHub
#clojurescript
<
2016-11-14
>
iku00088808:11:59

Can confirm that same thing happens

iku00088808:11:00

but on the other hand I do not see how it would be an issue esp. in a browser context?

dbsgtk08:11:11

Well i want to read a file at compile time

iku00088808:11:46

That would totally makes sense... Sorry, never had to do that...

iku00088808:11:44

What kind of data would be in that file (Now I am just asking out of curiosity...)?

dbsgtk08:11:43

Its a scoring matrix used in bioinformatics sequence alignments

dbsgtk08:11:23

The app is for exercises for students

iku00088808:11:27

And I am assuming the browser file api does not get the job done?

iku00088808:11:32

I asked the guy sitting next to me. I think you can just say slurp without any namespece prefix

iku00088808:11:00

(clojure.core/slurp file) => (slurp file)

thheller08:11:55

@dbsgtk It is generally a better idea to load data when the app starts instead of turning data into code

thheller08:11:51

makes it easier to switch the data as well as you don't need to recompile

thheller08:11:04

besides that is your macro in a .clj file?

thheller08:11:12

or .cljc by any chance?

rackdon10:11:16

I’m trying to use goog-define but I can’t make it works. This is my code:

In the cljs file:

(ns web.server)
(goog-define server-client-id “website-dev”)

In the project.clj:

:closure-defines { ‘web.server/server-client-id "website"}
 :optimizations :advanced
The problem is that when I compile the code, server-client-id is website-dev instead of ‘website’… Could anyone help me?

thheller11:11:14

Note when using Lein the quote is unnecessary due to implicit quoting.

thheller11:11:25

:closure-defines { web.server/server-client-id "website"} does that work?

rackdon11:11:12

nop, I tried too but it didn’t work 😔

pesterhazy11:11:14

your asssumption is that project.clj overrides the ns def?

rackdon11:11:06

I think that it should override the server-client-id variable at compiling time no?

pesterhazy11:11:55

ah I wasn't aware that's how it worked

snoonan12:11:36

How repeatable is the order of keys in a hash guarenteed to be? Will different hashes with the same keys always be iterated over in the same order?

pesterhazy13:11:07

@snoonan, I think: 1. on the same version of clojure(script), it should be repeatable; 2. this is an implementation detail that you shouldn't rely on, even accidentally

pesterhazy13:11:24

but not in a position to know really

firthh13:11:26

I think you could use a sorted-map if you need guarantees about order - https://clojuredocs.org/clojure.core/sorted-map

am-a_metail14:11:41

@rackdon - did you sort it? :closure-defines { web.server.server-client-id "website"} in web.server (goog-define server-client-id "_unset_") (println server-client-id) ; unset or website, depending on whether passed in during build

rackdon14:11:48

Finally I made work, the problem was other but I didn’t have any clue so I thought the problem was with closure 😓

rackdon15:11:00

As @thheller said, :closure-defines { web.server/server-client-id “website”} works perfectly

dnolen15:11:38

@rackdon what was the problem?

rackdon15:11:49

I had compiled without minifying before, and I have a main field in the project.clj so it didn’t compile the minified part, but because I had the coded compiled before, I thought everything was ok in the compilation process 😅

digioi15:11:50

@pupeno About using JS Promises in a more core.async way i came across this https://github.com/jamesmacaulay/cljs-promises

sophiago17:11:46

i know this is old news per here: https://groups.google.com/forum/#!searchin/clojurescript/ANN%7Csort:date/clojurescript/a7KnSSwJsbk/cwv0RduyCwAJ, but still having trouble getting core.spec.test to compile with 1.9.198 and alpha14. i've done a clean and install, switched from :refer-macros to :refer, so not sure the issue?

anmonteiro17:11:23

@sophiago I'll make a best guess and say that you don't have clojure.test.check in your dependencies

anmonteiro17:11:56

if that's not the issue, happy to look at a stacktrace

sophiago17:11:46

didn't need that for straight clj

anmonteiro17:11:08

because Clojure lazy-loads clojure.test.check whenever you call a function that depends on it

anmonteiro17:11:30

We can't do that in ClojureScript

anmonteiro17:11:06

the fact that you didn't get an error in Clojure might just be related to the fact that you didn't call any clojure.spec.test functions that depend on test.check

sophiago17:11:45

wait, i'm having trouble reconciling the two parts of that. you mean it didn't have a compile time error due to the :require, but it would have had a runtime error had i used it?

sophiago17:11:53

on the clj side?

sophiago18:11:09

good to know. i'll fix that too. so to be clear: just test, not spec needed in deps? and do i need a version number? if so same as the clojure alpha?

anmonteiro18:11:09

clojure.spec.gen too

sophiago18:11:05

sorry, and no version needed?

anmonteiro18:11:22

oh, hrm, the latest version of clojure.test.check should be good

sophiago18:11:34

i'm saying i can't tell what that is. i assume same as the clojure alpha i'm using right?

sophiago18:11:54

it's not it's own repo

sophiago18:11:17

@anmonteiro yeah, lein isn't able to find them on clojars so clearly i'm doing something wrong in deps. could you link me to a sample project file maybe?

markx19:11:08

I finally got a cljs project setup and run. I have to say, this is not very beginner friendly...😅

dnolen19:11:35

@markx I’m assuming you tried to do something from scratch and not a template?

markx19:11:48

That’s true.

markx19:11:26

Well.. I used lein

dnolen19:11:39

@markx yes, if you’re trying integrate some custom web stuff - very little is obvious

markx19:11:51

so not really from scratch

dnolen19:11:10

well Lein doesn’t really help that much 🙂

markx19:11:16

No, I didn’t integrate anything. I was just trying to setup a “hello world” project

dnolen19:11:26

@markx so no web server component?

markx19:11:42

I don’t know what that is ...

dnolen19:11:06

@markx meaning you didn’t use a webserver, you’re just loading a index.html in your browser directly or something

markx19:11:37

oh, right, I didn’t use a webserver.

markx19:11:07

I spent a lot of time on the project.clj file, just to get the project build and run

dnolen19:11:42

@markx hrm ok, following the lein-cljsbuild README?

markx19:11:09

I just tried figwheel, and it worked. Then I disabled figwheel, and it broke again.

markx19:11:27

play-clojurescript/resources/public/resources/public/js/out/goog/base.js

markx19:11:38

why does it try to load goo from here?

markx19:11:15

I didn’t set anything like /resources/public/resources/public

dnolen19:11:05

@markx are you sure? what did you supply for :output-dir?

markx19:11:05

@dnolen Oh man, you are right. It was :output-dir.

markx19:11:44

output-dir is to 'Sets the output directory for temporary files used during compilation. Defaults to “out”.'

markx19:11:43

So how is this related to goo?

dnolen19:11:19

@markx goo ? do you mean goog ?

markx19:11:10

@dnolen Yeah, I’m sorry, I meant goog

dnolen19:11:23

@markx ok, but what is your question?

markx19:11:46

output-dir is to 'Sets the output directory for temporary files used during compilation. Defaults to “out”.’ How is this related to goog?

anmonteiro19:11:55

@sophiago sorry I don't have a sample project at hand. anyway, the test.check JARs are probably not in Clojars, but in Maven

sophiago19:11:20

well, lein checks both so it must be the way i'm writing the deps

markx19:11:56

@dnolen Or maybe not goog, but the path of files?

dnolen19:11:50

@markx :output-dir is the root where we write out JS output files

dnolen19:11:07

everything goes there, including copies of Google Closure Library stuff like goog/…

markx19:11:56

I mean, this influence is not mention in the doc. In my understanding, the option is to set directory for temp files, so whatever file in the directory should not be needed for running the project.

sophiago19:11:07

@anmonteiro i was just trying [clojure.spec.test.check] [clojure.spec.gen] but have since tried many permutations and none found on maven or clojars...

anmonteiro19:11:25

[clojure.test.check "0.9.0"]

sophiago19:11:49

the only version i had tried was "1.9.0-alpha14" 😛

dnolen19:11:01

@markx I don’t know why you think that - can you point to the documentation that confuses you?

markx19:11:57

@dnolen It says "for temporary files used during compilation"

sophiago19:11:00

yikes, don't know why i couldn't turn that up on my own. only found the part of core. anyway, thanks!

dnolen19:11:22

@markx I can see why you might be confused by that

markx19:11:51

@dnolen I don’t see how one can not be. Unless my mistake was in English.

dnolen19:11:26

@markx the confusion would be the interpretation of "temporary files"

dnolen19:11:45

that these are transient in some way or not used - that would be incorrect

markx19:11:27

Yeah. I think it’s better now. Thanks!

dnolen19:11:41

@markx thanks for pointing it out

sophiago19:11:11

@anmonteiro all good. thanks!

hlolli19:11:12

Is there a way to manually add .js dependency to cljs. I have ace.js online code editor working with externs, but when ace calls for a theme file (basically js css injection) it will not be found when seeking for it in out/theme.js. I'd like to avoid manually drag-drop the file if possible.

dnolen19:11:20

@hlolli yes :foreign-libs

hlolli19:11:54

ok, was trying that, but would I need to provide :provides if I only want the resource?

hlolli19:11:19

maybe its a figwheel issue, try compileing, glad to know that its possible!

skrat20:11:35

anyone knows how to create a CLJSJS package for a library that has closure annotated sources? do I still need to provide externs? can't I simply use the non-minified, concatenated version of the library as externs file?

dnolen20:11:57

@hlolli :provides it just so we know how to require it - you can make up whatever name you like

hlolli20:11:35

ahh understand!

hlolli20:11:10

This works, but its now compiled inside a javascript file, so a get request for a specific file that this library ace is looking for wont therefore exists. This is as far as i see rather google closure unfriendly project. And I will just copy paste these js-css themes to garden or something.

dnolen21:11:13

@hlolli I don’t understand your problem

dnolen21:11:21

Ace tries to load random JS files from the internet?

hlolli21:11:36

@dnolen Ace tries to find theme (and mode) files which are defined in seperate .js files. I believe I misunderstood the problem myself and don't think its connected. The problem is probably due to a function that is called define which is defined in ace.js. But to make less noise, Im going to scratch my head over this for few hours until I can get to the root of the problem. 🙂 (probably a McChickenBurger will give me some brain boost...)

hlolli23:11:21

so my problem was that :requires within :foreign-libs was missing, causing the order of dependencies to be wrong. Glad to find out.

juhoteperi23:11:22

@skrat Cljsjs has a few existing Closure libs, like: https://github.com/cljsjs/packages/tree/master/kemia In short: Place the source files to correct path in jar file and define :libs property in deps.cljs with path to those files