This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-06-26
Channels
- # adventofcode (2)
- # beginners (69)
- # boot (37)
- # cider (6)
- # clara (31)
- # cljs-dev (75)
- # cljsrn (5)
- # clojure (72)
- # clojure-dev (7)
- # clojure-italy (11)
- # clojure-nl (8)
- # clojure-russia (2)
- # clojure-spec (56)
- # clojure-uk (54)
- # clojure-za (1)
- # clojurescript (156)
- # cursive (2)
- # datomic (34)
- # emacs (1)
- # fulcro (227)
- # hoplon (74)
- # jobs (1)
- # jobs-discuss (16)
- # leiningen (5)
- # lumo (17)
- # off-topic (9)
- # om (3)
- # onyx (10)
- # other-languages (1)
- # portkey (2)
- # re-frame (2)
- # reagent (36)
- # reitit (1)
- # remote-jobs (1)
- # ring-swagger (8)
- # shadow-cljs (85)
- # slack-help (2)
- # spacemacs (6)
- # specter (3)
- # sql (17)
- # test-check (15)
- # tools-deps (80)
Hello
I'm trying to implement the "webpack method" on my "real" project but the compiler says Error: Cannot find module '@cljs-oss/module-deps'
On a small/toy project, I do exactly the same and get no errors.
Figwheel: Starting server at
Figwheel: Watching build - dev
Compiling build :dev to "resources/public/javascript/main.js" from ["src" "test" "dev"]...
internal/modules/cjs/loader.js:596
throw err;
^
Error: Cannot find module '@cljs-oss/module-deps'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at [eval]:8:13
at Script.runInThisContext (vm.js:91:20)
at Object.runInThisContext (vm.js:298:38)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at evalScript (internal/bootstrap/node.js:531:27)
Successfully compiled build :dev to "resources/public/javascript/main.js" in 8.408 seconds.
happens when #reagent tryes to require react-dom
(require '[react-dom :as rdom])
internal/modules/cjs/loader.js:596
throw err;
^
Error: Cannot find module '@cljs-oss/module-deps'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at [eval]:8:13
at Script.runInThisContext (vm.js:91:20)
at Object.runInThisContext (vm.js:298:38)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at evalScript (internal/bootstrap/node.js:531:27)
My compiler
:infer-externs true
:install-deps false
:foreign-libs [{:file "dist/index_bundle.js"
:provides ["react" "react-dom" "material-ui" "react-bootstrap"]
:global-exports {react React
react-bootstrap ReactBootstrap
material-ui MaterialUI
react-dom ReactDOM}}]
and my index.js
import React from 'react';
import ReactDOM from 'react-dom';
import * as MaterialUI from '@material-ui/core/index.js';
import * as ReactBootstrap from 'react-bootstrap';
window.React = React;
window.ReactDOM = ReactDOM;
window.MaterialUI = MaterialUI
window.ReactBootstrap = ReactBootstrap
happens when #reagent tryes to require react-dom
(require '[react-dom :as rdom])
internal/modules/cjs/loader.js:596
throw err;
^
Error: Cannot find module '@cljs-oss/module-deps'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at [eval]:8:13
at Script.runInThisContext (vm.js:91:20)
at Object.runInThisContext (vm.js:298:38)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at evalScript (internal/bootstrap/node.js:531:27)
My compiler
:infer-externs true
:install-deps false
:foreign-libs [{:file "dist/index_bundle.js"
:provides ["react" "react-dom" "material-ui" "react-bootstrap"]
:global-exports {react React
react-bootstrap ReactBootstrap
material-ui MaterialUI
react-dom ReactDOM}}]
and my index.js
import React from 'react';
import ReactDOM from 'react-dom';
import * as MaterialUI from '@material-ui/core/index.js';
import * as ReactBootstrap from 'react-bootstrap';
window.React = React;
window.ReactDOM = ReactDOM;
window.MaterialUI = MaterialUI
window.ReactBootstrap = ReactBootstrap
how do I suppress stack traces in the repl (cider)?
@souenzzo Looks like you have node_modules
directory present, disable npm module support with :npm-deps false
option
:install-deps
option is no-op without :npm-deps
Hi guys, may I ask a very abstract question: is it possible (or is it worth it?) to use Clojurescript+ReactNative for business logic only? I'm fine with UI in Swift/Java, but I'd like to make a "core" engine which would handle HTTP calls, validation, forms handling, search, etc.
I'm not really interested in x-platform UI as I have 100% positive experience with native technologies - I depend on pretty and fast native animations and other platform-dependent stuff - but I'm looking for a replacement for my current x-platform stack (C++ core/business logic/view models, djinni
x-language bridging, Swift/Objective-C/Java/Kotlin for UI and platform-dependent code).
So is it possible to make a small core in Clojurescript and then just execute callbacks on a native side which would consume nothing but maps and lists? Without touching ReactiveNative UI part. I'm eager to throw away C++ from my life 😬
Maybe you don’t even need RN then at all! You could just load the code into JSCore engine. But then you would probably need to setup bridge and everything by yourself, so perhaps RN would be a better “platform” for your needs.
Is metadata on namespaces allowed/supported in some way?
@martinklepsch allowed and supported yes (but as usual only available in analyzer data in the compiler env)
@thheller just to be sure, this syntax and all (ns ^:no-doc codox.example3)
, should be reflected in the result of parse-ns
?
uhm actually I'm not sure if it works properly in CLJS. I vaguely remember fixing a related issue in shadow-cljs, not sure if I ever made a ticket/patch for this
@thheller hm, I can’t get it to work at all 😅 does any of this look wrong to you?
@thheller thanks (-> ast :name meta)
was it! not sure I would have thought of trying that 🙌 🙂
Guys, I am using Webpack to pack external libraries and calling them from js namespace from clojurescript. But I can’t optimize my code because of that.
Hi there, Anyone knows a good library (or safe piece of code) that exposes a cljs function that returns a core.async channel for javascript consumption?
@thheller, hi again. 😇 It was an early crying. I solve my problem with these steps: - I looked into Optimization Documentation. It Cryptes variable names. --I didn’t know, really ¯\(ツ)/¯ - I thought, If I change my variables into strings. --which is crytical/untouchable for optimization processor. - I change my variable accessing function with goog.object/getValuesByKeys function call. It solved my problem. I don’t think it would be that easy. My verbosity for newbies like me. —forgive me guys—
@thheller do you have any other solution for this. I don’t know, it is the right way or not…
I'm getting (instance? LazySeq (array-seq #js[1 2 3])) => false
so that means it's not lazy right?
@jjttjj Right. It returns a cljs.core/IndexedSeq
, which can do nth
, for example, in O (1).
@scknkkrer you might be looking for (defn ^:export your-fn [] ...)
if you mean to call your.app.your_fn()
from HTML?
Entering 1/2 in a figwheel REPL and with "lein cljsbuild once" I get: "failed compiling constant: 1/2; class clojure.lang.Ratio is not a valid ClojureScript constant." lumo is dealing with it just fine returning a float for cljs.
In another project I get "No method in multimethod 'emit-constant' for dispatch value: class clojure.lang.Ratio"
unfortunately a quick web search has not revealed what is exactly the status of ratios.
@whilo I’m not sure ClojureScript supports ratios
the reason it works in Lumo is because the underlying compiler platform is JavaScript
and JavaScript just accepts the 1/2
pattern and a bunch of other garbage
@whilo I think the reader reads it just fine
the error you’re getting is from the ClojureScript emitter if I’m not mistaken
paging @mfikes
^ do you know if there’s an open JIRA for this?
@whilo so you’re just asking for a more meaningful error like "ratios aren't supported"
A motivating similar example. Consider .3
That is not a valid thing in Clojure. The fact that it seems to do something in ClojureScript doesn't mean it is valid in ClojureScript.
@dnolen that is an option. i have just been confused by porting some clojure tests and 4/2 was working, while 1/3 stayed a ratio and was throwing the error at me
if 1/4 is supposed to be syntax for ratios and they are not supported then it should probably not be readable
what would be the interesting types in cljs? big numbers and ratios? or full protocol support like core.matrix(?)
hmm, how can this not be a perf problem in js? clojure piggiebacks on java's polymorphic method dispatch, right?
just for reference, i am porting https://probprog.github.io/anglican/ to cljs atm.
I've played with https://github.com/gfredericks/exact a bit. It can be tedious, but is definitely useful
@whilo anyways - in case somehow something was misunderstood 1/4
is a valid literal in Clojure
FWIW, https://dev.clojure.org/jira/browse/CLJS-555 is one of the most highly voted JIRAs
ratio support itself is helpful, because of floating point numerical errors. it makes testing of some code easier and precise
i am now getting (not (m/equals [10.666666666666666 10.666666666666666 10.666666666666666 10.666666666666666] [10.666666666666664 10.666666666666664 10.666666666666664 10.666666666666664]))
You also have the unfortunate difference with (/ 0)
between Clojure and ClojureScript. Former is an error, latter is a hosty mathematical ¯\(ツ)/
presumably it’d be very hard to add different forms of math to +
without incurring a dynamic dispatch overhead on all mathy things
omg. and it keeps track of the signs if you keep multiplying -0 times itself. haha.
oh i see. i didn’t know about that in javascript to being with and now that i’ve learned of it i now learn it won’t print in clojurescript. 🙂
Are shadow-cljs and cljs.main comparable to each other?
@ghopper they are different, if you have been using cljs.main I'd suggest you try figwheel.main as the cli is comparable
I've actually been using cljs.main
. I was just wondering if they were on the same level.
Err, I've been using figwheel.main
.
Ok, so shadow-cljs would be comparable to figwheel.main
?
I just figured I'd try all the options before settling on something. I started with Boot-cljs, then I tried pure cljs.main
, then I moved on to your figwheel.main
.
It uses the normal cljs compiler under the hood though, right?
:thumbsup: Thanks
I'm still not sure I buy into this CLI script with Makefile idea. It's certainly very nice for some things during development, but there's a lot to be said for the build process entirely being a clj program.
You make a fair point. I think I just need to spend more time to figure out where the happy middle ground is between using CLI argument only and calling the clj API instead.
I kinda jumped from one extreme to the other.
Hmm, no, I'm not actually sure what that does.
I know I can just write build scripts and clj $script
them.
Oh, right, yeah. I thought you were saying there was a :main
entry in deps.edn
that did something. I'm familiar with aliases. That's a good idea over just doing everything in the Makefile.
I've only used them for my system global aliases for rebel readline and such.
I do like that over all the phony tasks I have in my Makefile.
an interesting pattern is to have a user.clj
file with a bunch of tasks in it and then invoke functions in it via these aliases
Do you by any chance have a repo you can point to that's using this?
It's a good idea. I was thinking I'd need separate namespaces for each to use -m
.
That's alright :thumbsup:
I know this is kinda new ground. Overall I'm liking the direction. It feels a lot cleaner without the overhead of Boot's abstractions.
(or Leiningen for that matter)
🙂 Thanks for talking through things with me.
you would want to separate namespaces if you had a vastly different set of dependencies for certain tasks
Yeah, certainly.
So if you had for e.g. tasks for managing AWS infrastructure via CloudFormation, would you do that in a Makefile, or would it make sense to use clojure.java.shell
to call the aws
CLI?
That's kinda outside the scope cljs, I guess. I'm just trying to figure out how to divide things.
All good point. I hadn't thought about non Unix contributors. That is one of the benefits of using Boot and clj only stuff.
There's a number of AWS calls, and I hadn't really considered using a Java API. I guess if we're sticking with the CLI it should be through the Makefile.
Yeah, there is. It's quite nice, though the CLI does a lot for you that I don't want to do manually.
This is the one I was using: https://github.com/mcohen01/amazonica
Right, and the CLI through a Makefile is simpler than trying to shell out from clj I think.