All Projects → thheller → Shadow Cljs

thheller / Shadow Cljs

Licence: epl-1.0
ClojureScript compilation made easy

Programming Languages

clojure
4091 projects
javascript
184084 projects - #8 most used programming language
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Shadow Cljs

Rcrl
Read-Compile-Run-Loop: tiny and powerful interactive C++ compiler (REPL)
Stars: ✭ 332 (-81.29%)
Mutual labels:  repl, hot-reload
Flexlib
FlexLib是一个基于flexbox模型,使用xml文件进行界面布局的框架,融合了web快速布局的能力,让iOS界面开发像写网页一样简单快速
Stars: ✭ 1,569 (-11.56%)
Mutual labels:  hot-reload
Scalakata2
Interactive Playground
Stars: ✭ 99 (-94.42%)
Mutual labels:  repl
Sass Vars Loader
Use Sass variables defined in Webpack config or in external Javascript or JSON files
Stars: ✭ 112 (-93.69%)
Mutual labels:  hot-reload
Repl
REPL rewrite for Node.js ✨🐢🚀✨
Stars: ✭ 101 (-94.31%)
Mutual labels:  repl
Universal React Redux
🧐 A sensible universal starter kit for React + Redux
Stars: ✭ 112 (-93.69%)
Mutual labels:  hot-reload
Ns Tracker
Library to keep track of changes to Clojure source files
Stars: ✭ 95 (-94.64%)
Mutual labels:  repl
Lips
Scheme based powerful lisp interpreter written in JavaScript
Stars: ✭ 120 (-93.24%)
Mutual labels:  repl
Hotreloading
Hot reloading as a Swift Package
Stars: ✭ 116 (-93.46%)
Mutual labels:  hot-reload
Node Hot Loader
Hot module replacement (hot reload) for Node.js applications. Develop without server restarting.
Stars: ✭ 111 (-93.74%)
Mutual labels:  hot-reload
Cl Repl
A full-featured repl implementation designed to work with Roswell
Stars: ✭ 106 (-94.02%)
Mutual labels:  repl
Next Express Bootstrap Boilerplate
⚡️ JavaScript boilerplate for a full stack app built using React.js, Next.js, Express.js, react-bootstrap, SCSS and full SSR with eslint.
Stars: ✭ 102 (-94.25%)
Mutual labels:  hot-reload
Nodebook
Nodebook - Multi-Lang Web REPL + CLI Code runner
Stars: ✭ 1,521 (-14.26%)
Mutual labels:  repl
Babel Plugin Functional Hmr
Babel plugin enables HMR for functional components in React Native.
Stars: ✭ 100 (-94.36%)
Mutual labels:  hot-reload
N
Node.js REPL with lodash
Stars: ✭ 118 (-93.35%)
Mutual labels:  repl
Almond
A Scala kernel for Jupyter
Stars: ✭ 1,354 (-23.68%)
Mutual labels:  repl
Endbasic
BASIC environment with a REPL, a web interface, and RPi support written in Rust
Stars: ✭ 106 (-94.02%)
Mutual labels:  repl
Brain
An esoteric programming language compiler on top of LLVM based on Brainfuck
Stars: ✭ 112 (-93.69%)
Mutual labels:  repl
Reactly Starter Kit
Deployable React + Webpack 2 starter kit
Stars: ✭ 122 (-93.12%)
Mutual labels:  hot-reload
Bull Repl
Bull / BullMQ queue command line REPL
Stars: ✭ 121 (-93.18%)
Mutual labels:  repl

shadow-cljs provides everything you need to compile your ClojureScript code with a focus on simplicity and ease of use.

npm Clojars Project

Features

  • Good configuration defaults so you don't have to sweat the details
  • Seamless npm integration
  • Fast builds, reliable caching, ...
  • Supporting various targets :browser, :node-script, :npm-module, :react-native, :chrome-extension, ...
  • Live Reload (CLJS + CSS)
  • CLJS REPL
  • Code splitting (via :modules)

overview-img

Requirements

  • node.js (v6.0.0+, most recent version preferred)
  • npm (comes bundled with node.js) or yarn
  • Java SDK (Version 8+, Hotspot)

Quick Start

Creating your project can be done quickly using the npx create-cljs-project utility. npx is part of npm and lets us run utility scripts quickly without worrying about installing them first. The installer will create a basic project scaffold and install the latest version of shadow-cljs in the project.

$ npx create-cljs-project acme-app
npx: installed 1 in 5.887s
shadow-cljs - creating project: .../acme-app
Creating: .../acme-app/package.json
Creating: .../acme-app/shadow-cljs.edn
Creating: .../acme-app/.gitignore
Creating: .../acme-app/src/main
Creating: .../acme-app/src/test
----
Installing shadow-cljs in project.

npm notice created a lockfile as package-lock.json. You should commit this file.
+ shadow-cljs@<version>
added 88 packages from 103 contributors and audited 636 packages in 6.287s
found 0 vulnerabilities

----
Done.
----

The resulting project has the following structure

.
├── node_modules (omitted ...)
├── package.json
├── package-lock.json
├── shadow-cljs.edn
└── src
    ├── main
    └── test

shadow-cljs.edn will be used to configure your CLJS builds and CLJS dependencies. package.json is used by npm to manage JS dependencies.

Everything is ready to go if you just want to start playing with a REPL

$ npx shadow-cljs node-repl
# or
$ npx shadow-cljs browser-repl

When building actual projects we need to configure the build first and create at least one source file.

The default source paths are configured to use src/main as the primary source directory. It is recommended to follow the Java Naming Conventions to organize your CLJS namespaces. It is recommended to start all namespaces with a unique enough prefix (eg. company name, project name) to avoid conflicts with generic names such as app.core. Suppose you were building a Web Frontend for Acme Inc. using acme.frontend.app might be a good starting point as it can easily grow to include acme.backend.* later on.

Using the above example the expected filename for acme.frontend.app is src/main/acme/frontend/app.cljs.

Lets start with a simple example for a browser-based build.

(ns acme.frontend.app)

(defn init []
  (println "Hello World"))

Inside the shadow-cljs.edn :builds section add

{...
 :builds
 {:frontend
  {:target :browser
   :modules {:main {:init-fn acme.frontend.app/init}}
   }}}

This config tells the compiler to call (acme.frontend.app/init) when the generated JS code is loaded. Since no :output-dir is configured the default public/js is used. You can start the development process by running:

$ npx shadow-cljs watch frontend
...
a few moments later ...
...
[:frontend] Build completed. (134 files, 35 compiled, 0 warnings, 5.80s)

The compilation will create the public/js/main.js we configured above (:main becomes main.js in the :output-dir). Since we want to load this in the browser we need to create a HTML file in public/index.html.

<!doctype html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>acme frontend</title>
  </head>
  <body>
    <div id="root"></div>
    <script src="/js/main.js"></script>
  </body>
</html>

We also need a simple HTTP server to serve our HTML since modern Browsers all place a few restrictions on files loaded directly from disk which will lead to issues later. shadow-cljs provides such a server but you can use anything you like at this point. It only matters that the files from the public directory are served properly. To start the built-in web server just adjust the build config from above.

{...
 :dev-http {8080 "public"}
 :builds
 {:frontend
  {:target :browser
   :modules {:main {:init-fn acme.frontend.app/init}}
   }}}

Once the config is saved the server will automatically start and serve the content at http://localhost:8080. There is no need to restart shadow-cljs. When opening the above URL the Browser Console should show "Hello World".

To be continued ...

Documentation

Please refer to the User Manual. (Work in Progress)

Video Courses

Guides

Examples

Libraries

  • flexsurfer/rn-shadow-steroid - React Native with shadow-cljs on steroids
  • re-frame-flow - A graph based visualization tool for re-frame event chains using shadow-cljs
  • ... please let me know if you created something to include here

License

Copyright © 2020 Thomas Heller

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].