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

Commit 1646b28

Browse files
alessandrodmoea
authored andcommitted
Fix issues with :optimizations :advanced (#77)
* Fix index.js as generated with :optimizations :advanced. Fix a ReferenceError exception being raised from index.js using :optimizations :advanced. * Fix single-file packaging. Adding :optimizations :simple support in bd57679 seems to have broken single-file packaging. :optimizations values (:none, :simple, :advanced) are never namespace prefixed, so we were always using stuff-zip :default.
1 parent c45b5d8 commit 1646b28

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

plugin/resources/index-advanced.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ try {
99
process.env.{{key}} = "{{value}}";
1010
{{/#env}}
1111

12-
require("./{{output-to}}");
12+
var __CLJS_LAMBDA_NS_ROOT = require("./{{output-to}}");
1313

1414
{{#module}}
1515
{{#function}}
16-
exports.{{export}} = {{js-name}};
16+
exports.{{export}} = __CLJS_LAMBDA_NS_ROOT.{{js-name}};
1717
{{/function}}
1818
{{/module}}

plugin/src/leiningen/cljs_lambda/zip_tedium.clj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,18 @@
5555
(when-not (.isDirectory file)
5656
(zip-entry zip-stream file path))))))
5757

58-
(defmulti stuff-zip (fn [_ {:keys [optimizations]} _] optimizations))
59-
60-
(derive ::advanced ::single-file)
61-
(derive ::simple ::single-file)
58+
(defmulti stuff-zip
59+
(fn [_ {:keys [optimizations]} _]
60+
(if (#{:simple :advanced} optimizations)
61+
:single-file
62+
:default)))
6263

6364
(defmethod stuff-zip :default [zip-stream {:keys [output-dir]} {:keys [index-path]}]
6465
(zip-entry zip-stream (io/file index-path) "index.js")
6566
(zip-below zip-stream (io/file output-dir))
6667
(zip-below zip-stream (io/file "node_modules")))
6768

68-
(defmethod stuff-zip ::single-file [zip-stream {:keys [output-to source-map]} {:keys [index-path]}]
69+
(defmethod stuff-zip :single-file [zip-stream {:keys [output-to source-map]} {:keys [index-path]}]
6970
(zip-entry zip-stream (io/file index-path) "index.js")
7071
(zip-entry zip-stream (io/file output-to))
7172
(when (string? source-map)

0 commit comments

Comments
 (0)