From 8c4d59b338e351618031e0a4d95404e1984009bc Mon Sep 17 00:00:00 2001 From: Alex Chythlook Date: Fri, 20 Apr 2018 13:48:17 -0800 Subject: [PATCH 1/9] Add intellij stuff to .gitignore --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index c53038e..7784934 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,8 @@ pom.xml.asc /.nrepl-port .hgignore .hg/ +/.idea/ +*.idea +.idea +*.iml +.iml \ No newline at end of file From 841a70f7f2a5dbf884d6c4727eaac54fcd0ec117 Mon Sep 17 00:00:00 2001 From: Alex Chythlook Date: Fri, 20 Apr 2018 16:35:48 -0800 Subject: [PATCH 2/9] Add provincial support for sw and push to clojars. --- project.clj | 7 ++++--- src/duct/module/cljs.clj | 42 +++++++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/project.clj b/project.clj index f6ea0f5..ad41f78 100644 --- a/project.clj +++ b/project.clj @@ -1,12 +1,13 @@ -(defproject duct/module.cljs "0.3.2" +(defproject zaphodious/module.cljs "0.4.0-SNAPSHOT" :description "Duct module for developing and compiling ClojureScript" :url "https://github.com/duct-framework/module.cljs" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} - :dependencies [[org.clojure/clojure "1.9.0-RC2"] - [org.clojure/clojurescript "1.9.946"] + :dependencies [[org.clojure/clojure "1.9.0"] + [org.clojure/clojurescript "1.10.238"] [binaryage/devtools "0.9.7"] [duct/core "0.6.1"] + [hireling "0.6.0-ALPHA-SNAPSHOT"] [duct/compiler.cljs "0.2.0"] [duct/server.figwheel "0.2.1"] [integrant "0.6.1"]]) diff --git a/src/duct/module/cljs.clj b/src/duct/module/cljs.clj index 438b040..a81faf1 100644 --- a/src/duct/module/cljs.clj +++ b/src/duct/module/cljs.clj @@ -18,10 +18,23 @@ (defn- target-public-path [config options] (str core/target-path "/resources/" (project-dirs config options) "/public")) -(defn- compiler-config [path main] +(defn- compiler-config [path main sw-main] {:duct.compiler/cljs {:builds ^:displace - [{:source-paths ["src"] + [(when sw-main + {:id "sw" + :source-paths ["src"] + :build-options + {:main sw-main + :output-to (src path "/sw.js") + :output-dir (src path "/sw") + :asset-path "/sw" + :closure-defines {'goog.DEBUG false} + :verbose true + :infer-externs true + :optimizations :advanced + :target :webworker}}) + {:source-paths ["src"] :build-options {:main main :output-to (str path "/js/main.js") @@ -31,13 +44,27 @@ :verbose true :optimizations :advanced}}]}}) -(defn- figwheel-config [path main] +(defn- figwheel-config [path main sw-main] {:duct.server/figwheel {:css-dirs ^:displace ["resources" "dev/resources"] :builds ^:displace - [{:id "dev" + [{:id "sw-dev" + :figwheel false + :source-paths ["dev/src" "src"] + :build-options + {:main sw-main + :output-to (str path "/sw.js") + :output-dir (str path "/sw") + :asset-path "/sw" + :closure-defines {'goog.DEBUG true} + :verbose false + :infer-externs true + :preloads '[devtools.preload] + :optimizations :none + :target :webworker}} + {:id "dev" :figwheel true - :source-paths ["dev/src" "src" ] + :source-paths ["dev/src" "src"] :build-options {:main main :output-to (str path "/js/main.js") @@ -51,7 +78,8 @@ (defmethod ig/init-key :duct.module/cljs [_ options] {:fn (fn [config] (let [path (target-public-path config options) + sw-main (:sw-main options) main (:main options)] (case (get-environment config options) - :production (core/merge-configs config (compiler-config path main)) - :development (core/merge-configs config (figwheel-config path main)))))}) + :production (core/merge-configs config (compiler-config path main sw-main)) + :development (core/merge-configs config (figwheel-config path main sw-main)))))}) From 0ab325d7da55fdcb82461f8205f59f510a9beb26 Mon Sep 17 00:00:00 2001 From: Alex Chythlook Date: Fri, 20 Apr 2018 19:04:25 -0800 Subject: [PATCH 3/9] Finish out support for service workers are prepare for pull request. --- project.clj | 4 ++-- src/duct/module/cljs.clj | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/project.clj b/project.clj index ad41f78..855cb08 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject zaphodious/module.cljs "0.4.0-SNAPSHOT" +(defproject duct/module.cljs "0.4.0" :description "Duct module for developing and compiling ClojureScript" :url "https://github.com/duct-framework/module.cljs" :license {:name "Eclipse Public License" @@ -7,7 +7,7 @@ [org.clojure/clojurescript "1.10.238"] [binaryage/devtools "0.9.7"] [duct/core "0.6.1"] - [hireling "0.6.0-ALPHA-SNAPSHOT"] + [hireling "0.6.0"] [duct/compiler.cljs "0.2.0"] [duct/server.figwheel "0.2.1"] [integrant "0.6.1"]]) diff --git a/src/duct/module/cljs.clj b/src/duct/module/cljs.clj index a81faf1..e6a301b 100644 --- a/src/duct/module/cljs.clj +++ b/src/duct/module/cljs.clj @@ -26,12 +26,14 @@ :source-paths ["src"] :build-options {:main sw-main - :output-to (src path "/sw.js") - :output-dir (src path "/sw") + :output-to (str path "/sw.js") + :output-dir (str path "/sw") :asset-path "/sw" :closure-defines {'goog.DEBUG false} :verbose true :infer-externs true + :language-in :es6 + :rewrite-polyfills true :optimizations :advanced :target :webworker}}) {:source-paths ["src"] @@ -59,6 +61,8 @@ :closure-defines {'goog.DEBUG true} :verbose false :infer-externs true + :language-in :es6 + :rewrite-polyfills true :preloads '[devtools.preload] :optimizations :none :target :webworker}} From f74acd062f56cbd31ccc047e868fb3c7e81f5db5 Mon Sep 17 00:00:00 2001 From: Alex Chythlook Date: Fri, 20 Apr 2018 19:10:19 -0800 Subject: [PATCH 4/9] Realize that literally nothing in this module requires a dependency on hireling. --- project.clj | 1 - 1 file changed, 1 deletion(-) diff --git a/project.clj b/project.clj index 855cb08..31395a0 100644 --- a/project.clj +++ b/project.clj @@ -7,7 +7,6 @@ [org.clojure/clojurescript "1.10.238"] [binaryage/devtools "0.9.7"] [duct/core "0.6.1"] - [hireling "0.6.0"] [duct/compiler.cljs "0.2.0"] [duct/server.figwheel "0.2.1"] [integrant "0.6.1"]]) From 213ffa28a1ebace8fcfd75cff509cca9a1df3824 Mon Sep 17 00:00:00 2001 From: Alex Chythlook Date: Fri, 20 Apr 2018 19:57:17 -0800 Subject: [PATCH 5/9] Add to test case. --- test/duct/module/cljs_test.clj | 37 +++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/test/duct/module/cljs_test.clj b/test/duct/module/cljs_test.clj index 05c9627..bbfab6f 100644 --- a/test/duct/module/cljs_test.clj +++ b/test/duct/module/cljs_test.clj @@ -9,7 +9,8 @@ (def base-config {:duct.core/project-ns 'foo - :duct.module/cljs {:main 'foo.client}}) + :duct.module/cljs {:main 'foo.client + :sw-main 'foo.sw}}) (defn- absolute-path [relative-path] (.getAbsolutePath (io/file relative-path))) @@ -20,7 +21,21 @@ (merge base-config {:duct.compiler/cljs {:builds - [{:source-paths ["src"] + [{:id "sw" + :source-paths ["src"] + :build-options + {:main 'foo.sw + :output-to (absolute-path "target/resources/foo/public/sw.js") + :output-dir (absolute-path "target/resources/foo/public/sw") + :asset-path "/sw" + :closure-defines {'goog.DEBUG false} + :verbose true + :infer-externs true + :language-in :es6 + :rewrite-polyfills true + :optimizations :advanced + :target :webworker}} + {:source-paths ["src"] :build-options {:main 'foo.client :output-to (absolute-path "target/resources/foo/public/js/main.js") @@ -37,7 +52,23 @@ {:duct.server/figwheel {:css-dirs ["resources" "dev/resources"] :builds - [{:id "dev" + [{:id "sw-dev" + :figwheel false + :source-paths ["dev/src" "src"] + :build-options + {:main 'foo.sw + :output-to (absolute-path "target/resources/foo/public/sw.js") + :output-dir (absolute-path "target/resources/foo/public/sw") + :asset-path "/sw" + :closure-defines {'goog.DEBUG true} + :verbose false + :infer-externs true + :language-in :es6 + :rewrite-polyfills true + :preloads '[devtools.preload] + :optimizations :none + :target :webworker}} + {:id "dev" :figwheel true :source-paths ["dev/src" "src"] :build-options From 1560f78034ba7cd600d56bcb6dbf027786fa8966 Mon Sep 17 00:00:00 2001 From: Alex Chythlook Date: Fri, 20 Apr 2018 20:01:45 -0800 Subject: [PATCH 6/9] Add back on test without service worker. --- test/duct/module/cljs_test.clj | 48 +++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/test/duct/module/cljs_test.clj b/test/duct/module/cljs_test.clj index bbfab6f..2b850e4 100644 --- a/test/duct/module/cljs_test.clj +++ b/test/duct/module/cljs_test.clj @@ -7,18 +7,22 @@ (core/load-hierarchy) -(def base-config +(def service-worker-base-config {:duct.core/project-ns 'foo :duct.module/cljs {:main 'foo.client :sw-main 'foo.sw}}) +(def base-config + {:duct.core/project-ns 'foo + :duct.module/cljs {:main 'foo.client}}) + (defn- absolute-path [relative-path] (.getAbsolutePath (io/file relative-path))) -(deftest module-test +(deftest service-worker-module-test (testing "production config" - (is (= (core/prep base-config) - (merge base-config + (is (= (core/prep service-worker-base-config) + (merge service-worker-base-config {:duct.compiler/cljs {:builds [{:id "sw" @@ -80,3 +84,39 @@ :verbose false :preloads ['devtools.preload] :optimizations :none}}]}})))))) + +(deftest module-test + (testing "production config" + (is (= (core/prep base-config) + (merge base-config + {:duct.compiler/cljs + {:builds + [{:source-paths ["src"] + :build-options + {:main 'foo.client + :output-to (absolute-path "target/resources/foo/public/js/main.js") + :output-dir (absolute-path "target/resources/foo/public/js") + :asset-path "/js" + :closure-defines {'goog.DEBUG false} + :verbose true + :optimizations :advanced}}]}})))) + + (testing "development config" + (let [config (assoc base-config ::core/environment :development)] + (is (= (core/prep config) + (merge config + {:duct.server/figwheel + {:css-dirs ["resources" "dev/resources"] + :builds + [{:id "dev" + :figwheel true + :source-paths ["dev/src" "src"] + :build-options + {:main 'foo.client + :output-to (absolute-path "target/resources/foo/public/js/main.js") + :output-dir (absolute-path "target/resources/foo/public/js") + :asset-path "/js" + :closure-defines {'goog.DEBUG true} + :verbose false + :preloads ['devtools.preload] + :optimizations :none}}]}})))))) \ No newline at end of file From 15fce570e949263ccafd880a18ca73b9bd2b84a7 Mon Sep 17 00:00:00 2001 From: Alex Chythlook Date: Fri, 20 Apr 2018 20:05:49 -0800 Subject: [PATCH 7/9] Correctly identify which system dec to use. --- test/duct/module/cljs_test.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/duct/module/cljs_test.clj b/test/duct/module/cljs_test.clj index 2b850e4..371b3f2 100644 --- a/test/duct/module/cljs_test.clj +++ b/test/duct/module/cljs_test.clj @@ -50,7 +50,7 @@ :optimizations :advanced}}]}})))) (testing "development config" - (let [config (assoc base-config ::core/environment :development)] + (let [config (assoc service-worker-base-config ::core/environment :development)] (is (= (core/prep config) (merge config {:duct.server/figwheel From 055e1fa377f69387b6234aaf451e910a9e127ba8 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 20 Apr 2018 20:18:47 -0800 Subject: [PATCH 8/9] Add the nil that the new config setup puts into the build vector. --- test/duct/module/cljs_test.clj | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/duct/module/cljs_test.clj b/test/duct/module/cljs_test.clj index 371b3f2..7041c90 100644 --- a/test/duct/module/cljs_test.clj +++ b/test/duct/module/cljs_test.clj @@ -91,7 +91,8 @@ (merge base-config {:duct.compiler/cljs {:builds - [{:source-paths ["src"] + [nil + {:source-paths ["src"] :build-options {:main 'foo.client :output-to (absolute-path "target/resources/foo/public/js/main.js") @@ -108,7 +109,8 @@ {:duct.server/figwheel {:css-dirs ["resources" "dev/resources"] :builds - [{:id "dev" + [nil + {:id "dev" :figwheel true :source-paths ["dev/src" "src"] :build-options From fc58bb90aeb29fe592cfbf52caebb2fd94936379 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 20 Apr 2018 20:35:37 -0800 Subject: [PATCH 9/9] Add in check to figwheel config. --- src/duct/module/cljs.clj | 75 +++++++++++++++++----------------- test/duct/module/cljs_test.clj | 8 ++-- 2 files changed, 42 insertions(+), 41 deletions(-) diff --git a/src/duct/module/cljs.clj b/src/duct/module/cljs.clj index e6a301b..be41ab7 100644 --- a/src/duct/module/cljs.clj +++ b/src/duct/module/cljs.clj @@ -21,51 +21,52 @@ (defn- compiler-config [path main sw-main] {:duct.compiler/cljs {:builds ^:displace + [(when sw-main + {:id "sw" + :source-paths ["src"] + :build-options + {:main sw-main + :output-to (str path "/sw.js") + :output-dir (str path "/sw") + :asset-path "/sw" + :closure-defines {'goog.DEBUG false} + :verbose true + :infer-externs true + :language-in :es6 + :rewrite-polyfills true + :optimizations :advanced + :target :webworker}}) + {:source-paths ["src"] + :build-options + {:main main + :output-to (str path "/js/main.js") + :output-dir (str path "/js") + :asset-path "/js" + :closure-defines {'goog.DEBUG false} + :verbose true + :optimizations :advanced}}]}}) + +(defn- figwheel-config [path main sw-main] + {:duct.server/figwheel + {:css-dirs ^:displace ["resources" "dev/resources"] + :builds ^:displace [(when sw-main - {:id "sw" - :source-paths ["src"] + {:id "sw-dev" + :figwheel false + :source-paths ["dev/src" "src"] :build-options - {:main sw-main - :output-to (str path "/sw.js") + {:main sw-main + :output-to (str path "/sw.js") :output-dir (str path "/sw") :asset-path "/sw" - :closure-defines {'goog.DEBUG false} - :verbose true + :closure-defines {'goog.DEBUG true} + :verbose false :infer-externs true :language-in :es6 :rewrite-polyfills true - :optimizations :advanced + :preloads '[devtools.preload] + :optimizations :none :target :webworker}}) - {:source-paths ["src"] - :build-options - {:main main - :output-to (str path "/js/main.js") - :output-dir (str path "/js") - :asset-path "/js" - :closure-defines {'goog.DEBUG false} - :verbose true - :optimizations :advanced}}]}}) - -(defn- figwheel-config [path main sw-main] - {:duct.server/figwheel - {:css-dirs ^:displace ["resources" "dev/resources"] - :builds ^:displace - [{:id "sw-dev" - :figwheel false - :source-paths ["dev/src" "src"] - :build-options - {:main sw-main - :output-to (str path "/sw.js") - :output-dir (str path "/sw") - :asset-path "/sw" - :closure-defines {'goog.DEBUG true} - :verbose false - :infer-externs true - :language-in :es6 - :rewrite-polyfills true - :preloads '[devtools.preload] - :optimizations :none - :target :webworker}} {:id "dev" :figwheel true :source-paths ["dev/src" "src"] diff --git a/test/duct/module/cljs_test.clj b/test/duct/module/cljs_test.clj index 7041c90..0776da1 100644 --- a/test/duct/module/cljs_test.clj +++ b/test/duct/module/cljs_test.clj @@ -20,7 +20,7 @@ (.getAbsolutePath (io/file relative-path))) (deftest service-worker-module-test - (testing "production config" + (testing "production config with service worker" (is (= (core/prep service-worker-base-config) (merge service-worker-base-config {:duct.compiler/cljs @@ -49,7 +49,7 @@ :verbose true :optimizations :advanced}}]}})))) - (testing "development config" + (testing "development config with service worker" (let [config (assoc service-worker-base-config ::core/environment :development)] (is (= (core/prep config) (merge config @@ -86,7 +86,7 @@ :optimizations :none}}]}})))))) (deftest module-test - (testing "production config" + (testing "production config without service worker" (is (= (core/prep base-config) (merge base-config {:duct.compiler/cljs @@ -102,7 +102,7 @@ :verbose true :optimizations :advanced}}]}})))) - (testing "development config" + (testing "development config without service worker" (let [config (assoc base-config ::core/environment :development)] (is (= (core/prep config) (merge config