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.
35 35
   * [closure-compiler](https://github.com/google/closure-compiler/)
36 36
   * [closure-templates](https://github.com/google/closure-templates/)
37 37
   * [closure-stylesheets](https://github.com/google/closure-stylesheets/)
38
+  * [incremental-dom](https://github.com/google/incremental-dom)
39
+  * [clang](http://clang.llvm.org/) (for JavaScript linting only)
38 40
 * [Go 1.5.3+](http://golang.org/) (golang)
39 41
 * [lib/pq](https://github.com/lib/pq)
40 42
 * [go-imap](https://github.com/mxk/go-imap)

+ 18 - 0
closure-templates.patch

@@ -0,0 +1,18 @@
1
+diff --git a/java/src/com/google/template/soy/SoyToJsSrcCompiler.java b/java/src/com/google/template/soy/SoyToJsSrcCompiler.java
2
+index b013b6c..d1f0bb5 100644
3
+--- a/java/src/com/google/template/soy/SoyToJsSrcCompiler.java
4
++++ b/java/src/com/google/template/soy/SoyToJsSrcCompiler.java
5
+@@ -282,7 +282,12 @@ public final class SoyToJsSrcCompiler {
6
+       sfs.compileToJsSrcFiles(
7
+           outputPathFormat, inputPrefix, jsSrcOptions, locales, messageFilePathFormat);
8
+     } else {
9
+-      sfs.compileToJsSrcFiles(outputPathFormat, inputPrefix, jsSrcOptions, locales, null);
10
++        jsSrcOptions.setShouldDeclareTopLevelNamespaces(false);
11
++        jsSrcOptions.setShouldProvideRequireSoyNamespaces(false);
12
++        jsSrcOptions.setShouldProvideRequireJsFunctions(false);
13
++        jsSrcOptions.setShouldProvideBothSoyNamespacesAndJsFunctions(false);
14
++        jsSrcOptions.setShouldGenerateGoogModules(true);
15
++        sfs.compileToIncrementalDomSrcFiles(outputPathFormat, jsSrcOptions);
16
+     }
17
+   }
18
+ }

+ 25 - 1
deps.sh

@@ -42,13 +42,14 @@ if [ ! -f closure-stylesheets.jar ]; then
42 42
 fi
43 43
 
44 44
 # TODO(hochhaus): Use pre-compiled linter.jar if/when upload packages it.
45
+# https://github.com/google/closure-compiler/issues/1401
45 46
 # https://groups.google.com/forum/#!topic/closure-compiler-discuss/KrWtaKItdog
46 47
 if [ ! -f linter.jar ]; then
47 48
   git clone https://github.com/google/closure-compiler.git
48 49
   cd closure-compiler
49 50
   ant linter
51
+  cp build/linter.jar ..
50 52
   cd ..
51
-  cp closure-compiler/build/linter.jar .
52 53
 fi
53 54
 if [ ! -d clang ]; then
54 55
   CLANG_VERSION="3.7.1"
@@ -58,5 +59,28 @@ if [ ! -d clang ]; then
58 59
   mv clang+llvm-${CLANG_VERSION}-x86_64-linux-gnu-debian8 clang
59 60
 fi
60 61
 
62
+# TODO(hochhaus): Use pre-compiled SoyToIncrementalDomSrcCompiler.java when it
63
+# is packaged upstream.
64
+# https://groups.google.com/forum/#!topic/closure-templates-discuss/8p6JIdaWWj0
65
+if [ ! -f SoyToIncrementalDomSrcCompiler.jar ]; then
66
+  git clone https://github.com/google/closure-templates.git
67
+  cd closure-templates
68
+  patch -p1 < ../../closure-templates.patch
69
+  mvn package
70
+  cp target/soy-*-SoyToJsSrcCompiler.jar ../SoyToIncrementalDomSrcCompiler.jar
71
+  cd ..
72
+fi
73
+
74
+if [ ! -f incremental-dom-closure.js ]; then
75
+  git clone https://github.com/google/incremental-dom.git
76
+  cd incremental-dom
77
+  npm install gulp gulp-babel del rollup gulp-file gulp-gjslint gulp-util \
78
+      karma gulp-replace vinyl-source-stream gulp-sourcemaps gulp-uglify
79
+  npm i
80
+  gulp js-closure
81
+  cp dist/incremental-dom-closure.js ..
82
+  cd ..
83
+fi
84
+
61 85
 set +x
62 86
 echo "Success"