Node.js example with ClojureScript with shadow-cljs

Develop

Install all dependencies.

npm run install

Watch compile with with hot reloading, using the browser target as example.

npm run watch:browser

The above command will also start a server at port 5000 so that you can open http://localhost:5000 and load the website.

Production release

Build production builds for each target.

# Build all targets
npm run release
# or
npm run release:app
npm run release:library
npm run release:browser

Browser

# Build the JS bundle
npm run release:browser

# Serve the demo at http://localhost:5000
npm run start:browser

This will generate a file inside build/browser/browser-main.js, and use it from the generated build/browser/index.html which loads the script.

The browser-main.js file contains your JavaScript logic, so copy that into your server and load it into your main website HTML. See the provided src/_build_hooks/index.html as an example.

Node application

npm run release:app

Compiles the Node app, :app target, to build/node-app.js.

You can run your app/script by running node build/node-app.js.

Library

Apart from the main Node script/app generated, we can also generate a library in the standard commonjs format that can be used in other Node/JavaScript projects, or as a handler in AWS Lambda.

npm run release:library

You can test the library generated by running the default AWS Lambda handler provided:

node -e 'require("./build/lib.js").handler({"a": 10}, null, (_, result) => console.log(JSON.stringify(result)))'

REPL

Start a REPL connected to current running program, app for the :build-id:

npx shadow-cljs cljs-repl app

License

MIT