This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-19
Channels
- # aleph (1)
- # announcements (3)
- # aws (1)
- # beginners (95)
- # calva (15)
- # clojars (4)
- # clojure (84)
- # clojure-android (3)
- # clojure-austin (1)
- # clojure-chicago (1)
- # clojure-dev (66)
- # clojure-europe (3)
- # clojure-italy (15)
- # clojure-nl (13)
- # clojure-uk (33)
- # clojuredesign-podcast (9)
- # clojurescript (6)
- # cursive (68)
- # data-science (4)
- # datavis (1)
- # datomic (13)
- # emacs (4)
- # fulcro (2)
- # jobs (4)
- # jobs-discuss (89)
- # luminus (23)
- # nrepl (6)
- # off-topic (2)
- # onyx (2)
- # pathom (4)
- # pedestal (11)
- # re-frame (9)
- # reagent (8)
- # reitit (5)
- # shadow-cljs (131)
- # spacemacs (13)
- # sql (8)
- # vim (8)
- # xtdb (7)
- # yada (4)
can i have node_modules
in a different directory than the top level?
i have a project that outputs builds for the browser and node
and some of the node deps aren’t installable on CI
ideally i’d have different profiles in package.json, but i don’t think that’s possible
Has anyone come across this error before and how to resolve it? Running shadow-cljs... [:app] Compiling ... ------ WARNING #1 - ----------------------------------------------------------- Resource: com/cognitect/transit.js:649:8 variable module is undeclared -------------------------------------------------------------------------------- ------ WARNING #2 - ----------------------------------------------------------- Resource: com/cognitect/transit/impl/writer.js:256:8 variable isObject is undeclared -------------------------------------------------------------------------------- nil Thanks!
@currentoor it is possible to set :js-options {:node-modules-dir "some/nested/path"}
in your build config
@jcb those are just warnings. not errors. not currently possible to resolve it since its a problem in the transit lib
thanks @thheller, I'm trying to track down why a request to the server that works in dev would fail after uberjar
this is in luminus, so I'll take it there after I've been through some things. But essentially - In dev I'm sending a request for an edn file with some frontend config stuff in it. However, after compilation this fails. It not so much the error itself as the disparity between the dev experience (where everything just kind of works!) and the compiled code that is leading me down many rabbit holes.
remember that :advanced
compiled builds are much less dynamic and certain dynamic things you can do in dev builds wont work
sorry I've been trying to trace it back as I've been working through I've made many new errors. The initial problem was something along the lines of "replace" and "map" on null
that can happen if you for example access a JS property and the GCC decides to rename the name of that property
ie. enable :compiler-options {:infer-externs :auto}
in your build config and check the warnings (if there are any)
I did that and there was a warning about some things from goog.history and goog.events but they seemed unrelated
you can also try shadow-cljs release your-build --debug
to make things a bit easier to debug
thank you! I will post them in a bit. I'm using luminus so should I add that into the uberjar tasks?
Hi. Has somebody noticed a problem with too many generated JS files in dev mode? I guess I have too many NPM dependencies (like material-ui) but I don't see an easy way to reduce them. Currently, when I try to open the app in dev mode the browser does 1470 requests. I guess the real number is about 2900 including the .map files. The Chrome-based browsers (including Opera and Vivaldi) sometimes display error "net::ERR_INSUFFICIENT_RESOURCES" but most of the time just hang. Currently only Firefox can open the application but unfortunately, some tools like re-frisk don't work. Is there an option to combine the NPM resources in a single JS file in dev mode to reduce the number of requests?
two infer warnings - (swap! session assoc :page (match-route (.-token event))))) -------------------------------------------------------^------------------------ Cannot infer target type in expression (. event -token)
and (events/listen js/window EventType.KEYDOWN 648 | (fn [e] (reset! press (.-keyCode (.-event_ e)))))) -----------------------------------------------------------^-------------------- Cannot infer target type in expression (. e -event_)
@lubo try https://clojureverse.org/t/improving-initial-load-time-for-browser-builds-during-development/2518
@jcb yeah that warning can be ignored. you can add (fn [^goog e] ...)
to make that warning to away
not sure what event_
is though. doesn't look like something you should be using directly
you can try (fn [^js e] ...)
which will cause externs for event_
to be added. maybe that fixes it
thank you I'll try it - it could be a problem but the request problem seem to be more about how formats are being en/decoded
unlikely given that most apps use either EDN or transit or both and usually don't have any issues
JSON is known to have some edge cases when using js->clj
but EDN/transit don't have those issues
@thheller Thank you very much! The :loader-mode :eval option reduced the number of requests from 1470 to 30 and the Chrome-based browsers can open the application now
Greetings, fellow clojurians! I seem to face an npm dependency issue, trying to add: https://github.com/funcool/cuerdasp into a deps.edn + shadow-cljs project I was unable to reproduce the same issue in a clean project, my dilettante guess would be that issue is caused by npm dependency clash package.json
"version": "0.0.1",
"private": true,
"devDependencies": {},
"dependencies": {
"bootstrap": "^4.3.1",
"core-js": "^3.1.4",
"create-react-class": "^15.6.3",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-transition-group": "^4.2.1",
"sass": "^1.18.0",
"xregexp": "^4.2.4",
"yarn": "^1.13.0"
}
core-js
is being required by xregexp
and also create-react-class
I don't have an idea of how it can be resolved (being new with using npm deps in cljs and shadow-cljs), any hints?@brownmoose3q check which version of core-js xregexp depends on via node_modules/xregexp/package.json
. then make sure to install that version.
npm i --save core-js@2
did the trick!
ta!@thheller I noticed the user manual doesn’t mention :js-options {:node-modules-dir "some/nested/path"}
anywhere, would you like a PR that adds a tiny note about it?
Hi!
I’m facing the following issue when running tests with shadow-clj configured with :ci {:target :karma}
:
{
"message": "Uncaught ReferenceError: $jscomp is not defined\nat ci.js:229378:1\n\nReferenceError: $jscomp is not defined\n at ci.js:229378:1",
"str": "Uncaught ReferenceError: $jscomp is not defined\nat ci.js:229378:1\n\nReferenceError: $jscomp is not defined\n at ci.js:229378:1"
}
The line that throws the error the is a transpilation of a js class extension:
$jscomp.inherits(ShuffleLoader$$module$nubank$shuffle$common$ui$shuffle_loader, module$node_modules$react$index.PureComponent);
Shadow-clj compiles and runs the app perfectly, the error only appears when running tests.you probably should set :compiler-options {:output-feature-set :es6}
so it doesn't transpile classes
don't really need to assuming you are running the tests in a somewhat recent platform
Yep, our target is only a single evergreen browser.
Changing the :compiler-options
did the trick. Thank you very much!
FWIW if you use any newer features in the JS like async/await you can bump that up to :es7
or :es8
has anyone seen this error?
{:clojure.main/message
"Execution error at shadow.build/eval16057$loading (build.clj:1).\nUnable to resolve spec: :clojure.core.specs.alpha/args+body\n",
:clojure.main/triage
{:clojure.error/class java.lang.Exception,
:clojure.error/line 1,
:clojure.error/cause
"Unable to resolve spec: :clojure.core.specs.alpha/args+body",
shadow-cljs - config: /Users/currentoor/src/ucv/shadow-cljs.edn cli version: 2.4.5 node: v10.16.0
ah it’s because my node_modules are in a subdirectory now…
right i’m launching the server with npx shadow-cljs server
i agree it doesn’t look node_modules related, but calling npx ...
in the same directory as my node_modules (now i have two in two separate dirs) launches the server
but my shadow-cljs.edn and deps.edn are top level, so maybe i need a top level node_modules that just has shadow-cljs in it?
good grief, i find it baffling that JS with all it’s mindshare doesn’t have the notion of profiles in their dependency management
only guess I have is that you are using an older clojure version that doesn't have those specs?
this all would be a non-issue if in package.json i could just specify two profiles and do npm install --profile browser
in one context and npm install --profile node
in another context
not sure what you mean. this is a CLJ exception. CLJ never touches any JS whatsoever
i’m sorry i’m not being very articulate
you’ve already been immensely helpful, i should stop complaining 😅
about JS
but just in case you know, is there a way specify two different sets of dependencies in one package.json?
like how in deps i can say these deps are for only for a particular build
and the other deps are for all builds
right and i’m having trouble getting that approach to work with my shadow-cljs setup
ok so it is possible
BUT it is absolutely impossible that :node-modules-dir
prevents your process from starting
right i understand
hmm i wonder if omitting npx might work
trying
nope i get the same error
i haven’t added :node-modules-dir
just have package.json and node_modules in a subdirectory
sorry that was a little messed up
i’ll make a gist
do you need the rest of the stacktrace?
:deps {:aliases [:test :cljs :dev]}
running
that was able to spin a repl
user=> (require 'shadow.cljs.devtools.cljs-specs)
nil
under the alias :dev
i have it thheller/shadow-cljs {:mvn/version "2.8.21"}
1.10.1-beta2
i tried deleting both .cpcache
and .shadow-cljs
no luck
~/s/ucv (feature/barcode-scanner↑2|✔) $ clj -A:test:cljs:dev
Clojure 1.10.1-beta2
user=> ( "clojure/core/specs/alpha.clj")
#object[java.net.URL 0x5efb3259 "jar:file:/Users/currentoor/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar!/clojure/core/specs/alpha.clj"]
is there a reason why :js-options {:node-modules-dir "..."}
would work for a :browser
target but not :node-script
well i see you’re using it in shadow-cljs itself, so it should work
perhaps i need to :keep-native-requires
I'm using shadow-cljs and VSCode/Calva and trying to reload a file with several functions I am making changes to.
(require 'my.ns :reload-all)
but this doesn't seem to work. Is this an effect of the caching? Do I need to turn this off completely when developing?
@dfcarpenter , there is something going on with loading files with Calva and shadow-cljs. I'm struggling to figure it out. Meanwhile, try selecting the whole file and then evaluate the selection.