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 5, 2019
1 parent 632bbf3 commit ac10daa
Show file tree
Hide file tree
Showing 18 changed files with 622 additions and 152 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,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
5 changes: 4 additions & 1 deletion ci/Jenkinsfile.android
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ pipeline {
}
stage('Build') {
steps {
script { cmn.nix.shell('lein prod-build-android')}
script {
cmn.nix.shell('lein prod-build-android')
cmn.nix.shell('node prepare-modules.js')
}
}
}
stage('Bundle') {
Expand Down
5 changes: 4 additions & 1 deletion ci/Jenkinsfile.ios
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ pipeline {
}
stage('Build') {
steps {
script { cmn.nix.shell('lein prod-build-ios') }
script {
cmn.nix.shell('lein prod-build-ios')
cmn.nix.shell('node prepare-modules.js')
}
}
}
stage('Bundle') {
Expand Down
1 change: 1 addition & 0 deletions ci/utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def changeId() {
}

def updateEnv(type) {
sh "cp params_prod.edn params.edn"
def envFile = "${env.WORKSPACE}/.env"
/* select .env based on type of build */
def selectedEnv = '.env.jenkins'
Expand Down
2 changes: 1 addition & 1 deletion externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,5 +560,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);
}
});
});
});

46 changes: 29 additions & 17 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
:optimizations :advanced
: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 ac10daa

Please sign in to comment.