Browse Source

Add incremental-dom (idom) based closure-templates (soy) support

Andy Hochhaus 2 years ago
parent
commit
537242002e
3 changed files with 45 additions and 1 deletions
  1. 2 0
      README.md
  2. 18 0
      closure-templates.patch
  3. 25 1
      deps.sh

+ 2 - 0
README.md

@@ -35,6 +35,8 @@ supported.
   * [closure-compiler](https://github.com/google/closure-compiler/)
   * [closure-templates](https://github.com/google/closure-templates/)
   * [closure-stylesheets](https://github.com/google/closure-stylesheets/)
+  * [incremental-dom](https://github.com/google/incremental-dom)
+  * [clang](http://clang.llvm.org/) (for JavaScript linting only)
 * [Go 1.5.3+](http://golang.org/) (golang)
 * [lib/pq](https://github.com/lib/pq)
 * [go-imap](https://github.com/mxk/go-imap)

+ 18 - 0
closure-templates.patch

@@ -0,0 +1,18 @@
+diff --git a/java/src/com/google/template/soy/SoyToJsSrcCompiler.java b/java/src/com/google/template/soy/SoyToJsSrcCompiler.java
+index b013b6c..d1f0bb5 100644
+--- a/java/src/com/google/template/soy/SoyToJsSrcCompiler.java
++++ b/java/src/com/google/template/soy/SoyToJsSrcCompiler.java
+@@ -282,7 +282,12 @@ public final class SoyToJsSrcCompiler {
+       sfs.compileToJsSrcFiles(
+           outputPathFormat, inputPrefix, jsSrcOptions, locales, messageFilePathFormat);
+     } else {
+-      sfs.compileToJsSrcFiles(outputPathFormat, inputPrefix, jsSrcOptions, locales, null);
++        jsSrcOptions.setShouldDeclareTopLevelNamespaces(false);
++        jsSrcOptions.setShouldProvideRequireSoyNamespaces(false);
++        jsSrcOptions.setShouldProvideRequireJsFunctions(false);
++        jsSrcOptions.setShouldProvideBothSoyNamespacesAndJsFunctions(false);
++        jsSrcOptions.setShouldGenerateGoogModules(true);
++        sfs.compileToIncrementalDomSrcFiles(outputPathFormat, jsSrcOptions);
+     }
+   }
+ }

+ 25 - 1
deps.sh

@@ -42,13 +42,14 @@ if [ ! -f closure-stylesheets.jar ]; then
 fi
 
 # TODO(hochhaus): Use pre-compiled linter.jar if/when upload packages it.
+# https://github.com/google/closure-compiler/issues/1401
 # https://groups.google.com/forum/#!topic/closure-compiler-discuss/KrWtaKItdog
 if [ ! -f linter.jar ]; then
   git clone https://github.com/google/closure-compiler.git
   cd closure-compiler
   ant linter
+  cp build/linter.jar ..
   cd ..
-  cp closure-compiler/build/linter.jar .
 fi
 if [ ! -d clang ]; then
   CLANG_VERSION="3.7.1"
@@ -58,5 +59,28 @@ if [ ! -d clang ]; then
   mv clang+llvm-${CLANG_VERSION}-x86_64-linux-gnu-debian8 clang
 fi
 
+# TODO(hochhaus): Use pre-compiled SoyToIncrementalDomSrcCompiler.java when it
+# is packaged upstream.
+# https://groups.google.com/forum/#!topic/closure-templates-discuss/8p6JIdaWWj0
+if [ ! -f SoyToIncrementalDomSrcCompiler.jar ]; then
+  git clone https://github.com/google/closure-templates.git
+  cd closure-templates
+  patch -p1 < ../../closure-templates.patch
+  mvn package
+  cp target/soy-*-SoyToJsSrcCompiler.jar ../SoyToIncrementalDomSrcCompiler.jar
+  cd ..
+fi
+
+if [ ! -f incremental-dom-closure.js ]; then
+  git clone https://github.com/google/incremental-dom.git
+  cd incremental-dom
+  npm install gulp gulp-babel del rollup gulp-file gulp-gjslint gulp-util \
+      karma gulp-replace vinyl-source-stream gulp-sourcemaps gulp-uglify
+  npm i
+  gulp js-closure
+  cp dist/incremental-dom-closure.js ..
+  cd ..
+fi
+
 set +x
 echo "Success"