Skip to content

Commit 23ada84

Browse files
committed
Print artifact size analysis in the text form if -v option is passed.
1 parent 0c991f0 commit 23ada84

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

build/analysis/tree.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func (n *treeMapNode) Describe() string {
218218
// String representation of the node and its effective children.
219219
func (n *treeMapNode) String() string {
220220
s := &strings.Builder{}
221-
fmt.Fprintf(s, " %s %s\n", strings.Repeat(" *", n.depth), n.Describe())
221+
fmt.Fprintf(s, " %s %s\n", strings.Repeat(" |", n.depth), n.Describe())
222222
for _, c := range n.effectiveChildren {
223223
s.WriteString(c.String())
224224
}

build/analysis/visualize.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import (
1010
// Visualizer renders a TreeMap diagram representing the generated JS file and
1111
// how different packages contributed it its size.
1212
type Visualizer struct {
13-
File *os.File
14-
Main *compiler.Archive
15-
Deps []*compiler.Archive
13+
File *os.File
14+
Main *compiler.Archive
15+
Deps []*compiler.Archive
16+
PrintStats bool
1617
}
1718

1819
// Render a Tree Map diagram for the given package sizes.
@@ -32,6 +33,10 @@ func (v *Visualizer) Render(stats map[string]int) error {
3233
return err
3334
}
3435
fmt.Fprintf(v.File, "</svg>\n")
36+
37+
if v.PrintStats {
38+
fmt.Println(tree)
39+
}
3540
return nil
3641
}
3742

build/build.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -966,9 +966,10 @@ func (s *Session) WriteCommandPackage(archive *compiler.Archive, pkgObj string)
966966
}
967967
defer f.Close()
968968
visualizer := &analysis.Visualizer{
969-
Main: archive,
970-
Deps: deps,
971-
File: f,
969+
Main: archive,
970+
Deps: deps,
971+
File: f,
972+
PrintStats: s.options.Verbose && !s.options.Quiet,
972973
}
973974
defer func() {
974975
if err := visualizer.Render(sourceMapFilter.BytesWritten); err != nil {

0 commit comments

Comments
 (0)