diff --git a/incremental-dom/README.md b/incremental-dom/README.md new file mode 100644 index 000000000..8d249fc20 --- /dev/null +++ b/incremental-dom/README.md @@ -0,0 +1,19 @@ +# cljsjs/incremental-dom + +[](dependency) +```clojure +[cljsjs/incremental-dom "0.3"] ;; latest release +``` +[](/dependency) + +This jar comes with `deps.cljs` providing incremental-dom **as a Closure library**, which means it can undergo all the closure-compiler optimisations. + +This means requiring it is done in a similar fashion to requiring parts of the Closure library itself: + +```clojure +(ns application.core + (:require [goog.dom :as dom] ; Closure + [incremental-dom :as inc])) ; Incremental Dom +``` + +Currently, incremental-dom produces a few warnings on compilation. Some of these are resolved by setting the `:language-in` option to `:ecmascript5` in your cljsbuild configuration, but some seem to be to do with Babel stripping some parentheses from the ES2015 code. diff --git a/incremental-dom/build.boot b/incremental-dom/build.boot new file mode 100644 index 000000000..5558c0768 --- /dev/null +++ b/incremental-dom/build.boot @@ -0,0 +1,47 @@ +(set-env! + :resource-paths #{"resources"} + :dependencies '[[cljsjs/boot-cljsjs "0.5.0" :scope "test"]]) + +(require + '[cljsjs.boot-cljsjs.packaging :refer :all] + '[boot.core :as boot] + '[boot.tmpdir :as tmpd] + '[clojure.java.io :as io] + '[boot.util :refer [sh]]) + +(def +version+ "0.3") + +(task-options! + pom {:project 'cljsjs/incremental-dom + :version +version+ + :description "Dom-building library from google" + :url "http://github.com/google/incremental-dom" + :scm {:url "https://github.com/cljsjs/packages"} + :license {"Apache 2.0" "http://opensource.org/licenses/Apache-2.0"}}) + +(deftask build-incremental-dom [] + (let [tmp (boot/tmp-dir!)] + (with-pre-wrap + fileset + ;; Copy all files in fileset to temp directory + (doseq [f (->> fileset boot/input-files) + :let [target (io/file tmp (tmpd/path f))]] + (io/make-parents target) + (io/copy (tmpd/file f) target)) + + (binding [boot.util/*sh-dir* (str (io/file tmp (format "incremental-dom-%s" +version+)))] + ((sh "npm" "install")) + ((sh "patch" "gulpfile.js" "../gulpfile.js.patch" "-o" "patched-gulpfile.js")) + ((sh "./node_modules/.bin/gulp" "--gulpfile=patched-gulpfile.js" "js-closure-provides"))) + (-> fileset (boot/add-resource tmp) boot/commit!)))) + + +(deftask package [] + (comp + (download :url (format "https://github.com/google/incremental-dom/archive/%s.zip" +version+) + :checksum "170A1C354379FF2AF3A08455BFB0AD9D" + :unzip true) + (build-incremental-dom) + (sift :move {#"^incremental-dom-(.*)/dist/incremental-dom-closure-provides.js" + "cljsjs/incremental-dom/development/incremental-dom.js"}) + (sift :include #{#"^cljsjs/" #"deps.cljs"}))) diff --git a/incremental-dom/resources/deps.cljs b/incremental-dom/resources/deps.cljs new file mode 100644 index 000000000..f2eb09660 --- /dev/null +++ b/incremental-dom/resources/deps.cljs @@ -0,0 +1 @@ +{:libs ["cljsjs/incremental-dom/development"]} diff --git a/incremental-dom/resources/gulpfile.js.patch b/incremental-dom/resources/gulpfile.js.patch new file mode 100644 index 000000000..1626892d5 --- /dev/null +++ b/incremental-dom/resources/gulpfile.js.patch @@ -0,0 +1,24 @@ +34a35 +> var googNamespace = 'incremental_dom'; +146a148,166 +> function jsClosureProvides(done) { +> return bundle('cjs').then(function(gen) { +> var moduleDeclaration = 'goog.provide(\'' + googNamespace + '\');'; +> var code = moduleDeclaration + '\n' +> + 'goog.scope(function(){\n' +> + 'var exports = ' + googNamespace + ';' +> + gen.code.replace(/'use strict';/, '') +> + '\n});'; +> +> return file(artifactName + '-closure-provides.js', code, {src: true}) +> .pipe(sourcemaps.init({loadMaps: true})) +> .pipe(replace('process.env.NODE_ENV !== \'production\'', 'goog.DEBUG')) +> .pipe(babel()) +> .pipe(sourcemaps.write('./')) +> .pipe(gulp.dest('dist')); +> }); +> } +> +> +177a198 +> gulp.task('js-closure-provides', jsClosureProvides);