-
-
Save zalky/47dd7ee21f713b532fcb45093956d7c1 to your computer and use it in GitHub Desktop.
More on code splitting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{:closure-warnings {:non-standard-jsdoc :off} | |
:optimizations :advanced | |
:source-map true | |
:pseudo-names true | |
:parallel-build true | |
:output-dir "js/compiled" | |
:asset-path "js/compiled" | |
:modules {:core {:entries #{re-demo.core} | |
:output-to "js/compiled/app.js" | |
:depends-on #{:vendor}} | |
:data {:entries #{re-demo.data} | |
:output-to "js/compiled/data.js" | |
:depends-on #{:vendor}} | |
:vendor {:entries #{reagent.core} | |
:output-to "js/compiled/vendor.js"}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns re-demo.core | |
(:require [cljs.loader :as loader] | |
[reagent.core :as r])) | |
(def state | |
(r/atom {:input "Hello, world!"})) | |
(defn event->value | |
[e] | |
(-> e .-target .-value)) | |
(defn input-handler | |
[app e] | |
(let [value (event->value e)] | |
(loader/load :data | |
(fn [] | |
((resolve 're-demo.data/update-input) app value))))) | |
(defn root | |
[app] | |
[:input {:value (:input @app) | |
:on-change (partial input-handler app)}]) | |
(defn init! | |
[] | |
(r/render [root state] | |
(.getElementById js/document "container"))) | |
(defonce _ | |
(loader/set-loaded! :core)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns re-demo.data | |
(:require [cljs.loader :as loader] | |
[reagent.core :as r])) | |
(def state | |
(r/atom {})) | |
(defn update-input | |
[app value] | |
(swap! app assoc :input value)) | |
(loader/set-loaded! :data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<meta name="description" content=""> | |
</head> | |
<body> | |
<div id="container"></div> | |
<script src="js/compiled/cljs_base.js" type="text/javascript"></script> | |
<script src="js/compiled/app.js" type="text/javascript"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment