Skip to content

Commit b7c4897

Browse files
committed
feat: add report script
1 parent dc74704 commit b7c4897

File tree

7 files changed

+27
-8
lines changed

7 files changed

+27
-8
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ You can use it to design, test, and think about parts of your app in isolation.
105105

106106
This environment uses [Devcards](https://github.com/bhauman/devcards) and [React Testing Library](https://testing-library.com/docs/react-testing-library/intro).
107107

108+
### `npm run build` or `yarn build`
109+
110+
Builds the app for production to the `public` folder.<br>
111+
It correctly bundles all code and optimizes the build for the best performance.
112+
108113
### `npm test` or `yarn test`, and `npm run e2e` or `yarn e2e`
109114

110115
`test` launches the test runner in the interactive watch mode.<br>
@@ -118,10 +123,10 @@ See the ClojureScript [testing page](https://clojurescript.org/tools/testing) fo
118123

119124
`format` will format your code in a consistent manner using [zprint-clj](https://github.com/clj-commons/zprint-clj).
120125

121-
### `npm run build` or `yarn build`
126+
### `npm run report` or `yarn report`
122127

123-
Builds the app for production to the `public` folder.<br>
124-
It correctly bundles all code and optimizes the build for the best performance.
128+
Make a report of what files contribute to your app size.<br>
129+
Consider [code-splitting](https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html) or using smaller libraries to make your app load faster.
125130

126131
### `npm run server` or `yarn server`
127132

src/create_cljs_app/template.cljs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Will likely need to be replaced with a proper templating library."
2626
{:from "__TEST__" :to (:test:once commands)}
2727
{:from "__E2E__" :to (:e2e commands)}
2828
{:from "__LINT__" :to (:lint commands)}
29+
{:from "__REPORT__" :to (:report commands)}
2930
{:from "__FORMAT__" :to (:format commands)}
3031
{:from "__BUILD__" :to (:build commands)}]})
3132

src/create_cljs_app/utils.cljs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
:test:watch "yarn test:watch"
2121
:e2e "yarn e2e"
2222
:lint "yarn lint"
23+
:report "yarn report"
2324
:format "yarn format"}
2425
{:start "npm start"
2526
:cards "npm run cards"
@@ -29,6 +30,7 @@
2930
:test:watch "npm run test:watch"
3031
:e2e "npm run e2e"
3132
:lint "npm run lint"
33+
:report "npm run report"
3234
:format "npm run format"}))
3335

3436
(defn has-binary-on-PATH? [name] (boolean (which name)))

src/e2e/core.cljs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
(is (not (fileIncludes "./README.md" "__E2E__")))
4747
(is (not (fileIncludes "./README.md" "__BUILD__")))
4848
(is (not (fileIncludes "./README.md" "__LINT__")))
49+
(is (not (fileIncludes "./README.md" "__REPORT__")))
4950
(is (not (fileIncludes "./README.md" "__FORMAT__"))))
5051
(testing "Commands"
5152
(is (= (.-code (silent-exec "yarn sc start")) 0) "Should start background server")
@@ -54,5 +55,6 @@
5455
(is (existsSync "./public/js/main.js"))
5556
"Should output public/js/main.js")
5657
(is (= (.-code (silent-exec "yarn e2e")) 0) "Should e2e")
58+
(is (= (.-code (silent-exec "yarn report")) 0) "Should report")
5759
(is (= (.-code (silent-exec "yarn lint")) 0) "Should lint")
5860
(is (= (.-code (silent-exec "yarn format")) 0) "Should format"))))

template/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ out
55
.nrepl-port
66
.clj-kondo
77
yarn-error.log
8+
report.html

template/README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ You can use it to design, test, and think about parts of your app in isolation.
2323

2424
This environment uses [Devcards](https://github.com/bhauman/devcards) and [React Testing Library](https://testing-library.com/docs/react-testing-library/intro).
2525

26+
### `__BUILD__`
27+
28+
Builds the app for production to the `public` folder.<br>
29+
It correctly bundles all code and optimizes the build for the best performance.
30+
31+
Your app is ready to be deployed!
32+
33+
## Other useful scripts
34+
2635
### `__TEST__` and `__E2E__`
2736

2837
You can use `__TEST__` to run tests a single time, and `__E2E__` to run the end-to-end test app.
@@ -36,12 +45,10 @@ See the ClojureScript [testing page](https://clojurescript.org/tools/testing) fo
3645

3746
`__FORMAT__` will format your code in a consistent manner using [zprint-clj](https://github.com/clj-commons/zprint-clj).
3847

39-
### `__BUILD__`
40-
41-
Builds the app for production to the `public` folder.<br>
42-
It correctly bundles all code and optimizes the build for the best performance.
48+
### `__REPORT__`
4349

44-
Your app is ready to be deployed!
50+
Make a report of what files contribute to your app size.<br>
51+
Consider [code-splitting](https://code.thheller.com/blog/shadow-cljs/2019/03/03/code-splitting-clojurescript.html) or using smaller libraries to make your app load faster.
4552

4653
### `__SERVER__`
4754

template/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"test": "shadow-cljs compile test && node out/test.js",
1212
"test:watch": "shadow-cljs watch test --config-merge \"{:autorun true}\"",
1313
"e2e": "shadow-cljs compile e2e && node out/e2e.js",
14+
"report": "shadow-cljs run shadow.cljs.build-report app report.html",
1415
"lint": "clj-kondo --lint src",
1516
"format": "zprint-clj --hang -i \"./src/**/*.{clj,cljs,cljc,edn}\" -o ./ && zprint-clj -i \"./*.edn\" -o ./",
1617
"clean": "rimraf public/js"

0 commit comments

Comments
 (0)