This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-28
Channels
- # aws (1)
- # aws-lambda (1)
- # beginners (19)
- # boot (7)
- # cider (9)
- # cljs-dev (311)
- # cljsjs (34)
- # cljsrn (8)
- # clojars (7)
- # clojure (41)
- # clojure-argentina (3)
- # clojure-russia (15)
- # clojure-spec (15)
- # clojure-uk (11)
- # clojurescript (83)
- # datomic (45)
- # emacs (7)
- # hoplon (13)
- # klipse (2)
- # lein-figwheel (1)
- # luminus (3)
- # om-next (1)
- # parinfer (5)
- # perun (1)
- # planck (1)
- # reagent (5)
- # spacemacs (2)
- # untangled (1)
- # yada (1)
I'm seeing 'dirname is not defined' with fw on nodejs. The only thing I can think of is that dirname is context sensitive (I think?) and fw's client breaks the context. anyways, reverting the bootstrap node changes in 59a7f26 fixes
@pat sounds like something to report to figwheel and then see if it can’t be sorted there first
@dnolen might be the same issue as require
I think __dirname
and __filename
may need to be bound to global
@anmonteiro I don’t know about filename since that needs to be done by require
hrm, but I guess we should bind it at root, and expect require
to do the right thing later
I'm referring to this comment: https://github.com/nodejs/node-v0.x-archive/issues/9211#issuecomment-134412415
@dnolen I'll have something for you tonight
@dnolen A typo in externs guide: Cannot infer target type in expression (.bar x) ...
-- the code above calls (.baz x)
.
@dottedmag you can edit that page here: https://github.com/clojure/clojurescript-site/blob/master/content/guides/externs.adoc
@anmonteiro hey 🙂 did you try running this: https://github.com/swannodette/es6-demo/compare/closure-master?
I haven't, not yet
having trouble?
@anmonteiro an idea by any chance how that deps.cljs
has been generated?
I’m currently looking into how cljsjs could utilize the new stuff. Your changes to Om seem like it would be relatively straightforward, the es6-demo however seems very different (i.e. all files are provided as foreign lib individually)
if I had to guess, I'd say it's these new functions: https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/build/api.clj#L222-L292
going to bed now, curious to see what you come up with. Hope the above helps
Well, don’t expect too much haha 😄
Good night 🙂
Thanks for the pointer
doh, just node test.js
😉
got React production build working with env variable set via
(ns process.env)
(goog-define NODE_ENV “development")
:closure-defines {'process.env/NODE_ENV "production"}
React + ReactDOM no env var 71KB gzipped env set to “development” 69KB gzipped env set to “production” 52KB gzipped
it’s funny that development build with env var set has less code that the one without 😄
however, Webpack production build is 42KB gzipped
@dnolen trying the latest cljs with shadow-build, I get literally thousands of infer warnings although I did not enable it anywhere WARNING: Cannot infer target type in expression (. cljs.core/PersistentVector -EMPTY-NODE) ...
probably missing some setup in shadow-build but I'm confused why this code is reached at all
@dnolen not shadow-build related, if you actually enable :infer-warnings
globally you get many many warnings everywhere
would produce warnings for cljs.core
as well but it is using the cached version so it is hidden
so the warning is always generated, it is just silenced when *warn-on-infer*
is not set
looks like only a tiny figwheel tweak to get file reloading on dir based foreign libs
Right now I'm adding foreign libs to the watched paths by default, hasn't been a problem so far. But I'm think I'm going to need to make this explicit instead of implicit.
@roman01la can you share your project maybe?
@martinklepsch I would just refer to the guide now, it covers everything from es6-demo but with like - documentation
@dnolen good morning 🙂
basically we shell out to node
to run module-deps
on a your specified CommonJS entry point
the interesting part about the es6-demo was how it integrated React or “npm library code” more generally
@dnolen that is not what I meant. I meant that there is no way to actually toggle :infer-externs
as off, the work is always done.
@martinklepsch but the JS guide covers that as the last thing - I don’t know what you mean
@dottedmag thanks fixed
I did update the deps.json
by running node test.js > deps.json
but got stuck after a while with this one:
ERROR: JSC_COMMONJS_MODULE_LOAD_ERROR. Failed to load module "react" at /Users/martin/code/es6-demo/src/libs/NodeStuff.js line 2 : 12
Exception in thread "main" java.lang.IllegalStateException: Cannot build without root node being specified
I read the last section on the docs page but it doesn’t give much more info than “it might not be possible"My motivation of using es6-demo was to have something working and tinker with that as foundation
@martinklepsch I keep saying that the guide shows you how to do all this 🙂
@martinklepsch which part “might not be possible"
the reason you’re failing at that spot is that module-deps
doesn’t add package.json
entries
maybe but it’s hard to say I think using es6-demo
here is very counterproductive for everyone 🙂
I think it would be cool to have it working so it can serve as a playground for people interested in messing around with the module stuff
@martinklepsch right, but I don’t know why you can’t do that with the final example in the guide is all I’m saying
> the reason you’re failing at that spot is that module-deps
doesn’t add package.json
entries
you mean as in it fails because react isn’t in package.json? (it is so I guess I’m misunderstanding)
es6-demo was a hack and I didn’t document all the details that I fixed in ClojureScript itself
@martinklepsch so let’s rewind and let me explain how it works
In es6-demo could I require react from core.cljs
? I think this is where my misunderstanding might stem from
@martinklepsch only if you supply a :provides
right, ok. I think I’m slowly catching up 🙂
so ClojureScript shells out to get the CommonJS deps so we can give the Closure Compiler all the inputs
@dnolen what I'm seeing it that :provides [React]
is not putting an entry in cljs-deps.js
ok, 1s here. What needs to include package.json entries? and what is main:
in that context? is that a node/npm thing?
@martinklepsch Node.js dep resolution
ok, so that’s what goes into require()
essentially
oh, ok, that clears up the confusion about that part
@martinklepsch https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/build/api.clj#L298
@dnolen yup, the pieces start to fit a bit more. I think you gave me enough to chew on for now. Thanks for taking the time to explain! I’m sure I’ll be back though 🙂
goog.provide("module$resources$js$react");var module$resources$js$react={};
(function(f){var module$resources$js$react=f()})(function(){var define,module,exports;re
the code there is just Google Closure rewriting that CommonJS module into a Google Closure namespace
so what I'm saying is that :provides used to reify module$resources$js$react into the global env
it is a novel behavior change in the relationship between require/:provides in foreign libs for common js
https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/closure.clj#L1958-L1961
right there are harder problems to sort out here that we haven’t even gotten to yet as well
@bhauman right, I think for Figwheel you just need the original aliases in the goog.addDependency(…
calls
right so I'm going to get off of this common js stuff for the moment and just get things in figwheel working for dir based foreign libs
@roman01la the reason you weren’t seeing this result is because of :target :nodejs
@dnolen: what does it mean "what FB provides"
Ah, ok. The stats I reported was for React + React DOM browser, want using Node as a target or println
*wasn't
There was also a diff between Webpack and cljs build in 10 kb, I think that's because of runtime overhead, but @martinklepsch pointed out that cljs runtime should be elided, so I'm not entirely sure if Closure Compiler can optimize React as JS optimizer, but that doesn't make sense to me
I've used Webpack 2, not sure how Facebook do it
So there might be a runtime or Webpack 2 can elide more stuff
Not sure how to compare both builds properly to find out
@roman01la: I thought they used browserify
Should be in the React repo somewhere
Not sure how worthy the comparison between webpack/browserify is though....
@anmonteiro: I mean Webpack vs Closure
I was answering to "not sure how FB do it"
Yeah, things are much better now. @dnolen are there any ideas on how to make it possible to consume NPM deps directly, without JS entry point?
@roman01la task in JIRA about that
Probably a lookup for every package json
Ok, will check it, thanks.
based on what Chad Killingsworth said this may be easier than it sounds, dependency mode STRICT implies all of the machinery is already present
I was wrong! And I’m glad I was 😄 React + ReactDOM 32KB vs Webpack 42KB
probably cljs build caches was the cause
@dnolen: that JIRA ticket above... by "directly requiring" you mean without needing to add a :provides
entry?
So what's the best way most common way for me to require React in my :es6 hello world
@bhauman I’ve just published a test repo, you can see how it’s done there https://github.com/roman01la/cljs-npm-test
You may have noticed that our ES6 file does not declare its dependency on React, ReactDOM, or ReactDOMServer via import. Handling this correctly depends on a pending patch to Google Closure to support Node.js module resolution for ES6 source files. When this change lands this guide will updated.
@roman01la that’s what I was saying 🙂 but glad you could repro
@anmonteiro I mean treating CommonJS modules as Google Closure namespaces
Ah gotcha
@dnolen and I can't require react via the commonjs module like you did in the es6-demo either
boom https://github.com/google/closure-compiler/commit/35e1e1b102eea96f8a3aa23adf1763a1e6f9acbe
bummer we'll have to wait ~1 month for a release
that commit missed the Jan release by 3 days
@anmonteiro it’s February in a couple of days 🙂
right, but we need to wait until the end of February 🙂
@dnolen just attached the __dirname
patch to http://dev.clojure.org/jira/browse/CLJS-1916
@anmonteiro applied
@dnolen weird edge case that works in Clojure but not CLJS:
cljs.user=> (def foo '(:a :b))
#'cljs.user/foo
cljs.user=> (case foo '(:a :b) :works)
Error: No matching clause: (:a :b)
found it because inadvertently quoted the list passed to case
when I really wanted a non-quoted list
I don't think that should work in Clojure
Lists in case represent a list of cases, not sure if you're aware of that
You can't match a literal list in case afaik
@alexmiller I'm aware of that, but my example above seems to work in Clojure
it works as if matching a literal vector
my understanding is that ClojureScript should also mimic that behavior
I'm saying I think maybe Clojure is wrong here
oh hrm
I would need to do some more poking to be more sure
right. so maybe needs some more analysis from your part before we reach any conclusions
@alexmiller in any case this is open for reference http://dev.clojure.org/jira/browse/CLJS-1917