Skip to content
This repository was archived by the owner on Oct 22, 2022. It is now read-only.

Commit bd57679

Browse files
committed
Support :optimizations :simple
1 parent 461e8b0 commit bd57679

File tree

5 files changed

+29
-9
lines changed

5 files changed

+29
-9
lines changed

plugin/project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject io.nervous/lein-cljs-lambda "0.6.4"
1+
(defproject io.nervous/lein-cljs-lambda "0.6.5-SNAPSHOT"
22
:description "Deploying Clojurescript functions to AWS Lambda"
33
:url "https://github.com/nervous-systems/cljs-lambda"
44
:license {:name "Unlicense" :url "http://unlicense.org/UNLICENSE"}
File renamed without changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{#source-map}}
2+
try {
3+
require("source-map-support").install();
4+
} catch(err) {
5+
}
6+
{{/source-map}}
7+
8+
{{#env}}
9+
process.env.{{key}} = "{{value}}";
10+
{{/#env}}
11+
12+
var __CLJS_LAMBDA_NS_ROOT = require("./{{output-to}}");
13+
14+
{{#module}}
15+
{{#function}}
16+
exports.{{export}} = __CLJS_LAMBDA_NS_ROOT.{{js-name}};
17+
{{/function}}
18+
{{/module}}

plugin/src/leiningen/cljs_lambda.clj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727

2828
(defn- generate-index [env {:keys [optimizations source-map] :as compiler-opts} fns]
2929
(let [template (slurp (io/resource
30-
(if (= optimizations :advanced)
31-
"index-advanced.mustache"
32-
"index.mustache")))]
30+
(str "index-" (name optimizations) ".mustache")))]
3331
(clostache.parser/render
3432
template
3533
(assoc compiler-opts

plugin/src/leiningen/cljs_lambda/zip_tedium.clj

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
(:import [java.io File]
55
[java.nio.file Files LinkOption]
66
[java.nio.file.attribute PosixFilePermission]
7-
[org.apache.commons.compress.archivers.zip ZipArchiveEntry
8-
ZipArchiveOutputStream]))
7+
[org.apache.commons.compress.archivers.zip
8+
ZipArchiveEntry
9+
ZipArchiveOutputStream]))
910

1011
;; I don't have time to explain
1112
(def ^:dynamic *print-files* false)
@@ -55,17 +56,20 @@
5556
(zip-entry zip-stream file path))))))
5657

5758
(defmulti stuff-zip (fn [_ {:keys [optimizations]} _] optimizations))
59+
60+
(derive ::advanced ::single-file)
61+
(derive ::simple ::single-file)
62+
5863
(defmethod stuff-zip :default [zip-stream {:keys [output-dir]} {:keys [index-path]}]
5964
(zip-entry zip-stream (io/file index-path) "index.js")
6065
(zip-below zip-stream (io/file output-dir))
6166
(zip-below zip-stream (io/file "node_modules")))
6267

63-
(defmethod stuff-zip :advanced [zip-stream {:keys [output-to source-map]} {:keys [index-path]}]
68+
(defmethod stuff-zip ::single-file [zip-stream {:keys [output-to source-map]} {:keys [index-path]}]
6469
(zip-entry zip-stream (io/file index-path) "index.js")
6570
(zip-entry zip-stream (io/file output-to))
6671
(when (string? source-map)
67-
(zip-entry zip-stream (io/file source-map)))
68-
(zip-below zip-stream (io/file "node_modules")))
72+
(zip-entry zip-stream (io/file source-map))))
6973

7074
(defn write-zip [{:keys [output-dir] :as compiler-opts}
7175
{:keys [project-name zip-name resource-dirs] :as spec}]

0 commit comments

Comments
 (0)