Code Monkey home page Code Monkey logo

meteor-clojurescript's Introduction

Meteor Clojurescript

Clojurescript is a Clojure to JS compiler

Meteor-Clojurescript is a Meteor package which allows you to use clojurescript in your Meteor projects.

Installation

Meteor-Clojurescript requires leiningen to be installed and on your path.

From Atmosphere

mrt add clojurescript

From Github

mkdir packages
git clone https://github.com/mystor/meteor-clojurescript packages/clojurescript
meteor add clojurescript

Usage

Place a project.clj at the root of your project. It should look something like this:

(defproject my-project-name "0.0.1"
  :dependencies [[org.clojure/clojurescript "0.0-2173"]]
  :plugins [[lein-cljsbuild "1.0.1"]]
  :cljsbuild {
    :builds {
      :client
      {:source-paths ["client"] ; The directories to include on the client
       :compiler {:output-to "bin/client.cjs" ; Path must contain 'client' and have extension 'cjs'
                  :output-dir "bin/.build/client" ; Must be a folder ignored by Meteor
                  :source-map "bin/client.cjs.map" ; Must be the :output-to path, with an added '.map'
                  :optimizations :simple ; Use :whitespace, :simple, or :advanced
                  :pretty-print true}}
      :server
      {:source-paths ["server"] ; The directories to include on ths server
       :compiler {:output-to "bin/server.cjs" ; Path must contain 'server' and have extension 'cjs'
                  :output-dir "bin/.build/server" ; Must be a folder ignored by Meteor
                  :source-map "bin/server.cjs.map" ; Must be the :output-to path, with an added '.map'
                  :optimizations :simple ; Use :simple, or :advanced
                  :target :nodejs ; Necessary
                  :pretty-print true}}}})

Meteor Clojurescript runs the equivalent of lein cljsbuild auto when you run Meteor, and then transforms the .cjs files, adding them to the Meteor asset pipeline.

If you change your project.clj file, it may not register your changes immediately. You can call lein cljsbuild clean to clean leiningen's output files, forcing a full recompile.

Limitations

Advanced Compilation

Advanced compilation is supported by Clojurescript, through the use of Google's Closure compiler. Unfortunately, nobody (as far as I know) has written an externs file for Meteor, which means that all calls to the core libraries will be munged. Because of this, :advanced compilation is not currently recommended.

Minimum Compilation levels

Meteor-Clojurescript will not concatinate output files for you, so the compiler has to have already done it. Thus, the :none optimization level is not supported.

In addition, the :nodejs target does not currently work correctly with :whitespace or :none, so :simple is recommended on the server.

Meteor Packages

Clojurescript is non-ideal for Meteor package development, and thus no effort has been made to make such development easy, or even possible, with Meteor Clojurescript.

Clojurescript produces a large amount of boilerplate, and it would be inefficient to duplicate it across multiple packages. In addition, pre-compiled clojurescript code doesn't interop as well with other clojurescript code.

For clojurescript package development, I recommend using the standard clojurescript packaging system, with leiningen, rather than using Meteor's packages.

meteor-clojurescript's People

Contributors

mystor avatar

Watchers

Xiyang Chen avatar James Cloos 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.