Skip to content

Commit

Permalink
[perf] move goog.i18n deps to a module
Browse files Browse the repository at this point in the history
  • Loading branch information
rasom committed Jun 7, 2019
1 parent 1457f0f commit a25d644
Show file tree
Hide file tree
Showing 16 changed files with 621 additions and 149 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,6 @@ conan.cmake
/.ran-setup
/.nix-gcroots/

#modules
# modules
status-modules/translations
status-modules/cljs
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,22 @@ prod-build:

prod-build-android: export TARGET_OS ?= android
prod-build-android:
lein prod-build-android
cp params_prod.edn params.edn && \
lein prod-build-android && \
node prepare-modules.js

prod-build-ios: export TARGET_OS ?= ios
prod-build-ios:
lein prod-build-ios
cp params_prod.edn params.edn && \
lein prod-build-ios && \
node prepare-modules.js

prod-build-desktop: export TARGET_OS ?= $(HOST_OS)
prod-build-desktop:
git clean -qdxf -f ./index.desktop.js desktop/ && \
lein prod-build-desktop
cp params_prod.edn params.edn && \
lein prod-build-desktop && \
node prepare-modules.js

#--------------
# REPL
Expand Down
1 change: 1 addition & 0 deletions ci/desktop.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def cleanupAndDeps() {
def buildClojureScript() {
nix.shell(
'''
cp params_prod.edn params.edn && \
make prod-build-desktop && \
./scripts/build-desktop.sh buildClojureScript
''',
Expand Down
2 changes: 1 addition & 1 deletion externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,5 +559,5 @@ var TopLevel = {
"decimalPlaces": function () {},
"_android": function () {},
"isSupported" : function () {},
"authenticate" : function () {},
"authenticate" : function () {}
}
1 change: 1 addition & 0 deletions params.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{:env :dev}
1 change: 1 addition & 0 deletions params_prod.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{:env :prod}
20 changes: 20 additions & 0 deletions prepare-modules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var fs = require("fs");

var modules = [
"i18n"
];

modules.forEach(
function (moduleName) {
fs.readFile(`status-modules/cljs/${moduleName}-raw.js`, "utf8", function (err, data) {
if (err) throw err;
fs.writeFile(`status-modules/cljs/${moduleName}.js`,
("module.exports=`" + data.replace(/[\\$'"]/g, "\\$&") + "`;"),
function (err) {
if (err) {
return console.log(err);
}
});
});
});

44 changes: 28 additions & 16 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
:githooks {:auto-install true
:pre-commit ["lein cljfmt check src/status_im/core.cljs $(git diff --diff-filter=d --cached --name-only src test/cljs)"]}
:cljfmt {:indents {letsubs [[:inner 0]]}}
:clean-targets ["target/" "index.ios.js" "index.android.js"]
:clean-targets ["target/" "index.ios.js" "index.android.js" "status-modules/cljs"]
:aliases {"prod-build" ^{:doc "Recompile code with prod profile."}
["do" "clean"
["with-profile" "prod" "cljsbuild" "once" "ios"]
Expand Down Expand Up @@ -90,12 +90,12 @@
:target :nodejs}}
{:id "protocol"
:source-paths ["components/src" "src" "test/cljs" "dev"]
:compiler {:main status-im.test.protocol.runner
:output-to "target/test/test.js"
:output-dir "target/test"
:optimizations :none
:preamble ["js/hook-require.js"]
:target :nodejs}}
:compiler {:main status-im.test.protocol.runner
:output-to "target/test/test.js"
:output-dir "target/test"
:optimizations :none
:preamble ["js/hook-require.js"]
:target :nodejs}}
{:id "env-dev-utils"
:source-paths ["env/dev/env/utils.cljs" "test/env/dev" "dev"]
:compiler {:main env.test.runner
Expand All @@ -106,8 +106,7 @@
:prod {:cljsbuild {:builds
{:ios
{:source-paths ["components/src" "react-native/src/cljsjs" "react-native/src/mobile" "src" "env/prod" "prod"]
:compiler {:output-to "index.ios.js"
:main "env.ios.main"
:compiler {:main "env.ios.main"
:output-dir "target/ios-prod"
:static-fns true
:fn-invoke-direct true
Expand All @@ -119,12 +118,15 @@
:parallel-build false
:elide-asserts true
:externs ["externs.js"]
:language-in :ecmascript5}
:language-in :es-2015
:language-out :es-2015
:modules {:cljs-base {:output-to "index.ios.js"}
:i18n {:entries #{"status_im.goog.i18n"}
:output-to "status-modules/cljs/i18n-raw.js"}}}
:warning-handlers [status-im.utils.build/warning-handler]}
:android
{:source-paths ["components/src" "react-native/src/cljsjs" "react-native/src/mobile" "src" "env/prod" "prod"]
:compiler {:output-to "index.android.js"
:main "env.android.main"
:compiler {:main "env.android.main"
:output-dir "target/android-prod"
:static-fns true
:fn-invoke-direct true
Expand All @@ -136,18 +138,28 @@
:parallel-build false
:elide-asserts true
:externs ["externs.js"]
:language-in :ecmascript5}
:language-in :es-2015
:language-out :es-2015
:modules {:cljs-base {:output-to "index.android.js"}
:i18n {:entries #{"status_im.goog.i18n"}
:output-to "status-modules/cljs/i18n-raw.js"}}}
:warning-handlers [status-im.utils.build/warning-handler]}
:desktop
{:source-paths ["components/src" "react-native/src/cljsjs" "react-native/src/desktop" "src" "env/prod" "prod"]
:compiler {:output-to "index.desktop.js"
:main "env.desktop.main"
:compiler {:main "env.desktop.main"
:output-dir "target/desktop-prod"
:static-fns true
:fn-invoke-direct true
:optimize-constants true
:optimizations :simple
:closure-defines {"goog.DEBUG" false}
:pseudo-names false
:pretty-print false
:parallel-build false
:elide-asserts true
:language-in :ecmascript5}
:language-in :es-2015
:language-out :es-2015
:modules {:cljs-base {:output-to "index.desktop.js"}
:i18n {:entries #{"status_im.goog.i18n"}
:output-to "status-modules/cljs/i18n-raw.js"}}}
:warning-handlers [status-im.utils.build/warning-handler]}}}}})
Loading

0 comments on commit a25d644

Please sign in to comment.