reagent-project / reagent-frontend-template Goto Github PK
View Code? Open in Web Editor NEWtemplate for creating Reagent projects without a backend
License: MIT License
template for creating Reagent projects without a backend
License: MIT License
Hi,
First of all, I am a huge Reagent fan. Thanks so much for your time and effort!
I just tried to create a new project but got a "Template resource not found" error. I only have this problem with v0.1.34, not v0.1.33. Here are the lein commands I ran and their output.
$ lein new reagent-frontend com.example --template-version 0.1.33
Generating fresh 'lein new' Reagent frontend project.
$ rm -rf com.example
$ lein new reagent-frontend com.example --template-version 0.1.34
Generating fresh 'lein new' Reagent frontend project.
Template resource 'leiningen/new/reagent_frontend/env/dev/clj/user.clj' not found.
Thanks,
James
First, thanks for this excellent template, I often need to try out reagent things in a clean, empty, environment for experimentation. Having an up-to-date template like this is a huge time-saver.
Here are the steps I'm doing that are resulting in the stacktrace:
lein new reagent-frontend reagent-frontend-test +figwheel
This works well
cider-jack-in
The repl starts:
;; Connected to nREPL server - nrepl://localhost:34185
;; CIDER 1.5.0 (Strasbourg), nREPL 1.0.0
;; Clojure 1.11.1, Java 11.0.17
;; Docs: (doc function-name)
;; (find-doc part-of-name)
;; Source: (source function-name)
;; Javadoc: (javadoc java-object-or-class)
;; Exit: <C-c C-q>
;; Results: Stored in vars *1, *2, *3, an exception in *e;
;; Startup: /home/harold/bin/lein update-in :dependencies conj \[nrepl/nrepl\ \"0.9.0\"\] -- update-in :plugins conj \[cider/cider-nrepl\ \"0.28.5\"\] -- repl :headless :host localhost
(start-fw)
:Which appears to work well:
user> (start-fw)
Figwheel: Starting server at http://0.0.0.0:3449
Figwheel: Watching build - app
Figwheel: Cleaning build - app
Compiling build :app to "public/js/app.js" from ["src" "env/dev/cljs"]...
Successfully compiled build :app to "public/js/app.js" in 0.392 seconds.
Figwheel: Starting CSS Watcher for paths ["public/css"]
Figwheel: Starting nREPL server on port: 7002
nil
(cljs)
:And I see this stacktrace:
Launching ClojureScript REPL for build: app
Figwheel Controls:
(stop-autobuild) ;; stops Figwheel autobuilder
(start-autobuild id ...) ;; starts autobuilder focused on optional ids
(switch-to-build id ...) ;; switches autobuilder to different build
(reset-autobuild) ;; stops, cleans, and starts autobuilder
(reload-config) ;; reloads build config and resets autobuild
(build-once id ...) ;; builds source one time
(clean-builds id ..) ;; deletes compiled cljs target files
(print-config id ...) ;; prints out build configurations
(fig-status) ;; displays current state of system
(figwheel.client/set-autoload false) ;; will turn autoloading off
(figwheel.client/set-repl-pprint false) ;; will turn pretty printing off
Switch REPL build focus:
:cljs/quit ;; allows you to switch REPL to another build
Docs: (doc function-name-here)
Exit: :cljs/quit
Results: Stored in vars *1, *2, *3, *e holds last exception object
Prompt will show when Figwheel connects to your application
Exception in thread "Thread-19" java.lang.NullPointerException
at java.base/java.util.regex.Matcher.getTextLength(Matcher.java:1770)
at java.base/java.util.regex.Matcher.reset(Matcher.java:416)
at java.base/java.util.regex.Matcher.<init>(Matcher.java:253)
at java.base/java.util.regex.Pattern.matcher(Pattern.java:1134)
at clojure.core$re_matcher.invokeStatic(core.clj:4881)
at clojure.core$re_find.invokeStatic(core.clj:4923)
at clojure.core$re_find.invoke(core.clj:4923)
at cljs.analyzer$analyze_file.invokeStatic(analyzer.cljc:4862)
at cljs.analyzer$analyze_file.invoke(analyzer.cljc:4838)
at cljs.analyzer$analyze_file.invokeStatic(analyzer.cljc:4852)
at cljs.analyzer$analyze_file.invoke(analyzer.cljc:4838)
at cljs.analyzer$analyze_file.invokeStatic(analyzer.cljc:4848)
at cljs.analyzer$analyze_file.invoke(analyzer.cljc:4838)
at cljs.repl$repl_STAR_$fn__8067$fn__8068$fn__8071.invoke(repl.cljc:1181)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$with_bindings_STAR_.invokeStatic(core.clj:1990)
at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1990)
at clojure.lang.RestFn.invoke(RestFn.java:425)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.RestFn.applyTo(RestFn.java:132)
at clojure.core$apply.invokeStatic(core.clj:671)
at clojure.core$bound_fn_STAR_$fn__5818.doInvoke(core.clj:2020)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.AFn.run(AFn.java:22)
at java.base/java.lang.Thread.run(Thread.java:829)
nil
To quit, type: :cljs/quit
I see the same stacktrace if I used cider-jack-in-cljs
instead of cider-jack-in
.
I dug in a bit, and it seems that repl*
in repl.cljc
is trying to call analyze-file
on the :main
ns (reagent-frontend-test.dev
) that is specified in the project.clj
, but io/resource
is returning nil
, and so analyze-file
ends up throwing.
I am no expert in these matters, but it would be nice, for me, to have the cljs repl in cider rather than in a separate terminal window (as when I do lein figwheel
, which works well).
I suspect I'm either doing something silly, or have the wrong version of something. Let me know what else I can do or provide to help track this down.
Thanks in advance for your time and consideration.
For some reason, the template lein new reagent-frontend <name> +shadow-cljs
breaks for me if the shadow-cljs
dependency in package.json
is above version 2.19.8.
npx shadow-cljs watch app
will only render the page when I remove :handler user/app
from the shadow-cljs.edn
file. I was looking through the changes in https://github.com/thheller/shadow-cljs/blob/6d72ac7e09a1e153fa05498f19fa8dee34bd2474/CHANGELOG.md but I can’t isolate what may be causing this (maybe a dependency bump).
Of course, this relates to the form (def app (wrap-resource identity "public"))
in src/user.clj
. Replacing the call to wrap-resource
with the shadow-cljs default shadow.http.push-state/handle
fixes it, so I am quite sure that it has something to do with the ring-core
dependency (1.9.5 in my case) that may conflict somehow with shadow-cljs (>= 2.19.9).
But even after reinstalling ring and shadow-cljs in my local Maven repo it will just render an empty page, with an empty <head>
and <body>
tag, no error messages in the terminal or browser console.
It happens with Reagent 1.1.0 as well as 1.1.1.
After starting a new project with the command lean new reagent-frontend cljsrte
, the project was created correctly. Attempting to run the new project with lean figwheel
produced an error stack trace starting with
Exception in thread "main" java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter, compiling:(cljs/util.cljc:1:1)
at clojure.lang.Compiler.load(Compiler.java:7391)
at clojure.lang.RT.loadResourceScript(RT.java:372)
at clojure.lang.RT.loadResourceScript(RT.java:363)
at clojure.lang.RT.load(RT.java:453)
...
This is on a new iMac running High Sierra and Java 9.04. FWIW, creating and trying to start a new project with the Reagent template produces the same error.
Java 9 modules problem?
Not sure whether this is correct place to post this:
Are these messages normal for reagent 1.0.0
shadow-cljs release app
shadow-cljs - config: /home/jenkins/code/clojure/myproject/shadow-cljs.edn
[:app] Compiling ...
------ WARNING #1 - -----------------------------------------------------------
Resource: com/cognitect/transit.js:649:8
variable module is undeclared
--------------------------------------------------------------------------------
------ WARNING #2 - -----------------------------------------------------------
File: ~/.m2/repository/reagent/reagent/1.0.0/reagent-1.0.0.jar!/reagent/core.cljs:370
--------------------------------------------------------------------------------
367 | tmpl/default-compiler*
368 | compiler)))
369 |
370 | (defn render
--------------------------------------------------------------------------------
unreachable code
--------------------------------------------------------------------------------
371 | {:deprecated "0.10.0"}
372 | [& _]
373 | (throw (js/Error. "Reagent.core/render function was moved to reagent.dom namespace in Reagent v1.0."))
374 | nil)
--------------------------------------------------------------------------------
nil
[:app] Build completed. (141 files, 1 compiled, 0 warnings, 11.46s)
My shadow-cljs.edn has the following
{:source-paths ["src"]
:dependencies [[binaryage/devtools "1.0.2"]
[nrepl "0.8.3"]
[cider/cider-nrepl "0.25.5"]
[reagent "1.0.0"]
[cljs-ajax "0.8.1"]]
:builds {:app {:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules {:app {:entries [myproject.core]}}
:devtools {:after-load myproject.core/mount-root}}}
:dev-http {3000 {:root "public"
:handler user/app}}}
``
When the app starts, I see this warning in the console:
I believe it's due to these two lines:
If I change them to these:
[cljsjs/react "17.0.2-0"]
[cljsjs/react-dom "17.0.2-0"]
Then the warning goes away.
Maybe want to wait on React 18 until reagent is ready.
Thanks again for this awesome project - I'm off and running, really appreciate you!
Hi, thanks for this project, having a template to quickly setup cljs to test out front-end ideas is great!
I created a new project today with:
lein new reagent-frontend cljs-test +figwheel
And then tried lein figwheel
, but got the following error and it did not start up:
Figwheel: Cutting some fruit, just a sec ...
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: clojure.tools.analyzer.utils, being replaced by: #'clojure.tools.analyzer.utils/update-vals
WARNING: update-keys already refers to: #'clojure.core/update-keys in namespace: clojure.tools.analyzer.utils, being replaced by: #'clojure.tools.analyzer.utils/update-keys
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: clojure.tools.analyzer, being replaced by: #'clojure.tools.analyzer.utils/update-vals
WARNING: update-keys already refers to: #'clojure.core/update-keys in namespace: clojure.tools.analyzer, being replaced by: #'clojure.tools.analyzer.utils/update-keys
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: clojure.tools.analyzer.passes, being replaced by: #'clojure.tools.analyzer.utils/update-vals
WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: clojure.tools.analyzer.passes.uniquify, being replaced by: #'clojure.tools.analyzer.utils/update-vals
Figwheel: Validating the configuration found in project.clj
Figwheel: Configuration Valid ;)
Figwheel: Starting server at http://0.0.0.0:3449
Figwheel: Watching build - app
Compiling build :app to "public/js/app.js" from ["src" "env/dev/cljs"]...
Successfully compiled build :app to "public/js/app.js" in 0.361 seconds.
Figwheel: Starting CSS Watcher for paths ["public/css"]
Figwheel: Starting nREPL server on port: 7002
Launching ClojureScript REPL for build: app
Figwheel Controls:
(stop-autobuild) ;; stops Figwheel autobuilder
(start-autobuild id ...) ;; starts autobuilder focused on optional ids
(switch-to-build id ...) ;; switches autobuilder to different build
(reset-autobuild) ;; stops, cleans, and starts autobuilder
(reload-config) ;; reloads build config and resets autobuild
(build-once id ...) ;; builds source one time
(clean-builds id ..) ;; deletes compiled cljs target files
(print-config id ...) ;; prints out build configurations
(fig-status) ;; displays current state of system
(figwheel.client/set-autoload false) ;; will turn autoloading off
(figwheel.client/set-repl-pprint false) ;; will turn pretty printing off
Switch REPL build focus:
:cljs/quit ;; allows you to switch REPL to another build
Docs: (doc function-name-here)
Exit: :cljs/quit
Results: Stored in vars *1, *2, *3, *e holds last exception object
Prompt will show when Figwheel connects to your application
[Rebel readline] Type :repl/help for online help info
java.io.FileNotFoundException: Could not locate vendor/bridge__init.class, vendor/bridge.clj or vendor/bridge.cljc on classpath.
at clojure.lang.RT.load(RT.java:462)
at clojure.lang.RT.load(RT.java:424)
at clojure.core$load$fn__6908.invoke(core.clj:6161)
at clojure.core$load.invokeStatic(core.clj:6160)
at clojure.core$load.doInvoke(core.clj:6144)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at cljs.repl$repl_STAR_.invokeStatic(repl.cljc:1060)
at cljs.repl$repl_STAR_.invoke(repl.cljc:1033)
at rebel_readline.cljs.repl$eval25605$repl_STAR___25606.invoke(repl.clj:77)
at clojure.lang.Var.invoke(Var.java:388)
at figwheel_sidecar.repl$eval20357$fn__20358.invoke(repl.clj:218)
at clojure.lang.MultiFn.invoke(MultiFn.java:234)
at figwheel_sidecar.repl$repl.invokeStatic(repl.clj:346)
at figwheel_sidecar.repl$repl.doInvoke(repl.clj:344)
at clojure.lang.RestFn.invoke(RestFn.java:436)
at figwheel_sidecar.system$start_figwheel_repl.invokeStatic(system.clj:525)
at figwheel_sidecar.system$start_figwheel_repl.invoke(system.clj:516)
at figwheel_sidecar.system$figwheel_cljs_repl_STAR_.invokeStatic(system.clj:589)
at figwheel_sidecar.system$figwheel_cljs_repl_STAR_.invoke(system.clj:587)
at figwheel_sidecar.system$build_switching_cljs_repl_STAR_.invokeStatic(system.clj:595)
at figwheel_sidecar.system$build_switching_cljs_repl_STAR_.invoke(system.clj:591)
at figwheel_sidecar.system$cljs_repl_STAR_.invokeStatic(system.clj:611)
at figwheel_sidecar.system$cljs_repl_STAR_.invoke(system.clj:602)
at figwheel_sidecar.system$start_repl.invokeStatic(system.clj:636)
at figwheel_sidecar.system$start_repl.invoke(system.clj:630)
at figwheel_sidecar.system$start_repl.invokeStatic(system.clj:634)
at figwheel_sidecar.system$start_repl.invoke(system.clj:630)
at clojure.lang.AFn.applyToHelper(AFn.java:160)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invokeStatic(core.clj:669)
at clojure.core$apply.invoke(core.clj:662)
at figwheel_sidecar.system$cljs_repl.invokeStatic(system.clj:644)
at figwheel_sidecar.system$cljs_repl.doInvoke(system.clj:642)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at figwheel_sidecar.repl_api$start_figwheel_from_lein.invokeStatic(repl_api.clj:156)
at figwheel_sidecar.repl_api$start_figwheel_from_lein.invoke(repl_api.clj:147)
at figwheel_sidecar.repl_api$launch_from_lein.invokeStatic(repl_api.clj:224)
at figwheel_sidecar.repl_api$launch_from_lein.invoke(repl_api.clj:216)
at user$eval21659.invokeStatic(form-init2816361050350365811.clj:1)
at user$eval21659.invoke(form-init2816361050350365811.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:7194)
at clojure.lang.Compiler.eval(Compiler.java:7184)
at clojure.lang.Compiler.load(Compiler.java:7653)
at clojure.lang.Compiler.loadFile(Compiler.java:7591)
at clojure.main$load_script.invokeStatic(main.clj:475)
at clojure.main$init_opt.invokeStatic(main.clj:477)
at clojure.main$init_opt.invoke(main.clj:477)
at clojure.main$initialize.invokeStatic(main.clj:508)
at clojure.main$null_opt.invokeStatic(main.clj:542)
at clojure.main$null_opt.invoke(main.clj:539)
at clojure.main$main.invokeStatic(main.clj:664)
at clojure.main$main.doInvoke(main.clj:616)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:705)
at clojure.main.main(main.java:40)
I don't know what vendor
is in this case, so unfortunately I am a bit stuck.
$ lein --version
Leiningen 2.9.8 on Java 11.0.15 OpenJDK 64-Bit Server VM
Let me know what else I can do or provide to try and help debug.
Thanks again for your time and consideration.
Creating a new project and running lein figwheel
and going to http://localhost:3449 results in a page stating
"Figwheel Server: Resource not found
Keep on figwheelin'"
The template (shadow-cljs variant) generates a src/user.clj
with a custom handler. The only purpose of this handler seems to be to serve classpath resources from the public
prefix. This can be done purely via shadow-cljs.edn
:dev-http
config and does not need a custom handler.
Just turn
{...
:dev-http {3000 {:root "public"
:handler user/app}}}
into
{...
:dev-http {3000 ["public" "classpath:public"]}}
as mentioned in the docs.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.