Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[incremental-dom] - Add incremental dom #361

Merged
merged 3 commits into from Jan 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions 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.
47 changes: 47 additions & 0 deletions 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"})))
1 change: 1 addition & 0 deletions incremental-dom/resources/deps.cljs
@@ -0,0 +1 @@
{:libs ["cljsjs/incremental-dom/development"]}
24 changes: 24 additions & 0 deletions 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);