diff --git a/figwheel-main/.dir-locals.el b/figwheel-main/.dir-locals.el deleted file mode 100644 index 166468dc..00000000 --- a/figwheel-main/.dir-locals.el +++ /dev/null @@ -1,7 +0,0 @@ -((nil - (eval . (cider-register-cljs-repl-type - 'fm - "(require 'figwheel.main)(figwheel.main/start \"dev\")" - 'cider-verify-piggieback-is-present - )) - (cider-default-cljs-repl . fm))) diff --git a/figwheel-main/.gitignore b/figwheel-main/.gitignore deleted file mode 100644 index d70430a6..00000000 --- a/figwheel-main/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -target -.cpcache -*.log diff --git a/figwheel-main/CHANGES.md b/figwheel-main/CHANGES.md deleted file mode 100644 index a7542a43..00000000 --- a/figwheel-main/CHANGES.md +++ /dev/null @@ -1,36 +0,0 @@ -# 0.1.3 - -* enable reloading of dependents, configurable with :reload-dependents -* bump rebel-readline-cljs dep to latest -* fix the helper app so that it only attempts to operate on a DOM node if it is present -* added new evalback functionality which gives the client the ability to evaluate cljs - through the figwheel REPL connection -* fixed a problem where js/require couldn't be invoked from the REPL in Node -* ensure that repl warnings don't make it into the source code for a required ns -* added some helper content for the new figwheel-main-template -* validate that symbols in config don't start with quotes (a very common mistake) - -# 0.1.2 Fix for Java 9/10 - -* fix classloader bug that prevented figwheel.main from starting Java 9/10 -* fix NPE when nonexistant namespace is provided as main ns - -# 0.1.1 Classpath Repair, Devtools and Helper App - -* add helper app to provide contextual information when launching `figwheel.main` -* fix case when target directory is on the classpath but does not - exist, as resources will not resolve in this case -* warn when there is a `resources/public/index.html` and the `resources` - directory is not on the classpath -* ensure that the watched directories are on the classpath -* ensure that the watched directories have source files -* ensure the directory, that the `:main` ns is in, is on the classpath -* auto include `binaryage/devtools` in opt none builds targeting the browser -* fixed bug where providing a `:ring-handler` in build metadata didn't work -* fixed bug where single compiles with the -c option were not working for optimization - levels other than none -* add `:client-log-level` option to set the level for client side logging -* fixed problem where node target builds were launching a browser -* fixed undefined var warnings in the REPL by ensuring full analysis on REPL start - -# 0.1.0 Initial Release diff --git a/figwheel-main/Makefile b/figwheel-main/Makefile deleted file mode 100644 index f902c689..00000000 --- a/figwheel-main/Makefile +++ /dev/null @@ -1,58 +0,0 @@ -# makefile for figwheel.main -PROJECT_FILES=../figwheel-core/project.clj ../figwheel-repl/project.clj project.clj -DOC_FILES=README.md helper-content/*.md -DEPS_FILES=deps.edn - -# sed commands for changing version strings -CHANGE_LEIN_DEPS=sed -i '' -e "s|\[com.bhauman/figwheel-\([^[:space:]]*\) \"[^\"]*\"\]|[com.bhauman/figwheel-\1 \"$(VERSION)\"]|g" -CHANGE_TOOLS_DEPS=sed -i '' -e "s|com.bhauman/figwheel-\([^[:space:]]*\) {:mvn/version \"[^\"]*\"}|com.bhauman/figwheel-\1 {:mvn/version \"$(VERSION)\"}|g" -CHANGE_TOOLS_DEPS_ESC=sed -i '' -e "s|com.bhauman/figwheel-\([^[:space:]]*\) {:mvn/version \\\\\"[^\"]*\\\\\"}|com.bhauman/figwheel-\1 {:mvn/version \\\\\"$(VERSION)\\\\\"}|g" -MARKDOWN=ruby scripts/kram.rb - -deps-version: - sed -i '' -e "s|defproject com.bhauman/figwheel-\([^[:space:]]*\) \"[^\"]*\"|defproject com.bhauman/figwheel-\1 \"$(VERSION)\"|g" $(PROJECT_FILES) - $(CHANGE_LEIN_DEPS) $(PROJECT_FILES) - $(CHANGE_TOOLS_DEPS) $(DEPS_FILES) - -docs-version: - $(CHANGE_LEIN_DEPS) $(DOC_FILES) - $(CHANGE_TOOLS_DEPS) $(DOC_FILES) - $(CHANGE_TOOLS_DEPS_ESC) $(DOC_FILES) - -snapshot-version: deps-version - -release-version: deps-version docs-version - -helper-docs: - $(MARKDOWN) helper-content/* - -opt-docs: - clojure -Adocs - -docs: helper-docs opt-docs - -helper: - clojure -Abuild-helper - -clean: - rm -rf target - -clean-m2: - rm -rf ~/.m2/repository/com/bhauman - rm -rf .cpcache - -install: clean - pushd ../figwheel-core; lein install; popd; pushd ../figwheel-repl; lein install; popd; lein install - -test10: clean - jenv local 10.0 - lein test - jenv local 1.8 - -testit: clean - lein test - -testall: testit test10 - -deploy: clean install docs helper testall - pushd ../figwheel-core; lein deploy clojars; popd; pushd ../figwheel-repl; lein deploy clojars; popd; lein deploy clojars diff --git a/figwheel-main/README.md b/figwheel-main/README.md index e56ebd68..72af08f5 100644 --- a/figwheel-main/README.md +++ b/figwheel-main/README.md @@ -1,359 +1,5 @@ -# figwheel-main +# Figwheel Main has moved -[![Clojars Project](https://img.shields.io/clojars/v/com.bhauman/figwheel-main.svg)](https://clojars.org/com.bhauman/figwheel-main) +Figwheel Main now has it's own repository at +[https://github.com/bhauman/figwheel-main](https://github.com/bhauman/figwheel-main) -Figwheel Main is intended to provide a `cljs.main` like command line -experience for ClojureScript that also provides the many features that -were first developed in `lein-figwheel` but better. - -* Hot Code Reloading -* Stable multiplexing REPL connection -* CSS reloading -* Heads-up display for compile time errors -* Pop to editor from heads-up display -* Built in ring development server - -`figwheel-main` is a **complete rewrite** of original figwheel. All of the -above features have been improved significantly. - -* Hot code reloading has been significantly revamped. -* The REPL now only evals on one client and allows you to choose which one at runtime. -* The built-in ring server is now the ring-jetty-adapter which will - allow the use of HTTPS, and extensive configuration of the server itself -* the built-in ring server now uses `ring-defaults` and allows - extensive configuration of the middleware -* the amount of config needed to get started has been significantly - reduced -* the configuration options have been simplified - -The new architecture also makes it trivial to add your own development -tools that can communicate from the server to your client. - -> Currently ONLY works for a browser and Node environments - -> Currently still undergoing heavy development. Stuff will most certainly change. - -> This documentation is incomplete and intended to help you take the new figwheel -> for a spin before its official release. - -## Get started with the template - -Get a working example up and running quickly with the [figwheel.main template](http://rigsomelight.com/figwheel-main-template/) - -## Quick Usage - -> It is assumed that you have perused https://clojurescript.org/guides/quick-start - -First, make sure you have the [Clojure CLI Tools](https://clojure.org/guides/getting_started) -installed. - -On Mac OSX with brew: - - brew install clojure - -Now launch a ClojureScript REPL with: - -``` -clj -Sdeps "{:deps {com.bhauman/figwheel-main {:mvn/version \"0.1.3\"}}}}" -m figwheel.main -``` - -This will first compile browser REPL code to a temp directory, and -then a browser will open and a `cljs.user=>` prompt will appear. - -From here you can do REPL driven development of ClojureScript. - -You can also use `leiningen` by adding it to `:dependencies` in your -`project.clj` and launching it like so: - -``` -lein run -m figwheel.main -``` - -**With Rebel Readline for much better REPL experience** - -Figwheel main will automatically use `rebel-readline-cljs` it is -available. So you can get Rebel Readline behavior by simply adding it -to your dependencies. - -``` -clojure -Sdeps "{:deps {com.bhauman/figwheel-main {:mvn/version \"0.1.3\"} com.bhauman/rebel-readline-cljs {:mvn/version \"0.1.4\"}}}}" -m figwheel.main -``` - -As of right now Rebel readline does create some startup overhead -(hoping to correct this in the near future), so you may want to choose -use it only when you are going to interact at the REPL. - -**Creating a build** - -To define a build which will allow you work on a set of files and hot -reload them. - -Ensure your `deps.edn` file has `figwheel.main` dependencies: - -```clojure -{:deps {com.bhauman/figwheel-main {:mvn/version "0.1.3"} - com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}} - ;; setup common development paths that you may be used to - ;; from lein - :paths ["src" "target" "resources"]} -``` - -Create a file `dev.cljs.edn` build file: - -```clojure -{:main example.core} -``` - -And in `src/example/core.cljs` - -```clojure -(ns example.core) -(enable-console-print!) -(prn "hello world!") -``` - -and run the command: - -``` -clojure -m figwheel.main -b dev -r -``` - -This will launch a REPL and start autobuilding and reloading the `src` -directory so that any files you add or change in that directory will -be automatically hot reloaded into the browser. - -The `-b` or `--build` flag is indicating that we should read -`dev.cljs.edn` for configuration. - -The `-r` or `--repl` flag indicates that a repl should be launched. - -Interesting to note that the above command is equivalent to: - -``` -clojure -m figwheel.main -co dev.cljs.edn -c -r -``` - -Note: that if you want to add your own `index.html` file to host your -application, if you have added `resources` to your "deps.edn" `:paths` -key, as demonstrated above, you can place the `index.html` in -`resources/public/index.html` - -## Configuring Figwheel Main - -If you need to configure figwheel.main, place a `figwheel-main.edn` -in the same directory that you will be executing it from. - -If you need to override some of the figwheel configuration options for a -particular build, simply add those options as meta data on the build edn. - -For example if you want to have `:watch-dirs` that are specific to the -"dev" build then in `dev.cljs.edn` - -```clojure -^{:watch-dirs ["cljs-src"] - :css-dirs ["resources/public/css"]} -{:main example.core} -``` - -All the available configuration options are documented here: -https://github.com/bhauman/lein-figwheel/blob/master/figwheel-main/doc/figwheel-main-options.md - -All the available configuration options specs are here: -https://github.com/bhauman/lein-figwheel/blob/master/figwheel-main/src/figwheel/main/schema.clj - -## Classpaths, Classpaths, Classpaths - -Understanding of the Java Classpath can be very helpful when working -with ClojureScript. - -ClojureScript searches for source files on the Classpath. When you add -a `re-frame` dependency like so: - -```clojure -{:deps {com.bhauman/figwheel-main {:mvn/version "0.1.3"} - com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"} - ;; adding re-frame - re-frame {:mvn/version "1.10.5"}} - :paths ["src" "target" "resources"]} -``` - -The source files in `re-frame` are on the Classpath and the -ClojureScript compiler can find `re-frame.core` when you require it. - -Your sources will need to be on the Classpath so that the Compiler can -find them. For example, if you have a file -`cljs-src/example/core.cljs` you should add `cljs-src` to the `:paths` -key so that the ClojureScript compiler can find your `example.core` -namespace. It is important to note that the `src` directory is on your -Classpath by default. - -In Figwheel, the embedded HTTP server serves its files from the Java -Classpath. - -It actually serves any file it finds in on a Classpath in a `public` -sub-directory. This is why we added `target` and `resources` to the -`:paths` key in the `deps.edn` file above. With `target` and -`resources` both on the Classpath the server will be able to serve -anyfile in `target/public` and `resources/public`. - -The compiler by default compiles artifacts to `target` for easy cleaning. - -It is custmary to put your `index.html`, CSS files, and other -web artifacts in the `resources/public` directory. - -## Working with Node.js - -Unlike `cljs.main`, with `figwheel.main` you will not specify a -`--repl-env node` because the `figwheel.repl` handles Node.js REPL -connections in addition to others. - -You can launch a Node REPL like so: - - clojure -m figwheel.main -t node -r - -You can quickly get a hot reloading CLJS node build up an running using the -`deps.edn`, `example.core` and `dev.cljs.edn` above. Simply add a `--target node` -or `-t node` to the compile command. - - clojure -m figwheel.main -t node -b dev -r - -This will launch a CLJS Node REPL initialized with `example.core` you -can now edit `example/core.cljs` and it will be hot reloaded. - -Of course if you add `:target :nodejs` to `dev.cljs.edn` like so: - -```clojure -{:main example.core - :target :nodejs} -``` - -You be able to run the build more simply: - - clojure -m figwheel.main -b dev -r - -## Reload hooks - -It is common to want to provide callbacks to do some housekeeping -before or after a hot reload has occurred. - -You can conveniently configure hot reload callbacks at runtime with -metadata. You can see and example of providing callbacks below: - -```clojure -;; first notify figwheel that this ns has callback defined in it -(ns ^:figwheel-hooks example.core) - -;; mark the hook functions with ^:before-load and ^:after-load -;; metadata - -(defn ^:before-load my-before-reload-callback [] - (println "BEFORE reload!!!")) - -(defn ^:after-load my-after-reload-callback [] - (println "AFTER reload!!!")) -``` - -The reload hooks will be called before and after every hot code reload. - -## Quick way for experienced devs to understand the command line options - -You can supply a `-pc` or `--pprint-config` flag to `figwheel.main` -and it will print out the computed configuration instead of running -the command. - -For example: - -``` -clojure -m figwheel.main -pc -b dev -r -``` - -Will output: - -```clojure ----------------------- Figwheel options ---------------------- -{:ring-server-options {:port 9550}, - :client-print-to [:repl :console], - :pprint-config true, - :watch-dirs ("src"), - :mode :repl} ----------------------- Compiler options ---------------------- -{:main exproj.core, - :preloads [figwheel.core figwheel.main figwheel.repl.preload], - :output-to "target/public/cljs-out/dev-main.js", - :output-dir "target/public/cljs-out/dev", - :asset-path "cljs-out/dev", - :aot-cache false, - :closure-defines - #:figwheel.repl{connect-url - "ws://localhost:9550/figwheel-connect?fwprocess=c8712b&fwbuild=dev", - print-output "repl,console"}} -``` - -## Using figwheel.main from a script - -See the `figwheel.main/start` function and the `figwheel.main/start-join` functions. - -## Contributing to the Helper App - -Figwheel main comes with a helper Ring app that is served when there -is no other html page to host the REPL JavaScript env. - -If you are interested in contributing to this app: - -First hit me up in #figwheel-main channel on the clojurians Slack so -that we can coordinate a bit. - -To work on the helper app: - -Checkout this repository and change directory to the `figwheel-main` -directory where this README is located. - -Then the command - -```shell -clj -m figwheel.main -b helper -r -``` - -should launch a live development workflow for the Helper application. - -**tweaking the CSS** - -The **CSS** files for the helper app are located at -`helper-resources/public/com/bhauman/figwheel/helper/css` and you -should be able to edit them live. - -**working on the app itself** - -Both the server-side and client side code are located in -`src/figwheel/main/helper.cljc` and you should be able to work on them -live. - -If you change the behavior of the CLJS in -`src/figwheel/main/helper.cljc` it will not be reflected in the actual -helper app until you compile with `make helper` - -**editing helper content** - -The helper app content is generated from the Markdown files in the -`helper-content` directory. You must compile the markdown with `make -helper-docs` this currently requires `ruby` and **kramdown** (`gem -install kramdown`) - -**keep it simple** - -The helper app is intended to be very simple in structure. We do not want to -add more dependencies and slow the startup time of `figwheel.main`, -and we also do not want to do anything that will interfere with the -users running code. - -## More to come ... - -Figwheel Main aims to honor all the flags provided by `cljs.main`, as -of right now, your mileage may vary. - -## License - -Copyright © 2018 Bruce Hauman - -Distributed under the Eclipse Public License either version 1.0 or any -later version. diff --git a/figwheel-main/deps.edn b/figwheel-main/deps.edn deleted file mode 100644 index f239b412..00000000 --- a/figwheel-main/deps.edn +++ /dev/null @@ -1,44 +0,0 @@ -{:deps {org.clojure/clojure {:mvn/version "1.9.0"} - org.clojure/clojurescript {:mvn/version "1.10.238"} - com.bhauman/figwheel-repl {:mvn/version "0.1.3"} - com.bhauman/figwheel-core {:mvn/version "0.1.3"} - - ;; server - ring {:mvn/version "1.6.3"} - org.eclipse.jetty.websocket/websocket-servlet {:mvn/version "9.2.21.v20170120"} - org.eclipse.jetty.websocket/websocket-server {:mvn/version "9.2.21.v20170120"} - - ;; file watching - hawk {:mvn/version "0.2.11"} - - ;; possibly external - binaryage/devtools {:mvn/version "0.9.10"} - - ;; going to make validation seperate? - expound {:mvn/version "0.7.0"} - com.bhauman/spell-spec {:mvn/version "0.1.0"}} - - :paths ["src" "helper-resources"] - - :aliases {:build-helper - {:main-opts ["-m" - "figwheel.main" - "-co" "helper.cljs.edn" - "-o" - "helper-resources/public/com/bhauman/figwheel/helper.js" - "-O" - "advanced" - "-c" - "figwheel.main.helper"]} - :docs - {:extra-paths ["dev"] - :main-opts ["-e" (build-option-docs)]} - :rebel - {:extra-deps {com.bhauman/rebel-readline-cljs {:mvn/version "0.1.3"}}} - :dev - {:extra-deps - {com.bhauman/figwheel-core {:local/root "/Users/bhauman/workspace/lein-figwheel/figwheel-core"} - com.bhauman/figwheel-repl {:local/root "/Users/bhauman/workspace/lein-figwheel/figwheel-repl"}} - :extra-paths ["target" "devel" "dev"]}} - - } diff --git a/figwheel-main/dev/user.clj b/figwheel-main/dev/user.clj deleted file mode 100644 index 3d0abd94..00000000 --- a/figwheel-main/dev/user.clj +++ /dev/null @@ -1,6 +0,0 @@ -(ns user - (:require [figwheel.server.ring] - [figwheel.main.schema.config])) - -(defn build-option-docs [] - (figwheel.main.schema.core/output-docs "doc/figwheel-main-options.md")) diff --git a/figwheel-main/devel/exproj/core.cljs b/figwheel-main/devel/exproj/core.cljs deleted file mode 100644 index a270f4e9..00000000 --- a/figwheel-main/devel/exproj/core.cljs +++ /dev/null @@ -1,46 +0,0 @@ -(ns exproj.core - (:require - [goog.events] - [goog.object :as gobj] - [clojure.string :as string] - [exproj.other] - [cljs.test :refer [deftest is]])) - -(enable-console-print!) - -(defn hello [] - "hello exproj") - -(defn ^:after-load after-hook [] - (js/console.log "Called the AFTER hook!!!")) - -(defn ^:before-load befor-hook [& args] - (js/console.log "Called the before hook!!!")) - -(deftest this-is-a-test - (prn "hello") - (is false)) - - - -#_(d) - -;; stable reference -#_(defonce after-load (fn [e] (prn :after (.. e -data)))) -;; idempotent with stable reference -#_(.addEventListener js/document.body "figwheel.after-load" after-load) -#_(cljs.pprint/pprint (deref js/figwheel.core.state)) -#_(defonce before-load (fn [e] (prn :before (.. e -data)))) -;; idempotent with stable reference -#_(.addEventListener js/document.body "figwheel.before-load" before-load) - -#_(defonce after-css-load (fn [e] (prn :after-css-load (.. e -data)))) -;; idempotent with stable reference -#_(.addEventListener js/document.body "figwheel.after-css-load" after-css-load) - -(defn -main [& args] - (prn 35) - 35) - -#_(defn) -#_(d d d d d d d) diff --git a/figwheel-main/devel/exproj/other.cljs b/figwheel-main/devel/exproj/other.cljs deleted file mode 100644 index 8b9d93b0..00000000 --- a/figwheel-main/devel/exproj/other.cljs +++ /dev/null @@ -1,5 +0,0 @@ -(ns exproj.other) - -(defn hello-there [] "hello there") - - diff --git a/figwheel-main/devel/exproj/server.clj b/figwheel-main/devel/exproj/server.clj deleted file mode 100644 index eac9b885..00000000 --- a/figwheel-main/devel/exproj/server.clj +++ /dev/null @@ -1,6 +0,0 @@ -(ns exproj.server) - -(defn handler [r] - {:status 404 - :headers {"Content-Type" "text/html"} - :body "Server is working"}) diff --git a/figwheel-main/devver.cljs.edn b/figwheel-main/devver.cljs.edn deleted file mode 100644 index 9a29ba3f..00000000 --- a/figwheel-main/devver.cljs.edn +++ /dev/null @@ -1,3 +0,0 @@ -^{:watch-dirs ["src"]} -{:main exproj.core - :hi 1} diff --git a/figwheel-main/doc/command-line-semantics.md b/figwheel-main/doc/command-line-semantics.md deleted file mode 100644 index 65845560..00000000 --- a/figwheel-main/doc/command-line-semantics.md +++ /dev/null @@ -1,95 +0,0 @@ -# Questions/Explorations about the semantics of command line combinations - -#### What command line args will cause figwheel to autobuild and insert code to establish a repl connection? - -For the following examples assume `dev.cljs.edn` is in the current -directory and contains: - -```clojure -{:main example.core} -``` - -Acknowledge that there is need to simply autobuild without a server or -server connection. - - -w src -c example.core - -This should autobuild without a server or repl connection. If one -wants to supply the compile options resident in a figwheel build -config file (i.e. dev.cljs.edn) one can simply pass that config as a -normal `cljs.main` `-co` flag arg: - - -w src -co dev.cljs.edn -c - -and the above will not insert any repl or figwheel functionality into -the build or build process. - -The same is true for a single compile without watching of any kind. - - -co dev.cljs.edn -c - -and - - -c example.core - -should only compile once and have no figwheel libraries or -other functionality inserted into it. - -But once you add a `--repl` or `-serve` flag to the operation and the -compile `:optimizations` level is `:none` then figwheel specific -functionality will come into play. - -So for a command of: - - -co dev.cljs.edn -c -r - -Figwheel main will take actions to try and create a figwheel -autobuilding development session. - -1. a build name `dev` will be infered from the `dev.cljs.edn` file name -1. if no configured watch directories are found `figwheel.main` will - try to infer one from the given namespace if it can find it -2. it will insert `[figwheel.repl.preload figwheel.core figwheel.main]` into - the `:preloads` of the compile options -3. it will add a `figwheel.repl/connect-url` and perhaps some other - configuration into `:closure-defines` of the compile options -4. it will start a server, repl, and launch a browser to connect to - the repl server - -When you only ask for a server via: - - -co dev.cljs.edn -c -s - -A REPL will not be launched but all of the above steps will still be taken. - -There is a shortcut *main* option flag `-b` or `--build` which can be -used in place of the `-c` flag. - -The following examples are equivalient - - -b dev -r == -co dev.cljs.edn -c -r - - -b dev -s == -co dev.cljs.edn -c -s - - -b dev == -co dev.cljs.edn -c -s - -So when you use the `--build` flag you will normally get a server as well. - -#### How to build once with the `--build-once` or `-bo` flag - -#### Background builds and the `--bb` flag - -#### Turning various features off - -#### How do I better determine the behavior of a set of command line args? - -There is a `--pprint-config` or `-pc` *init* arg which when added to -the command line like so: - - -pc -co dev.cljs.edn -c example.core -s - -Will print out useful information about the resulting configuration. - - - - diff --git a/figwheel-main/doc/figwheel-main-options.md b/figwheel-main/doc/figwheel-main-options.md deleted file mode 100644 index 2179c4de..00000000 --- a/figwheel-main/doc/figwheel-main-options.md +++ /dev/null @@ -1,407 +0,0 @@ -# Figwheel Main Configuration Options - -The following options can be supplied to `figwheel.main` via the `figwheel-main.edn` file. - -# Commonly used options (in order of importance) - -## :watch-dirs - -A list of ClojureScript source directories to be watched and compiled on change. - - :watch-dirs ["cljs-src"] - -## :css-dirs - -A list of CSS source directories to be watched and reloaded into the browser. - - :css-dirs ["resource/public/css"] - -## :ring-handler - -A symbol or string indicating a ring-handler to embed in the -figwheel.repl server. This aids in quickly getting a dev server up and -running. If the figwheel server doesn't meet your needs you can simply -start your own server, the figwheel.client will still be able to -connect to its websocket endpoint. -Default: none - - :ring-handler my-project.server/handler - -## :ring-server-options - -All the options to forward to the `ring-jetty-adapter/run-jetty` function -which figwheel.main uses to run its ring server. - -All the available options are documented here: -https://github.com/ring-clojure/ring/blob/master/ring-jetty-adapter/src/ring/adapter/jetty.clj#L127 - -This will normally be used to set the `:port` and `:host` of the server. - -Most uses of these options are considered advanced if you find -yourself using many of these options you problably need to run your -own server outside of figwheel.main. - -## :rebel-readline - -By default Figwheel engauges a Rebel readline editor when it starts -the ClojureScript Repl in the terminal that it is launched in. - -This will only work if you have `com.bhauman/rebel-readline-cljs` in -your dependencies. - -More about Rebel readline: -https://github.com/bhauman/rebel-readline - -Default: true - - :rebel-readline false - -## :pprint-config - -When `:pprint-config` is set to true. The `figwheel.main` will print the -computed config information and will terminate the process. Useful for -understanding what figwheel.main adds to your configuration before it -compiles your build. - -Default: false - - :pprint-config true - -## :open-file-command - -A path to an executable shell script that will be passed a file and -line information for a particular compilation error or warning. - -A script like this would work -ie. in ~/bin/myfile-opener - - #! /bin/sh - emacsclient -n +$2:$3 $1 - -The add this script in your config: - - :open-file-command "myfile-opener" - -But thats not the best example because Figwheel handles `emacsclient` -as a special case so as long as `emacsclient` is on the shell path you can -simply do: - - :open-file-command "emacsclient" - -and Figwheel will call emacsclient with the correct args. - -## :figwheel-core - -Wether to include the figwheel.core library in the build. This - enables hot reloading and client notification of compile time errors. - Default: true - - :figwheel-core false - -## :hot-reload-cljs - -Whether or not figwheel.core should hot reload compiled -ClojureScript. Only has meaning when :figwheel is true. -Default: true - - :hot-reload-cljs false - -## :reload-dependents - -Whether or not figwheel.core should reload reload the namespaces -that `depend` on the changed namespaces in addition to the changed -namespaces themselves. Only has meaning when :figwheel is true. -Default:true - - :reload-dependents false - -## :connect-url - -The url that the figwheel repl client will use to connect back to -the server. - -This url is actually a template that will be filled in. For example -the default `:connect-url` is: - - "ws://[[config-hostname]]:[[server-port]]/figwheel-connect" - -The available template variables are: - -For the server side: - - [[config-hostname]] the host supplied in :ring-server-options > :host or "localhost" - [[server-hostname]] the java.InetAddress localhost name - "Bruces-MacBook-Pro.local" on my machine - [[server-ip]] the java.InetAddress localhost ip interface - normally 192.168.x.x - [[server-port]] the port supplied in :ring-server-options > :port or the default port 9500 - -On the client side: - - [[client-hostname]] the js/location.hostname on the client - [[client-port]] the js/location.port on the client - -If the url starts with a Websocket scheme "ws://" a websocket -connection will be established. If the url starts with an http scheme -"http" an http long polling connection will be established. - -## :open-url - -Either a boolean value `false` or a string that indicates the url -that the figwheel repl will open in the browser after the source code -has been compiled. A `false` value will disable this behavior. - -The string value is actually a template that can provide optional -template variables. For example the default `:open-url` is: - - "http://[[server-hostname]]:[[server-port]]" - -The available template variables are: - -For the server side: - - [[server-hostname]] the host supplied in :ring-server-options > :host or "localhost" - [[server-port]] the port supplied in :ring-server-options > :port or the default port 9500 - -## :reload-clj-files - -Figwheel naively reloads `clj` and `cljc` files on the `:source-paths`. -It doesn't reload clj dependent files like tools.namspace. - -Figwheel does note if there is a macro in the changed `clj` or `cljc` file -and then marks any cljs namespaces that depend on the `clj` file for -recompilation and then notifies the figwheel client that these -namespaces have changed. - -If you want to disable this behavior: - - :reload-clj-files false - -Or you can specify which suffixes will cause the reloading - - :reload-clj-files #{:clj :cljc} - -## :log-file - -The name of a file to redirect the figwheel.main logging to. This -will only take effect when a REPL has been started. - - :log-file "figwheel-main.log" - -## :log-level - -The level to set figwheel.main java.util.logger to. -Can be one of: `:error` `:info` `:debug` `:trace` `:all` `:off` - - :log-level :error - -## :client-log-level - -The log level to set the client side goog.log.Logger to for -figwheel.repl and figwheel.core. Can be one of: -`:severe` `:warning` `:info` `:config` `:fine` `:finer` `:finest` - - :client-log-level :warning - -## :log-syntax-error-style - -figwheel.main logging prints out compile time syntax errors which -includes displaying the erroneous code. -Setting `:log-syntax-error-style` to `:concise` will cause the logging to -not display the erroneous code. -Available options: `:verbose`, `:concise` -Default: `:verbose` - - :log-syntax-error-style :concise - -## :load-warninged-code - -If there are warnings in your code emitted from the compiler, figwheel -does not refresh. If you would like Figwheel to load code even if -there are warnings generated set this to true. -Default: false - - :load-warninged-code true - -## :ansi-color-output - -Figwheel makes an effort to provide colorful text output. If you need -to prevent ANSI color codes in figwheel output set `:ansi-color-output` -to false. Default: true - - :ansi-color-output false - -## :validate-config - -Whether to validate the figwheel-main.edn and build config (i.e.".cljs.edn") files. -Default: true - - :validate-config false - -## :validate-cli - -Whether to validate the figwheel-main command line options -Default: true - - :validate-cli false - -## :target-dir - -A String that specifies the target directory component of the path -where figwheel.main outputs compiled ClojureScript - -The default `:output-dir` is composed of: - - [[:target-dir]]/public/cljs-out/[[build-id]] - -The default `:output-to` is composed of: - - [[:target-dir]]/public/cljs-out/[[build-id]]-main.js - -If you are using the default figwheel.repl server to serve compiled -assets, it is very important that the :target-dir be on the classpath. - -The default value of `:target-dir` is "target" - - :target-dir "cljs-target" - -## :launch-node - -A boolean that indicates wether you want figwheel to automatically -launch Node. Defaults to true. - -## :inspect-node - -A boolean that indicates wether you want figwheel to enable remote -inspection by adding "--inspect" when it launches Node. -Defaults to true. - -## :node-command - -A String indicating the Node.js executable to launch Node with. -Defaults to "node" - -## :cljs-devtools - -A boolean that indicates wether to include binaryage/devtools into -the your clojurescript build. Defaults to true when the target is a -browser and the :optimizations level is :none, otherwise it is false. - - :cljs-devtools false - -# Rarely used options - -## :client-print-to - -The `figwheel.repl` client can direct printed (via pr) output to the -repl and or the console. `:client-print-to` is a list of where you -want print output directed. The output choices are `:console` and `:repl` -Default: [:console :repl] - - :client-print-to [:console] - -## :ring-stack - -The fighweel server has a notion of a `:ring-stack`. The -`:ring-stack` is a composition of basic ring-middleware (think -sessions) to wrap around a supplied `:ring-handler`. - -The default `:ring-stack` is a slightly modified -`ring.middleware.defaults/wrap-defaults` - -## :ring-stack-options - -The fighweel.repl server has a notion of a `:ring-stack`. The -`:ring-stack` is a composition of basic ring-middleware to wrap around -a supplied `:ring-handler`. - -The default `:ring-stack` is a slightly modified -ring.middleware.defaults/wrap-defaults. - -`:ring-stack-options` are the options that figwheel.repl supplies to -`ring.middleware.defaults/wrap-defaults`. - -The default options are slightly modified from `ring.middleware.defaults/site-defaults`: - -``` -{:params - {:urlencoded true, :multipart true, :nested true, :keywordize true}, - :cookies true, - :session - {:flash true, :cookie-attrs {:http-only true, :same-site :strict}}, - :static {:resources "public"}, - :responses {:content-types true, :default-charset "utf-8"}, - :figwheel.server.ring/dev - {:figwheel.server.ring/fix-index-mime-type true, - :figwheel.server.ring/resource-root-index true, - :figwheel.server.ring/wrap-no-cache true, - :ring.middleware.not-modified/wrap-not-modified true, - :co.deps.ring-etag-middleware/wrap-file-etag true, - :ring.middleware.cors/wrap-cors true, - :ring.middleware.stacktrace/wrap-stacktrace true}} -``` - -You can override these options by suppling your own to `:ring-stack-options` - -If these options are changed significantly don't be suprised if the -figwheel stops behaving correctly :) - -## :wait-time-ms - -The number of milliseconds to wait before issuing reloads. Set this -higher to wait longer for changes. This is the interval from when the first -file change occurs until we finally issue a reload event. - -Default: 50 - - :wait-time-ms 50 - -## :mode - -The `:mode` indicates the behavior that occurs after a compile. -Options: `:repl` `:serve` or `:build-once` - -* `:repl` indicates that repl sill be started -* `:serve` indicates that a server will be started -* `:build-once` indicates that a compile will not be follwed by any action - -This is mainly intended for use when you are launching figwheel.main from a script. - -Normally defaults to `:repl` - -## :broadcast-reload - -Figwheel broadcasts hot reloads to all clients that have connected -since the figwheel process has started. Set `:broadcast-reload` to -`false` if you want to only send hot-reloads to the client where the -REPL eval occurs. -Default: true - - :broadast-reload false - -## :broadcast - -In the past figwheel would broadcast REPL evaluations to all -connected clients and then print the first result received in the -REPL. Setting `:broadcast` to `true` will give you back this legacy -behavior. Default: false - - :broadcast true - -## :repl-eval-timeout - -The time (in milliseconds) it takes for the repl to timeout. -Evaluating any given expression in cljs can take some time. -The repl is configured to throw a timeout exception as to not hang forever. - -This config option will determine how long the repl waits for the result of an eval -before throwing. - -Default: 8000 - - :repl-eval-timeout 10000 ;;waits for 10 seconds instead of 8 - -## :hawk-options - -If you need to watch files with polling instead of FS events. This can -be useful for certain docker environments. - - :hawk-options {:watcher :polling} \ No newline at end of file diff --git a/figwheel-main/helper-content/creating_a_build_cli_tools.md b/figwheel-main/helper-content/creating_a_build_cli_tools.md deleted file mode 100644 index 1d34c7c3..00000000 --- a/figwheel-main/helper-content/creating_a_build_cli_tools.md +++ /dev/null @@ -1,145 +0,0 @@ -# Setting up a Figwheel build - -If you are ready to start working on a project with Figwheel Main then -it will be most helpful to set up a **build**. - -> A **build** is the configuration of a compile task, that determines -> what files get compiled with a certain set of compile options. A -> build also optionally configures the which features Figwheel -> enguages while you are working on your application. - -#### deps.edn - -First off, it is assumed that if you made it this far you already have -a `deps.edn` file in the directory that you launched this REPL from. - -If don't have a `deps.edn` file let's create one now: - -```clojure -{:deps {com.bhauman/figwheel-main {:mvn/version "0.1.3"} - ;; add rebel-readline for advanced REPL readline editing - com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}} - :paths ["src" "target" "resources"]} -``` - -#### dev.cljs.edn - -Next you will need to create a minimal **build** configuration. We will -create a configuration file for a build named `dev`. - -In `dev.cljs.edn`: - -```clojure -{:main hello.core} -``` - -At the very least you will need to define the entry point to your -build, i.e. the top level namespace for your build. - -There are many other -[compile options](https://clojurescript.org/reference/compiler-options) -that you can configure in this file. For most cases however all you -will need is the above. - -### src/hello/core.cljs - -Next let's create an initial ClojureScript file for our project. - -In `src/hello/core.cljs` put: - -```clojure -(ns hello.core) - -(enable-console-print!) - -(defn hello [] "hello There") - -;; uncomment this to alter the provided "app" DOM element -;; (set! (.-innerHTML (js/document.getElementById "app") (hello))) - -(println (hello)) -``` - -### resources/public/index.html (optional) - -The `resources/public/index.html` file is optional because Figwheel -provides a default one (much like the page you are looking at now) and -you can get pretty far overriding the html element `
`. - -```html - -``` - -To get started, place the following HTML code at `resources/public/index.html`: - -```html - - -
- - -
-