clojure / clojurescript-site Goto Github PK
View Code? Open in Web Editor NEWwebsite for ClojureScript
License: Eclipse Public License 1.0
website for ClojureScript
License: Eclipse Public License 1.0
We should start enumerating various :npm-deps
issues and how to troubleshoot them. In particular how to determine root causes and what enhancements or changes might be needed to the original JS projects.
The editors listed in the tools section should be be sorted alphabetically :) .
Please add forum on https://www.discourse.org/
Reading https://clojurescript.org/guides/quick-start, the "Browser REPL" section does not work for me. If I follow the instructions and open file:///path/to/index.html
in a browser (chrome, safari or firefox on macos), I get this exception in the browser console:
Uncaught Error: URI file:/robots.txt is invalid for field ppu
at new goog.net.xpc.CrossPageChannel (repl:2457)
at Function.clojure.browser.net.xpc_connection.cljs$core$IFn$_invoke$arity$0 (repl:2540)
at clojure.browser.net.xpc_connection (repl:2539)
at clojure.browser.repl.start_evaluator (repl:3043)
at repl:3052
at Object.goog.events.fireListener (repl:2229)
at goog.events.handleBrowserEvent_ (repl:2232)
at repl:2221
If I start an ad-hoc HTTP server
python -m SimpleHTTPServer 9999
and open http://localhost:9999
in the browser, the errors disappear and the REPL connects. The issue occurs with cljs-1.9.293.jar and cljs-1.9.473.jar.
I don't know where robots.txt
comes into the picture. Does Google Closure's method of creating an iframe work from file://
URLs?
Would be great if the examples for :foreign-libs
provide more details. E.g: defining upstream :foreign-libs
in delps.cljs
file.
There is also option to provide only directory path and the compiler will go through all .js files within the directory and automatically assign :provides
values based on the file name.
implementation in ClojureScript
(defn expand-libs
"EXPERIMENTAL. Given a set of libs expand any entries which only name
directories into a sequence of lib entries for all JS files recursively
found in that directory. All other options will be shared with the original
entry. The computed :provides assumes the specified directory is on the
classpath."
[libs]
(letfn [(prep-path [p root]
(subs (string/replace (subs p 0 (- (count p) 3)) root "") 1))
(path->provides [p]
(let [p' (string/replace p File/separator ".")]
(cond-> [p']
(string/includes? p' "_")
(conj (string/replace p' "_" "-")))))
(expand-lib* [{:keys [file] :as lib}]
(let [root (.getAbsolutePath (io/file file))
dir (io/file file)]
(if (.isDirectory dir)
(into []
(comp
(filter #(.endsWith (.getName ^File %) ".js"))
(filter #(not (.isHidden ^File %)))
(map
(fn [^File f]
(let [p (.getPath f)
ap (.getAbsolutePath f)]
(merge lib
{:file p :provides (path->provides (prep-path ap root))})))))
(file-seq dir))
[lib])))]
(into [] (mapcat expand-lib* libs))))
The following links do not work on the page https://clojurescript.org/community/dev
A "News" section is missing. At least from the top menu.
IMHO even if there's none so far, it could be linked to the clojure.org news page at least.
The guide published at https://clojurescript.org/guides/javascript-modules seems to be slightly incorrect as it doesn't build currently.
Tried integrating a JavaScript library in a project of mine but was getting errors so thought I would put together a minimal reproducible case to get help with.
So, upon finding this guide, I copied and pasted it literally, but that won't build either.
Full error:
Building ...
WARNING: JavaScript file found on classpath for library `js.hello`, but does not contain a corresponding `goog.provide` declaration: file:/data/projects/victorbjelkholm/hello-es6/src/js/hello.js
Reading analysis cache for jar:file:/home/victor/.m2/repository/org/clojure/clojurescript/1.9.854/clojurescript-1.9.854.jar!/cljs/core.cljs
Compiling src/hello_es6/core.cljs
Reading analysis cache for jar:file:/home/victor/.m2/repository/org/clojure/clojurescript/1.9.854/clojurescript-1.9.854.jar!/cljs/nodejs.cljs
WARNING: JavaScript file found on classpath for library `js.hello`, but does not contain a corresponding `goog.provide` declaration: file:/data/projects/victorbjelkholm/hello-es6/src/js/hello.js
clojure.lang.ExceptionInfo: failed compiling file:src/hello_es6/core.cljs {:file #object[java.io.File 0x5457123a "src/hello_es6/core.cljs"]}
at clojure.core$ex_info.invokeStatic(core.clj:4725)
at clojure.core$ex_info.invoke(core.clj:4725)
at cljs.compiler$compile_file$fn__4440.invoke(compiler.cljc:1521)
at cljs.compiler$compile_file.invokeStatic(compiler.cljc:1482)
at cljs.compiler$compile_file.invoke(compiler.cljc:1458)
at cljs.closure$compile_file.invokeStatic(closure.clj:533)
at cljs.closure$compile_file.invoke(closure.clj:524)
at cljs.closure$eval6681$fn__6682.invoke(closure.clj:602)
at cljs.closure$eval6617$fn__6618$G__6606__6625.invoke(closure.clj:486)
at cljs.closure$compile_sources$iter__6805__6809$fn__6810.invoke(closure.clj:947)
at clojure.lang.LazySeq.sval(LazySeq.java:40)
at clojure.lang.LazySeq.seq(LazySeq.java:49)
at clojure.lang.Cons.next(Cons.java:39)
at clojure.lang.RT.next(RT.java:703)
at clojure.core$next__6406.invokeStatic(core.clj:64)
at clojure.core$dorun.invokeStatic(core.clj:3115)
at clojure.core$doall.invokeStatic(core.clj:3121)
at clojure.core$doall.invoke(core.clj:3121)
at cljs.closure$compile_sources.invokeStatic(closure.clj:943)
at cljs.closure$compile_sources.invoke(closure.clj:932)
at cljs.closure$build.invokeStatic(closure.clj:2528)
at cljs.closure$build.invoke(closure.clj:2444)
at cljs.closure$watch$buildf__7486.invoke(closure.clj:2647)
at cljs.closure$watch.invokeStatic(closure.clj:2679)
at cljs.closure$watch.invoke(closure.clj:2623)
at cljs.build.api$watch.invokeStatic(api.clj:219)
at cljs.build.api$watch.invoke(api.clj:207)
at cljs.build.api$watch.invokeStatic(api.clj:216)
at cljs.build.api$watch.invoke(api.clj:207)
at cljs.build.api$watch.invokeStatic(api.clj:210)
at cljs.build.api$watch.invoke(api.clj:207)
at user$eval7609.invokeStatic(watch.clj:3)
at user$eval7609.invoke(watch.clj:3)
at clojure.lang.Compiler.eval(Compiler.java:6978)
at clojure.lang.Compiler.load(Compiler.java:7430)
at clojure.lang.Compiler.loadFile(Compiler.java:7368)
at clojure.main$load_script.invokeStatic(main.clj:277)
at clojure.main$script_opt.invokeStatic(main.clj:337)
at clojure.main$script_opt.invoke(main.clj:332)
at clojure.main$main.invokeStatic(main.clj:423)
at clojure.main$main.doInvoke(main.clj:386)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
at clojure.lang.Reflector.invokeStaticMethod(Reflector.java:207)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
at clojure.lang.Reflector.invokeStaticMethod(Reflector.java:207)
at user$eval15.invokeStatic(form-init4692376554675479651.clj:1)
at user$eval15.invoke(form-init4692376554675479651.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6978)
at clojure.lang.Compiler.eval(Compiler.java:6968)
at clojure.lang.Compiler.load(Compiler.java:7430)
at clojure.lang.Compiler.loadFile(Compiler.java:7368)
at clojure.main$load_script.invokeStatic(main.clj:277)
at clojure.main$init_opt.invokeStatic(main.clj:279)
at clojure.main$init_opt.invoke(main.clj:279)
at clojure.main$initialize.invokeStatic(main.clj:310)
at clojure.main$null_opt.invokeStatic(main.clj:344)
at clojure.main$null_opt.invoke(main.clj:341)
at clojure.main$main.invokeStatic(main.clj:423)
at clojure.main$main.doInvoke(main.clj:386)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
Caused by: clojure.lang.ExceptionInfo: No such namespace: js.hello, could not locate js/hello.cljs, js/hello.cljc, or JavaScript source providing "js.hello" in file src/hello_es6/core.cljs {:tag :cljs/analysis-error}
at clojure.core$ex_info.invokeStatic(core.clj:4725)
at clojure.core$ex_info.invoke(core.clj:4725)
at cljs.analyzer$error.invokeStatic(analyzer.cljc:694)
at cljs.analyzer$error.invoke(analyzer.cljc:690)
at cljs.analyzer$error.invokeStatic(analyzer.cljc:692)
at cljs.analyzer$error.invoke(analyzer.cljc:690)
at cljs.analyzer$analyze_deps.invokeStatic(analyzer.cljc:2111)
at cljs.analyzer$analyze_deps.invoke(analyzer.cljc:2085)
at cljs.analyzer$ns_side_effects.invokeStatic(analyzer.cljc:3430)
at cljs.analyzer$ns_side_effects.invoke(analyzer.cljc:3425)
at cljs.analyzer$analyze_STAR_$fn__3152.invoke(analyzer.cljc:3547)
at clojure.lang.PersistentVector.reduce(PersistentVector.java:341)
at clojure.core$reduce.invokeStatic(core.clj:6703)
at clojure.core$reduce.invoke(core.clj:6686)
at cljs.analyzer$analyze_STAR_.invokeStatic(analyzer.cljc:3547)
at cljs.analyzer$analyze_STAR_.invoke(analyzer.cljc:3537)
at cljs.analyzer$analyze.invokeStatic(analyzer.cljc:3571)
at cljs.analyzer$analyze.invoke(analyzer.cljc:3554)
at cljs.compiler$emit_source.invokeStatic(compiler.cljc:1340)
at cljs.compiler$emit_source.invoke(compiler.cljc:1319)
at cljs.compiler$compile_file_STAR_$fn__4409.invoke(compiler.cljc:1425)
at cljs.compiler$with_core_cljs.invokeStatic(compiler.cljc:1226)
at cljs.compiler$with_core_cljs.invoke(compiler.cljc:1215)
at cljs.compiler$compile_file_STAR_.invokeStatic(compiler.cljc:1410)
at cljs.compiler$compile_file_STAR_.invoke(compiler.cljc:1403)
at cljs.compiler$compile_file$fn__4440.invoke(compiler.cljc:1507)
... 70 more
Watching paths: /data/projects/victorbjelkholm/hello-es6/src
The docs say to create an issue to discuss a new page.
I use Atom in my day-to-day JS work, so I've been using Atom to learn Clojure with the Parinfer and Proto REPL plugins installed, and it's been a pretty positive experience. (Though to be fair, I'm pretty new, so there might be obvious things I'm missing.)
Does adding this page seem like a good idea?
As seen on https://clojurescript.org/reference/google-closure-library#searching-for-examples
You can look for cljs files on Github that use goog.dom with the following search:
Or you can search Google Closure Library on Github for keywords pertaining to a function it might have:
This is clearly missing the actual example searches.
Two links to the source code on the custom REPLs page (http://clojurescript.org/guides/custom-repls) point to a 404. The urls should contain the revision or the branch for the latest version: https://help.github.com/articles/getting-permanent-links-to-files/
Previous conversation: https://twitter.com/jiyinyiyong/status/877826188072239105
When beginners search for a guide, modern-cljs is the only guide they find on first screen.
http://utopia.knoware.nl/~hlub/uck/rlwrap/
http://downforeveryoneorjustme.com/utopia.knoware.nl
I am guessing it supposed to refresh the browser on rebuild? (rlwrap purpose is unclear to me given that the link is dead. But I noticed the quick start instruction is not as described unless I refresh the browser.) Is there a linux equivalent if I am not using OSX?
The page at https://clojurescript.org/tools/testing is missing some information that is currently at https://github.com/clojure/clojurescript/wiki/Testing
Likely worth a PR to get it caught up.
The main source on how to include JavaScript modules is still my blog. It would be good to consolidate the information from the different blog posts and add documentation for JS module support to the site.
The paragraph is at https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure#namespaces.
To demonstrate the pitfall, consider the following example:
;; foo.cljc
(ns foo
(:require [clojure.test :as test])
#?(:cljs (:require-macros [foo])))
(defmacro m [] `(test/deftest ~'x nil))
;; core.cljc
(ns core
(:require [foo]))
(foo/m)
The namespace foo
compiles perfectly well, core
however will warn you about the missing clojure.test
namespace. This places a constraint on core
, so that it has to explicitly require clojure.test
, even though it may not use it directly (therefore it is easy to miss).
def :export
metadata doesn't seem to be mentioned anywhere?
I think it should be mentioned somewhere in reference, and we could also have a simple guide/example about calling Cljs code from JS?
In https://github.com/clojure/clojurescript-site/blob/master/content/about/differences.adoc line 65 there is a malformed link to some info about Google's Closure library.
I would gladly fix/pr this for you but I'm not sure what page you're trying to link to, it just says ./Google-Closure
in the source. Should it be a link to: https://developers.google.com/closure/ ?
You could infer from these unit tests that .indexOf
and .lastIndexOf
are supported on ISequential
types.
If this support is intended to be public and stable, there is currently no good mechanism for ClojureScript developers to know this. This ticket proposes that this be resolved via new documentation on https://clojurescript.org
Resolving this ticket could start small: Just a new page that documents .indexOf
and .lastIndexOf
. If other JavaScript interop is deemed to be supported on ClojureScript-defined types, then this page could be grown in the future.
What I did:
Followed the instructions to download the theme assets for the site so that I could build and preview changes locally: https://github.com/clojure/clojurescript-site/blob/master/content/community/contributing_site.adoc#build
I clicked on the link to the ZIP file (http://cdn.cognitect.com/clojurescript.org/clojuretheme.zip) to download the theme assets.
What happened:
I received a 404 Not Found error. I also tried curl
and saw the same response. I tried HTTPS, but the operation timed out.
What I expected to happen:
I expected to receive a ZIP file with the theme assets.
"This features encourages"
Moved over from https://dev.clojure.org/jira/browse/CLJS-1128
Hey, just wanted to ask is there a repository where current theme is being hosted?
Right now from what I see it's fetched from Cognitect's CDN and there's no repository for it on clojure org.
Cheers!
SSIA
The testing wiki page seem too simple. how run test file with lein. Anyone help me ?
Few things I spotted on the first glance:
Fix: wrap h3
in w-row
and w-col w-col-12
like the rest of headers
Issue: Caption sticks to a box
Fix: .clj-home-company-attribution { margin-bottom: 10px; }
Issue: logo has a background with different color than the rest, overflowing text
Fix: set clj-footer-copyright
and clj-footer-designed-by
to display: static;
for @media (max-width: 991px)
, align clj-footer-legal-links
accordingly and either update background color or background png image to match.
Cheers!
https://clojurescript.org/community/reporting-bootstrap-issues
Formatting's a little off on the Ticket Entry section
The GitHub main clojurescript Readme.md page:
https://github.com/clojure/clojurescript/blob/master/README.md
should point to the clojurescript.org site too.
Every-time new page content is requested, the cljs logo flashes. Can we do some sort of prefetching of content and client side routing to remove the flash?
Kind of like how https://zeit.co works with Next.js
Please excuse my ignorance as I'm new to a lot of this and trying to keep up with all the advancements in the web space!
One particular caveat to mention is that, in some versions of NPM/Node, users need to have a package.json
file present in the directory they're developing in or NPM will install modules to a parent directory.
Hello,
The guide about code-splitting says (emphasis mine):
but this feature only worked under
:advanced
compilation [...] All of these issues are now addressed directly in ClojureScript [...]:optimizations :none
And the compiler options reference page says (for :modules
):
Modules are only supported with
:simple
and:advanced
optimizations.
It happens that you can still use :whitespace
and :none
when developing locally and it would still work. It will respect the split modules and respect the special :cljs-base
special split, it will just also produce a single javascript file for every ClojureScript/Closure namespace (like it does without code-splitting).
It made me think when developing you had to sacrifice the speed of recompilation to get code-splitting, but it's not the case. Code-splitting code still works in dev with :none
, it just produces other files than what's specified through :modules
. In this regard I understand why reference page says it only works in :simple
and :advanced
mode, but I find it a bit confusing.
Maybe this needs some rephrasing ?
We have a section on how to report issues https://clojurescript.org/community/reporting-issues and it discusses some somewhat technical details related to trying master.
We might be able to get a little more help from the community by simply documenting how to bisect, especially in the case where a minimal REPL-based repro is known. Here is a rough draft of the kind of content that might be useful:
Checkout ClojureScript master and cd to the top of the checkout tree.
Assuming you know it is broken on master but worked in 1.9.562, and there is an easy test you can do right in the REPL.
Run these three commands in your shell:
git bisect start git bisect bad HEAD git bisect good r1.9.562
Start up the Node REPL using
script/clean && script/bootstrap && rm -rf .cljs_node_repl && script/noderepljs
Try your test in the REPL and then exit the REPL.
If your test succeeded:
git bisect good
Or if your test failed:
git bisect bad
If the bisect is complete, git will incidate that a certain commit hash "is the first bad commit". Copy all of this text for JIRA.
Otherwise go back to the "Start up the Node REPL" step and repeat until done.
When finished, you can do this to restore your git checkout:
git bisect reset
In the ClojureScript Quick Start in the early parts every command will be duplicated for "Mac or GNU/Linux" and "Windows". E.g.:
Rebuild on Mac or GNU/Linux:
java -cp cljs.jar:src clojure.main build.clj
On Windows:
java -cp "cljs.jar;src" clojure.main build.clj
From the Auto-building section on it stops doing so, with only *nix style instructions, e.g.:
Let’s start auto building:
java -cp cljs.jar:src clojure.main watch.clj
This caught me off guard. I copy/pasted the above to my Powershell prompt but was met with:
Error: Could not find or load main class clojure.main
Which, in hindsight, makes sense.
It might be good to either include Windows-specific instructions everywhere, or leave them out everywhere with only a heads up at the start of the tutorial.
I've just had to use Google Closure directly for the first time, and I found it difficult to understand the nuances in order to get things working properly on a real project even after reading all the documentation and linked blog posts. The areas that were unclear to me:
[ ]
, ( )
, or nothing - particularly when importing multiple dependencies.(:import [goog URI OtherNS])
- the examples didn't explain this clearly to me.ol.source.Vector
and ol.layer.Vector
- What is the recommended way to work with these? Is there a way to import classes with a namespace to distinguish these?URI.
or goog.URI.
- this is laid out in a limited form, but I think an example of more extended interop would be very useful.I also think it would be worthwhile to better explain the benefits of using import
over require
, but with the caveat that everything will still work fine if you just require
everything - it may allow other beginners to this part of ClojureScript to get thing working quickly and improve or experiment as they understand things better.
I'm planning to work on a PR for this.
Any search I try results in empty search results, and in the browser's console I see it's due to a 500 Internal Server Error. For example:
GET https://search.clojurescript.org/?q=println 500 (Internal Server Error)
send @ jquery.min.js:4
ajax @ jquery.min.js:4
m.fn.load @ jquery.min.js:4
(anonymous) @ search?q=println:88
(anonymous) @ search?q=println:89
Moved over from https://dev.clojure.org/jira/browse/CLJS-1129
Searching for something that is definitely there yields no results.
The pages
https://clojurescript.org/guides/javascript-modules
and
https://clojurescript.org/reference/javascript-module-support
seem to be pretty similar in both name and scope. I suspect that they should either be combined into a single page, or split into a more specific reference and guide with a little less crossover.
I'll start work on a PR if nobody beats me to it, though it may be a while - I'll need to understand things a bit better first. I think there's also been some relevant improvements in this space since the last edits as well.
Considerations around the ns
are sufficiently complex, where I think a guide page covering it might be useful.
In particular, I think the guide can cover
clojure
namespaces aliasing, deriving material from ClojureScript clojure Namespace AliasingQuickStart has links to the released cljs.jar
that need to be manually updated. Would be cool to somehow automate (or perhaps revise to language that refers to https://github.com/clojure/clojurescript/releases/latest)
For the next release. Foreign library docs should be updated.
The tools page mentions lein-cljsbuild
and lein-figwheel
. Boot-clj
covers these areas as well. I wrote a blog post about converting a leiningen figwheel project to boot-clj
here, which could serve as inspiration, but it has been written a year ago. Things might have changed/evolved/improved.
https://clojurescript.org/community/road-map
It seems like a lot (most?) of the stuff on that page is complete. Perhaps we could simply remove the page.
Having a high level road map to consult might be interesting to the contributor community. If instead we update the page for new dev road map items, perhaps the mention of a 1.0 release could be omitted.
Suggestion: one ref page, one guide page. The Guide is where people go to learn interop; the Ref is for quick reference by people who already know. PRs on the way.
I think this would be nice to have a playground available from the website. This is how I first tried clojurescript few years ago and I wish new comers could do the same.
elm as an "online editor" (not sure if it's linked from the main page) http://elm-lang.org/try
coffescript as a "try button" on the main page http://coffeescript.org/
TypeScript as a "playground" on the main page https://www.typescriptlang.org/play/index.html
Dart as a "Dartpad" example linked on the main page https://dartpad.dartlang.org/b51ea7c04322042b582a
Different terminology but I like the playground one.
They almost all have some examples/template with the Dart ones better than the others from my point of view (a websocket client for example)
I guess klipse would be nice (I'm watching the klipse ClojuTRE video)
Loading example from gist looks straightforward https://github.com/viebel/klipse/blob/master/repl.md
I would be happy to propose a pull request once the ideas, terminology and examples are validated
For the next release
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.