Fork me on GitHub
#clojurescript
<
2017-09-08
>
madstap00:09:20

@hlolli You're destructuring incorrectly, the keys in the :or map should be symbols.

madstap00:09:02

When I change them to symbols (on clojure 1.9.0-alpha17) it works as expected.

madstap01:09:06

Actually, I didn't see that we're in the clojurescript channel 😳 I can reproduce with clojurescript 1.9.660. Seems to happen with any arglist that includes a vararg.

ag01:09:24

hey guys, I've been trying to use new :npm-deps feature and it mostly works, I can't figure out how to do something analogous to Browserify's .external. Can someone help please.

ag01:09:30

when I do use (require '["enzyme/shallow" :as shallow] in nodejs environment - it works, but when I switch to browser, it doesn't

ag01:09:25

it says Can't resolve 'react/addons', in Enzyme's documentation https://github.com/airbnb/enzyme/blob/master/docs/guides/browserify.md it said:

// make sure to mark these as external!
b.external('react/addons');
b.external('react/lib/ReactContext');
b.external('react/lib/ExecutionEnvironment');

juhoteperi12:09:25

Browserify is the opposite of using Node packages directly, so this guide is not relevant in this case

juhoteperi12:09:50

Browserify is needed if you use lib through :foreign-libs

juhoteperi12:09:30

And react/addons is not found, because that file has been removed in React 15

ag17:09:12

that's right, it was removed, yet Enzyme still trying to require it (in case older version of React is being used). That's why they say to mark these

react/addons
react/lib/ReactContext
react/lib/ExecutionEnvironment
as "external", for browserify and webpack

juhoteperi17:09:39

Externals are used when building JS for browser use

juhoteperi17:09:44

when React is provided by separate JS file

juhoteperi17:09:50

which is not the case when using Node packages

juhoteperi17:09:36

... or not, read their guide again

juhoteperi17:09:47

ugh, JS is crazy again

juhoteperi17:09:46

Cljs or Closure doesn't have option to ignore modules

ag17:09:49

>which is not the case when using Node packages that's right. And it works for me when I do (require ["enzyme/shallow" :as shallow]) and run that in nodejs environment. But I really need the test run in a browser, headless or whatnot.

juhoteperi17:09:45

And I think it'll be hard to provide these modules yourself, as Closure won't look for Closure modules when doing Node dependency resolution

juhoteperi17:09:07

so you just can't provide empty react/addons foreign-lib or ns from Cljs

juhoteperi17:09:11

touch node_modules/react/addons.js could work, though it is not very good idea to modify file in node_modules

ag17:09:34

I guess my only option is to use cljsjs strategy and "sift" it through webpack or browserify, so it can be used in a browser environment

ag17:09:02

which is huge pain, that I really don't want to get into

ag01:09:58

so the bundler ignores these. How do I ignore deps in Clojurescript? it's trying to require('react/addons'), module I have to ignore it, but how?

juanjo.lenero02:09:54

How do you assign to a property in cljs?

juanjo.lenero02:09:08

I have a text input element

juanjo.lenero02:09:18

I want to clear its value

juanjo.lenero02:09:34

In JS I would do el.value = ""

juanjo.lenero02:09:08

(.-value el "") doesn’t work since .- only accesses properties

juanjo.lenero02:09:41

I thought maybe (.value el "") would work, but it doesn’t either.

juanjo.lenero02:09:57

where el is a dom element

juanjo.lenero02:09:13

nvm found the answer in cljs’ cheat sheet 😅

juanjo.lenero02:09:41

(aset el "value" "")

sundarj08:09:32

i think aset isn't supposed to be used on objects (even though it currently works, i think that's an implementation detail that could change)

sundarj08:09:44

you can use (set! (.-value el) "")

thomaslp02:09:41

i have a weird issue that is stumping me but im sure is easy

thomaslp03:09:00

nevermind i figured it out, just as silly as i thought it would be....never code when tired

reefersleep03:09:49

@thomaslp out of curiosity, what was it? Your snippet looks perfectly fine to me (except I never use :type :submit, always :button, not sure if there'd be a difference)

reefersleep03:09:01

Was the error elsewhere?

thomaslp03:09:40

it was in the on-click section of the button

reefersleep03:09:06

Oh, not an FN!

thomaslp03:09:19

#(do did the trick

reefersleep03:09:30

Classic tired mistake

thomaslp03:09:39

had a few too many of those this week haha

reefersleep03:09:46

(I'm tired too)

hlolli07:09:05

@madstap thanks for looking at this, good info there.

dnolen11:09:20

@hlolli file an issue in JIRA, thanks!

lsnape12:09:40

If I compile clojurescript with compiler opts {:closure-defines {'my-app.setup/app-env "test"} and :optimizations :simple, I would expect the following to load my test config:

(ns my-app.setup
  (:require-macros [my-app.config :refer [config]]))

(goog-define app-env "dev")

(config app-env)
But it loads the dev config, even though app-env has the value "test"!

lxsameer13:09:44

is the development process of cljs as the same as clojure ?

johanmynhardt13:09:53

This is my last hope. I may be getting worse at googling. Is it possible to use /#/path-style routes with bidi? I got my first attempt working without the hash-based routes. But it's a bit problematic when you have an app anywhere else than on the root of the domain. Am I missing something?

lxsameer13:09:34

I assume you meant on CLJS bidi is just a routing library you have to provide the route to it,

lxsameer13:09:56

so it's up to you to either use url fragment style or not