binaryage / binaryage/cljs-devtools

Is dead code elimination really working?

オープン
#37 コメント 11 件 リアクション 0 件 担当者 0 名 GitHub で見る
cljs-bug help wanted
主要言語
Clojure
スター
1.1k
フォーク
51
PR マージ指標
30日以内にマージされた PR はありません

説明

I can't seem to bring the code size down with a barely empty project through dead-code elimination alone, even when following the installation instructions to the letter.

The template used was [reagent-figwheel](https://github.com/gadfly361/reagent-figwheel) with only `devtools` and `reagent` as dependencies. I've fiddled with the `goog.DEBUG` flag, and then removed `devtools` from the `:require` and `:dependencies` vectors.

| Type | Size |
|--------------------------------------------------------|-------:|
| `:dependencies` + `:require` + `goog.DEBUG true` | 1.9 MB |
| `:dependencies` + `:require` + `goog.DEBUG false` | 1.5 MB |
| `:dependencies` + `:require` + no mention at all | 1.6 MB |
| `:dependencies` + no `:require` + no mention at all | 763 KB |
| no `:dependencies` + no `:require` + no mention at all | 763 KB |

The first two rows followed the instructions from the [release notes](https://github.com/binaryage/cljs-devtools/releases/tag/v0.5.3). There's a single mention of ` (devtools/install!)` within a `(when ^boolean js/goog.DEBUG ...)` block. The other three had this line removed manually.

Google Closure's shaved 400kb of the build, but that's still a 800kb increase for a `:require` without a single mention of `devtools`! Is this the best I can expect from dead code elimination?

Here's the code used for the builds (e.g. `lein new reagent-figwheel +devtools`):
```clojure
;##################
;### profile.cljs

(defproject devtools-dce "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.9.229"]
[reagent "0.6.0"]
[binaryage/devtools "0.8.2"]]

[...]

:cljsbuild
{:builds
[{:id "min"
:source-paths ["src/cljs"]
:compiler {:main devtools-dce.core
:optimizations :advanced
:output-to "resources/public/js/compiled/app.js"
:output-dir "resources/public/js/compiled/min"
:closure-defines {goog.DEBUG false}
:pseudo-names true ;; added to exacerbate size difference
:pretty-print false}}

]})

;##############
;## core.cljs

(ns devtools-dce.core
(:require
[reagent.core :as reagent]
[devtools.core :as devtools]
))

[...]

(defn dev-setup [] ;; inlining into `main` made no difference
(when ^boolean js/goog.DEBUG
(enable-console-print!)
(println "dev mode")
(devtools/install!)
))

(defn ^:export main []
(dev-setup)
(reload))
```

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Start with the build configuration in profile.cljs and the namespace and dev-setup entry point in core.cljs, using the reagent-figwheel template and the listed advanced-optimization settings. Reproduce the five builds and compare their output sizes; done means explaining whether the unused devtools dependency is eliminated and documenting or correcting the observed result.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
clojure
領域
build-system
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。