This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-02
Channels
- # aws-lambda (1)
- # beginners (28)
- # boot (54)
- # cider (11)
- # clara (28)
- # cljs-dev (74)
- # cljsrn (13)
- # clojure (342)
- # clojure-austin (3)
- # clojure-dusseldorf (4)
- # clojure-france (2)
- # clojure-greece (11)
- # clojure-italy (42)
- # clojure-poland (7)
- # clojure-russia (11)
- # clojure-spec (44)
- # clojure-uk (156)
- # clojure-ukraine (4)
- # clojurescript (102)
- # cursive (17)
- # datascript (19)
- # datomic (17)
- # dirac (39)
- # emacs (22)
- # funcool (56)
- # hoplon (25)
- # jobs (3)
- # jobs-discuss (31)
- # leiningen (2)
- # luminus (4)
- # lumo (3)
- # off-topic (47)
- # om (51)
- # onyx (57)
- # re-frame (13)
- # reagent (57)
- # remote-jobs (15)
- # ring (9)
- # ring-swagger (7)
- # robots (2)
- # rum (6)
- # specter (16)
- # sql (7)
- # test-check (37)
- # untangled (7)
- # yada (5)
yeah let me know if you want me to try something else
actually the problem is not absolute files
it’s the usage of (System/getProperty “user.dir")
@richiardiandrea pushing a new patch real soon
ok awesome
btw thanks so much for giving the patch a go
thanks for debugging it 🙂
I’m fairly confident on the state the patch is at now
works with cljs.jar
, and Boot
able to consume several modules, no problem 🙂
@anmonteiro et al. I created a repro for importing aws-sdk
using CLJS-1960
(`mies` template) here: https://github.com/arichiardi/lumo-repros/pull/1
turns out package.json
files can have a "browser"
entry that specifies replacements for files if we're requiring that package for use in a browser
so in cljs/module_deps.js
we'll have to use different resolvers according to ClojureScript's compilation target 🙂
this is gonna be a fun one to solve
@anmonteiro Did you test the patch with :optimizations :none
or :simple
? It seems like NPM packages couldn’t be resolved. I’m getting using undeclared var
warnings.
@anmonteiro Works fine with advanced
optimizations, except React gets an error, probably because of Closure Compiler
@roman01la I'll look into that today, can you paste the error or warnings you're getting?
@roman01la actually I didn't test with optimizations :advanced
but I'm glad it works. :none
or :simple
works great here
(b/build "src"
{:output-to "resources/public/js/compiled/fridge_client.js"
:output-dir "resources/public/js/compiled/out"
:npm-deps {:react “15.4.2”
:react-dom "15.4.2"}
:main 'app.core
:optimizations :simple
:pseudo-names true
:closure-defines {'process.env/NODE_ENV "development"}
:pretty-print false
:verbose true})
(ns app.core
(:require [process.env]
[react :as React]
[react-dom :as ReactDOM]))
(def App (.createElement React "h1" nil "HELLO!"))
(.render ReactDOM App
(.getElementById js/document “app”))
here’s build config and code
warnings
WARNING: Use of undeclared Var app.core/React at line 6 /Users/roman01la/projects/fridge/fridge-client/src/app/core.cljs
WARNING: Use of undeclared Var app.core/ReactDOM at line 8 /Users/roman01la/projects/fridge/fridge-client/src/app/core.cljs
@roman01la sure that's expected
use ReactDOM/render
ReactDOM
is a namespace now, not an object
oh crap
thanks 😅
transition to NPM packages is going to be hard 😄
btw, are there going to be any problems with NPM modules and libraries which are using CLJSJS packages at the moment?
I mean wouldn’t it be a breaking change?
please clarify
do you mean consuming React from node_modules
while using React from CLJSJS?
hmm, I mean libraries that will switch to NPM modules instead of CLJSJS will no longer work with older versions of ClojureScript, right?
That's correct
So it's not a CLJS breaking change
But libraries can introduce breaking changes if they want to
yeah, I just think this will cause very slow transition to NPM modules in ClojureScript libraries
not a big ideal in fact
Sure. But my patch doesn't even allow libraries to use NPM modules yet
I'll work on that support after this patch gets in
To clarify, we'll support a npm-deps
option in upstream JARS via deps.cljs
ok, I see
@dnolen btw not sure when you're going to look at the node modules patch, but I have addressed the browser vs node resolver issues locally so the patch attached to CLJS-1960 is stale now
@anmonteiro tomorrow
I'll let you know when I upload the updated one
Gotcha, still have some time to kick it around then :-)
@anmonteiro I think I found a issue with your patch and react-dom
. react-dom
has two entry points index.js
(the main entry point) and server.js
. If I try to use any of the react-dom
server functionality I can't because it's not loaded. When I try to load it manually I get duplicate module errors from Google Closure
@spinningtopsofdoom how would you require it in JS?
require(’react-dom/server’);
?
yeah that’s gonna need more hammock time 🙂
Like in the current js module guide
we’re not gonna be able to support that for now
but you can still fallback to what the guide does
the main problem with something like this is that you probably can’t require react-dom/server
in a CLJS namespace
Yep but mixing the two methods will lead to duplication errors from Google Closure
and changing it to dots or dashes is too implicit for my taste
@spinningtopsofdoom so that’s definitely an issue that we can solve by making module entries a set
and I can address that in my patch
btw thanks for trying out the patch
lots of valuable input from everyone that tried it so far!
Cool the code I had to resolve it manually is
var ReactDOMServer = require("react-dom/server");
module.exports = {
ReactDOMServer: ReactDOMServer
};
for the javascript file and
(def node-libs
(let [entry {:file (.getAbsolutePath (io/file "src/libs/npm_deps.js"))
:provides ["libs.npm-deps"]
:module-type :commonjs}]
(into [entry] (cc/node-inputs [entry]))))
to get the foreign module deps@spinningtopsofdoom yep, but you still had a :npm-deps
entry right?
correct
and we merge those together creating duplicates
:npm-deps {:react "15.4.2"
:react-dom "15.4.2"}
so it’s a simple fix