Question: Hey all, is it possible to load a clojurescript namespace from lein repl? Does anyone know how to do it?

Asked By
derpocious
Asked At
2017-11-15 13:22:41

Found 15 possible answers.

User Answered At Possible Answer
vemv 2017-11-15 13:24:37 @derpocious are you familiar with figwheel? it gives you a repl where you can require things among other goodies
zalky 2017-11-15 15:24:10 @davertron : Unfortunately I don't think there is. However, there is a great FSM library called automat that works in both clj and cljs. https://github.com/ztellman/automat
davertron 2017-11-15 15:30:53 That’s actually the first one I came across, but the repo is “archived”. I wasn’t sure if that meant it was basically abandoned, or if it was just “done” :slightly_smiling_face: . I’ll take a look though if it works in cljs. Thanks for the heads-up!
tmarble 2017-11-15 15:31:53 Hi all! Today I'm thinking about making a simple CLJS example to demonstrate JS (export module) interop -- just want to check: has anyone done this? (context is seeing António's talk at the Conj)
zalky 2017-11-15 15:32:00 Hi all. I'm working on integrating cljs and js code in a project, and I have a build that is working well, except advanced compilation mode is throwing errors on ES6 features: And while this also works with no optimizations, in advanced mode, it has zero effect, and the same errors are thrown. Has anyone had experience including ES6 js code in their project? (as seen in: https://clojurescript.org/guides/javascript-modules )
                :module-type :es6}]
:foreign-libs [{:file "src/js" In the clojurescript docs it says that ES6 modules can be enabled by including the library as a foreign lib:
ERROR - this language feature is only supported for ECMASCRIPT6 mode or better: arrow function. Use --language_in=ECMASCRIPT6 or ECMASCRIPT6_STRICT or higher to enable ES6 features.
thheller 2017-11-15 15:34:36 you might need to set :language-in :ecmascript6 in the compiler options
zalky 2017-11-15 15:36:16 @thheller : I see, is that instead of the foreign-libs entry, or in addition to. @tmarble : I found that talk super interesting. Do you mean export to npm?
thheller 2017-11-15 15:37:52 in addition
tmarble 2017-11-15 15:39:23 sure.. could be npm or any other conventional JS target.... the trick is our CLJS gurus are creating far to much cool stuff --- i just want to document it! reviewing the talk now... https://www.youtube.com/watch?v=63K--ctvT-g
zalky 2017-11-15 15:44:20 Yeah, I was experimenting with consuming npm modules in cljs, and while I got it to work for a couple of libs (react, prosemirror... ), I couldn't get it to work for quite a few others.
WARNING: Skipping pass optimizeToEs6
Hmm... while the works for the errors, I'm now seeing a lot of warnings about skipped compiler passes:
thheller 2017-11-15 15:59:33 I really have no idea how all this works in CLJS core. it works very differently in shadow-cljs as described here: https://code.thheller.com/blog/shadow-cljs/2017/11/10/js-dependencies-in-practice.html
zalky 2017-11-15 20:25:47 Anyone ever seen the cljs compiler emit a bunch of warnings like:
Minimal build here:  
                    :module-type :es6}]}
  :foreign-libs   [{:file        "src/js"
  :language-in    :es6
  :parallel-build true
  :source-map     false
  :optimizations  :advanced
Compiler options:
 {:asset-path     "js/main.out"
};
  console.log(`Printing ${x} from cljs!`);
js.lib.debugMessage = (x = "any old string") => {
JS:
goog.provide('js.lib'); factory features: [block function, getters, string continuation
I'm compiling a very simple build that includes es6 js, and for the life of me I can't get it to compile with advanced optimizations.
WARNING: Skipping pass checkVariableReferences
r0man 2017-11-15 20:56:01 Hello, I was a bit out of the loop with ClojureScript recently but followed the announcement of :npm-deps and got quite exited. I would like to try the new apollo client via npm-deps with clojurescript in the browser. everything compiles and the node dependencies do get installed. but when I open my app in the browser I get errors like this "Uncaught ReferenceError: module is not defined" and "Uncaught ReferenceError: module$home$roman$workspace$apollo$node_modules$apollo_link$lib$index is not defined" telling me something is not right with my node dependencies. What's the state of :npm-deps? Are there still some restrictions with node modules, is this a bug, am I doing something wrong, or is trying to use a package like apollo-client via :npm-deps still a bit too ambitious? Any ideas? :slightly_smiling_face:
zalky 2017-11-15 21:09:32 @r0man : I also experimented recently with :npm-deps, and my experience was that while I was able to get some libs to work, others libs had issues similar to what you saw. My understanding is that the compiler has trouble inferring externs from some of the more advanced code that some libraries use. If you want to test that your approach is correct, I recommend trying your build with one of the projects that is known to work via :npm-deps , like react or lodash.
r0man 2017-11-15 21:11:23 @zalky ok, thanks! I'll verify with lodash next @zalky react via :npm-deps is working, so maybe something with apollo :confused:

Related Questions