Clojurians
#cljs-dev
<
2017-03-01
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

roman01la11:03:33

@anmonteiro I couldn’t compile a project with :npm-deps using your patch. Getting this error Exception in thread "main" java.io.FileNotFoundException: resources/public/js/compiled/out-min/cljs$node_modules.js (No such file or directory)

anmonteiro15:03:26

@roman01la thanks, I'll have a look later

anmonteiro17:03:58

I’m surprised no one has reported this before, but Node.js support seems broken in 1.9.494

anmonteiro17:03:23

smallest repro:

(ns example.core
  (:require [cljs.nodejs :as node]))

(node/enable-util-print!)

(println "hi")

anmonteiro17:03:31

just compile that with :target :nodejs

richiardiandrea17:03:50

uhm, I am using lumo for node that is why I haven't notice it

richiardiandrea17:03:56

let me try with replumb

anmonteiro17:03:01

hrm still broken in 1.9.473

anmonteiro18:03:26

hrm, broken for me going back to 1.9.229, at which point I’m starting to believe it’s a problem with my Node version

anmonteiro18:03:34

so probably false alarm

richiardiandrea18:03:15

yes it works here :slightly_smiling_face:

anmonteiro18:03:19

OK false alarm, I forgot to add :main to my compiler options

anmonteiro18:03:58

@dnolen still shouldn’t we require :main to be present if :target :nodejs?

anmonteiro18:03:14

probably worth validating that since it can lead to unexpected errors like this ^

anmonteiro18:03:44

tripped me up and I’m not properly a beginner

anmonteiro18:03:38

^ patch attached

dnolen18:03:17

@anmonteiro ok, makes sense

dnolen19:03:49

I’ve changed the compiler so we return nil if for some reason we can’t examine the contents of a JAR https://github.com/clojure/clojurescript/commit/86f26bf267f1c729313320c38e53e64450c0e68d

dnolen19:03:57

ran into a case where some 3rd party JAR is empty

dnolen19:03:32

since the JAR inputs are sourced from the JVM anyhow I don’t see how this could be a problem

anmonteiro21:03:17

just replaced the patch in http://dev.clojure.org/jira/browse/CLJS-1960 with an updated version that fixes some annoying stuff

anmonteiro21:03:27

/cc @roman01la

anmonteiro22:03:02

^ so ready for the next round of feedback :slightly_smiling_face:

richiardiandrea22:03:10

@anmonteiro I have no errors now but your example with react does not really apply to aws-sdk does it?

anmonteiro22:03:30

why wouldn’t it apply?

richiardiandrea22:03:32

I mean can I do (:require [aws-sdk :as AWS]) ?

richiardiandrea22:03:07

how to trigger the resolution and how to verify that it actually happens

anmonteiro22:03:38

so you need to add aws-sdk to the :npm-deps entry in the compiler options

richiardiandrea22:03:44

in normal bootstrap I do (def AWS (js/require "aws-sdk"))

richiardiandrea22:03:52

yep the above is done

anmonteiro22:03:00

then you can just require it in your namespace

anmonteiro22:03:23

if it doesn’t work you’ll know because the compiler will throw an error saying it can’t find the namespace

richiardiandrea22:03:26

ok I see a nice new message: No such namespace: aws-sdk, could not locate aws_sdk.cljs, aws_sdk.cljc, or Closure namespace "aws-sdk" in file src/web/rest_resources_viz/core.cljs

richiardiandrea22:03:36

so at least the error message works :smile:

anmonteiro22:03:04

is there a aws-sdk folder in node_modules?

richiardiandrea22:03:01

uhm, trying again, maybe I am doing something wrong on my side, will get back to you

moxaj22:03:25

@anmonteiro this might be a stupid question, but with this feature, could I use node deps in browser builds? since, afaik, node uses commonjs modules, and closure can convert them to closure modules

anmonteiro22:03:55

Yes, this is not limited to Node.js target

moxaj22:03:04

hella awesome

anmonteiro22:03:59

@moxaj it goes without saying the module must also target the browser

moxaj22:03:09

yes, I'm aware of that

anmonteiro22:03:24

there might also exist some hiccups e.g. when using React for the browser

anmonteiro22:03:37

saying for example that process.env is not defined

anmonteiro22:03:42

but you can easily work around that with a goog-define

moxaj22:03:24

set my eyes on a nice js lib, not packaged yet with cljsjs, but available as a node lib, so this would help immensely

anmonteiro22:03:56

@moxaj you can already use it today, my patch just makes it easier

shaun-mahood22:03:53

I figured out enough to test http://dev.clojure.org/jira/browse/CLJS-1868 and it looks good to me - it was my first time diving into CLJS itself (to experiment with the patch), applying a git patch and compiling it. Altogether a pretty fun experience! Does anyone think it would be worth trying to add a test for this as well?

moxaj22:03:15

@anmonteiro oh I never knew, cool!

richiardiandrea22:03:52

@anmonteiro I think I am getting the old version of the patch because it still returns: EOF while reading, can you try posting a -1 version?

richiardiandrea22:03:20

or maybe this is a new error I am getting

anmonteiro22:03:03

that doesn’t make sense

anmonteiro22:03:14

just looks like unbalanced parens in your code?

richiardiandrea22:03:15

right, there was an empty src/web/deps.cljs left there :disappointed:

shaun-mahood23:03:07

Is there a preferred way to highlight tickets that can probably be declined in Jira? For example, http://dev.clojure.org/jira/browse/CLJS-1962 is only related to the docs on http://clojurescript.org and probably doesn't belong in Jira. Just add a comment? How about tickets that are duplicates (http://dev.clojure.org/jira/browse/CLJS-1693 looks like the same as http://dev.clojure.org/jira/browse/CLJS-1868)?

anmonteiro23:03:14

@richiardiandrea the $ being present in the filename is not the cause of what you’re seeing, that’s just how the $ character works in the shell

anmonteiro23:03:23

can you produce a repro I can try?

richiardiandrea23:03:23

@anmonteiro nope don't have one, I guess it is working with build.clj right? I am trying with boot-cljs, the problem might be there...

anmonteiro23:03:22

the path is incorrect

richiardiandrea23:03:31

Don't want to waste your time on that, I had a couple of minutes only and decided to try on an existing prj

anmonteiro23:03:20

@richiardiandrea since you have a CLJS source locally, can you try and remove the path.resolve call here? https://github.com/anmonteiro/clojurescript/blob/node-modules/src/main/cljs/cljs/module_deps.js#L6

richiardiandrea23:03:01

Sure I can, let me do that

anmonteiro23:03:25

hrm, that might not be what’s wrong though, but it’ll be good to rule something out

richiardiandrea23:03:33

@anmonteiro with var filename=""; gives all sorts of other weird error

richiardiandrea23:03:59

probably a string is not the expected thing here

anmonteiro23:03:49

I just said to remove the path.resolve call

anmonteiro23:03:52

not the others :slightly_smiling_face:

richiardiandrea23:03:07

ah ah ok :smile:

anmonteiro23:03:12

so that the line becomes var filename = path.join(__dirname, 'JS_FILE');

richiardiandrea23:03:30

@anmonteiro Error: Cannot find module 'home/arichiardi/.boot/cache/tmp/ifl/-d8mh6z/main.out/cljs$node_modules.js' from '/home/arichiardi/git/rest-resources-viz'

anmonteiro23:03:53

hrm just looks like Boot hates absolute paths :slightly_smiling_face: