This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-24
Channels
- # aws (7)
- # aws-lambda (3)
- # beginners (65)
- # boot (43)
- # cider (7)
- # cljs-dev (12)
- # cljsrn (15)
- # clojure (284)
- # clojure-austin (32)
- # clojure-brasil (4)
- # clojure-dusseldorf (4)
- # clojure-germany (1)
- # clojure-italy (40)
- # clojure-spec (21)
- # clojure-uk (69)
- # clojurescript (97)
- # core-async (11)
- # cursive (19)
- # data-science (1)
- # datascript (6)
- # datomic (30)
- # dirac (2)
- # emacs (4)
- # events (2)
- # fulcro (76)
- # graphql (38)
- # juxt (1)
- # lein-figwheel (1)
- # leiningen (6)
- # luminus (4)
- # lumo (13)
- # mount (4)
- # off-topic (24)
- # om (28)
- # onyx (32)
- # other-languages (1)
- # parinfer (40)
- # pedestal (1)
- # portkey (47)
- # re-frame (21)
- # reagent (4)
- # ring (4)
- # ring-swagger (3)
- # rum (1)
- # shadow-cljs (115)
- # spacemacs (5)
- # sql (14)
- # unrepl (1)
- # yada (3)
is it possible to transpile some cljs
to js
without the Google Closure stuff?
I want to simply turn my cljs
file into a js
equivalent that I can run with cucumber
at the CLI
these transpiled js
files wouldn't have an entrypoint
ehh, ya, that wouldn't make any sense because output looks something like this:
// Compiled by ClojureScript 1.9.946 {:target :nodejs}
goog.provide('steps.foo');
goog.require('cljs.core');
cljs.core.enable_console_print_BANG_.call(null);
cljs.core.println.call(null,"Hello world");
and everything depends on those being there
what I want is like, how in typescript, I can do typescript things and it transpiles to es6 without adding extra libs -- I want that with cljs, because in this case, it's the transpiled output that gets evaluated by the runner: cucumber-js
binary
(which is a node CLI app)
here's full context: https://github.com/cucumber/cucumber-js/blob/master/docs/nodejs_example.md
I can follow the folder structure and translate that nodejs into cljs, but then when it comes time to build the cljs
to run cucumber
against the output, it will fail
for 3 days i've been trying to setup a cljs devenv, and i thought i had it, but no. some npm modules work, some npm modules don't work, everything just dies silently during compile
anyway, what's better way to spend the time between 2 AM and work than debug this, right?
i don't know why i can't require my npm module. it works fine from js but when i try to use it from cljs, the compile never finishes
i am even guessing what the bug is, the temp name is colliding with an already existing function. (i give 0.001% chance for this to happen, but would explain 100% so i like it :D)
maybe if you are curious, you can try installing it yourself and check what might be the issue https://www.npmjs.com/package/geta-random-word use version 1.2.0
@dhruv1 I'm checking the js extern name by opening the browser and writing in the browser console: window.<some words from lib name>
some example usage: https://github.com/dimovich/coverton/blob/cf7b12ad11533e4bc1ebe4e2fca600f89a55f1cd/src/cljs/coverton/components.cljs#L144
I'm getting Uncaught Error: Undefined nameToPath for prismic_javascript
when trying to use :npm-deps
@dimovich still no luck for me.
(ns test.draggable
(:require [cljsjs.react-draggable]
[reagent.core :as r]))
(def react-drag (r/adapt-react-class js/ReactDraggable))
error: #object[ReferenceError ReferenceError: ReactDraggable is not defined]
otherwise try typeing js/ReactDraggable into the brepl and see if you ged reference error, then it means your code is not loading or figwheel (in case you're on figwheel) wasn't able to compile.
i will try it out using reagent.
but anytime i reference js/ReactDraggable i get a reference error.
when i run (cljs-repl) in my cider-repl
, react-draggable is compiled and file is generated resources/public/js/compiled/out/cljsjs/react-
yes i agree that the ReactDraggable is then not being loaded
it could be that what you're doing r/adapt-react-class is correct, I just never used it, the :>
is maybe a syntax sugar for just that function
hmm ok, is it defined when you type ReactDraggable
into the developer console of the browser?
that's really strange. Try deleteing all the js artifacte (eg. /out) and restart all the tooling you use, be it clojure/figwheel etc.
i did.
i’ve been constantly running lein clean
and restarting my repl.
running lein clean
cleans out the resources/public/js/
folder
I initially made the cljsjs package for ReactDraggable, and I see much has changed. Let me try to require it, and I let you know if I can.
this is weird and i am not sure what’s going on but going through my chrome console i sometimes see this error
Uncaught TypeError: goog.net.jsloader.load is not a function
at file_reloading.cljs?rel=1508855444416:243
at figwheel$client$file_reloading$reload_file (file_reloading.cljs?rel=1508855444416:252)
at figwheel$client$file_reloading$blocking_load (file_reloading.cljs?rel=1508855444416:271)
at file_reloading.cljs?rel=1508855444416:281
at file_reloading.cljs?rel=1508855444416:279
at figwheel$client$file_reloading$state_machine__40235__auto____1 (file_reloading.cljs?rel=1508855444416:279)
at figwheel$client$file_reloading$state_machine__40235__auto__ (file_reloading.cljs?rel=1508855444416:279)
at cljs$core$async$impl$ioc_helpers$run_state_machine (ioc_helpers.cljs?rel=1508855441624:35)
at cljs$core$async$impl$ioc_helpers$run_state_machine_wrapped (ioc_helpers.cljs?rel=1508855441624:39)
at ioc_helpers.cljs?rel=1508855441624:48
at channels.cljs?rel=1508855438884:74
at cljs$core$async$impl$dispatch$process_messages (dispatch.cljs?rel=1508855438792:19)
at <anonymous>
i added it in there and and restarted my repl after doing a clean and now i can see it in my chrome console
And I get that error in the js console. Am I missing something? From reading https://anmonteiro.com/2017/03/requiring-node-js-modules-from-clojurescript-namespaces/ it seems like this should work.
@madstap it looks like a few people in the comments had problems getting that code to work. Have you looked at the Node integration docs from http://clojurescript.org? https://clojurescript.org/news/2017-07-12-clojurescript-is-not-an-island-integrating-node-modules
With that one I get another error: Exception in thread "main" java.lang.AssertionError: Assert failed: cljs.analyzer/foreign-dep? expected symbol got "react-dom/server"
@madstap are you sure you’re not on an old version of ClojureScript that doesn’t support all this?
Yeah, I downloaded the jar from https://github.com/clojure/clojurescript/releases/download/r1.9.946/cljs.jar
I tried nuking node_modules
and the contents of out
and now I get
[eval]:1
let fs = require('fs');
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at Object.exports.runInThisContext (vm.js:53:16)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (module.js:410:26)
at node.js:578:27
at nextTickCallbackWith0Args (node.js:419:9)
at process._tickCallback (node.js:348:13)
Which I have seem intermittently when trying to get stuff working. Below that I still get the expected symbol
error
@madstap I would recommend upgrading Node.js, you may be on an old version
Ok, I did that and the error message changed: Uncaught Error: Undefined nameToPath for react
Hmm… it seems like no matter what you put in there, the nameToPath is going to be undefined. What are you using to build? Leiningen, boot, java -jar
?
I was using lein with figwheel and all that stuff, but I took a step back and just used the cljs quickstart way (`java -jar ...`). I got it to work now with that by nuking everything, gonna try it on my real project now
Looks like instrument doesn't exist in clojurescript 1.9.908. I checked in cljs.spec.alpha and cljs.spec.gen (which are the only two namespaces prefixed with cljs.spec I have loaded...) What gives? Is there still a way to instrument specs?
@escherize cljs.spec.test.alpha/instrument
Hello I'm having an inconsistency with my project on a windows machine. When I run the same project in the same computer in a linux box it works normally. I'm thinking that it has something to do with this $ symbol
Writing adzerk\boot_reload\static$\js\app.cljs to connect to ...
@U17CAUN2F I'm having the same issue... I suppose you're using app.cljs.edn config file?
@dimovich yes, without edn it works?
yeah... instead of specifying the build config in app.cljs.edn, do it in your boot or lein build config