Git Product home page Git Product logo

shadow-build's Introduction

shadow-build

A ClojureScript build library capable of compiling multiple output files. It is basically a rewrite of cljs.closure since it assumes to only ever produce one output file.

Its a lot more flexible than cljs.closure which also means its a little more complex to use.

Closure Modules

Modules allow the compiler to optimize the dependencies of your code for you. Usually (in jQuery-Land) you have to include all necessary javascript files (jquery.plugin-a.js, jquery.plugin-b.js, ...) on every page that needs it. This usually ends in loading all files all the time cause who knows whats needed and what not. With modules you'd group common functionality into a API namespace which serves as an entry point for the module. They are not like usual JavaScript modules though (RequireJS, AMD, ...), although they are similar except that they export names in their own which you cannot bind yourself.

If you have big chunks of code in your app that are only required in certain circumstances (eg. only when the user is logged in, only for the shop checkout process, only for admins, only on Tuesdays, ...) you'd create feature module "checkout" and a (ns my-app.checkout) main as its entry point. In your HTML include the checkout module and you are done. If the checkout now starts using fancy new library it will be managed on the (ns my-app.checkout (:require)) side of things, no need to touch the HTML or build scripts.

Usage

Right now this really only is a library and not a tool like lein-cljsbuild. But Leiningen provides enough hooks to make integration easy, assuming you are using Leiningen of course.

Step 1: Include the necessary options in your project.clj

:profiles {:dev {:source-paths ["dev"]
                 :dependencies [[org.clojure/clojurescript "0.0-2322"]
                                [thheller/shadow-build "0.9.4"]]}}

I recommend putting it into the :dev profile since you usually don't need it in production. You'll also need to provide ClojureScript itself. Currently the minimum required version is 0.0-2127 (avoid releases 2197-2263).

Step 2: Create a build script.

See: https://github.com/thheller/shadow-build/blob/master/dev/build.clj

Needs more docs ....

Step 3: Run it using Leiningen

lein run -m build/dev or lein run -m build/production

Create as many different builds as you like, they are just a function call away. Its also possible to compile multiple independent outputs in one go, see build/separate

License

Copyright © 2014 Thomas Heller

Distributed under the Eclipse Public License, the same as Clojure.

shadow-build's People

Contributors

krisajenkins avatar

Watchers

James Cloos avatar Maverick Bozo avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.