Commit 5ef5f10
provide define macro to support proper use of goog.define
Using Closure defines [1] has always been possible by attaching
the appropriate JSDoc metadata to a var:
(def ^{:jsdoc ["@define {boolean}"]}
APP_DEBUG true)
When compiling with :optimizations :none however these defines cannot be
overridden.
This commit introduces a `cljs.core/define` macro that helps with
emitting proper `goog.define` calls. Defines done with `goog.define` can
be overriden at runtime by supplying `CLOSURE_UNCOMPILED_DEFINES` or
`CLOSURE_DEFINES`. [2]
(ns your-app.core)
(define APP_DEBUG true)
emits the following `goog.define` call:
/** @define {boolean} */
goog.define('your_app.core.APP_DEBUG', true)
When compiling with `:none` the map passed to `:closure-defines`
is now added to the main file, allowing `goog.define` to pick
the right value at runtime.
[1] https://developers.google.com/closure/compiler/docs/js-for-compiler?hl=en#tag-define
[2] http://google.github.io/closure-library/api/source/closure/goog/base.js.src.html#l511 parent b7309fd commit 5ef5f10
2 files changed
+35
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1123 | 1123 | | |
1124 | 1124 | | |
1125 | 1125 | | |
1126 | | - | |
| 1126 | + | |
| 1127 | + | |
1127 | 1128 | | |
1128 | 1129 | | |
1129 | 1130 | | |
| |||
1134 | 1135 | | |
1135 | 1136 | | |
1136 | 1137 | | |
| 1138 | + | |
1137 | 1139 | | |
1138 | 1140 | | |
1139 | 1141 | | |
1140 | | - | |
| 1142 | + | |
| 1143 | + | |
1141 | 1144 | | |
1142 | 1145 | | |
1143 | 1146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
685 | 685 | | |
686 | 686 | | |
687 | 687 | | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
688 | 718 | | |
689 | 719 | | |
690 | 720 | | |
| |||
0 commit comments