Skip to content

Commit 474fcad

Browse files
committed
internal,static: upgrade esbuild
The previous version of esbuild would sometimes out non-deterministic versions of minified files. This would generate large diffs when make small changes to script code on different machines. Change-Id: I30540088ad2a259e4c086b18505016a95937dc2f Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/469855 Run-TryBot: Jamal Carvalho <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]> TryBot-Result: kokoro <[email protected]>
1 parent 0c71934 commit 474fcad

File tree

20 files changed

+72
-66
lines changed

20 files changed

+72
-66
lines changed

devtools/cmd/static/main.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ import (
1313
)
1414

1515
func main() {
16-
_, err := static.Build(static.Config{EntryPoint: "static/frontend", Bundle: true})
17-
if err != nil {
16+
if err := static.Build(static.Config{EntryPoint: "static/frontend", Bundle: true}); err != nil {
1817
log.Fatal(err)
1918
}
2019

21-
_, err = static.Build(static.Config{EntryPoint: "static/worker", Bundle: true})
22-
if err != nil {
20+
if err := static.Build(static.Config{EntryPoint: "static/worker", Bundle: true}); err != nil {
2321
log.Fatal(err)
2422
}
2523
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/Masterminds/squirrel v1.5.2
1616
github.com/alicebob/miniredis/v2 v2.17.0
1717
github.com/andybalholm/cascadia v1.3.1
18-
github.com/evanw/esbuild v0.14.10
18+
github.com/evanw/esbuild v0.17.8
1919
github.com/ghodss/yaml v1.0.0
2020
github.com/go-git/go-billy/v5 v5.3.1
2121
github.com/go-git/go-git/v5 v5.4.2

go.sum

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,8 @@ github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.
399399
github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=
400400
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
401401
github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
402-
github.com/evanw/esbuild v0.14.10 h1:+7c1VNndl7uLLxVEeRH4rOUz0Y+nrSw8xfmE9rGtrtw=
403-
github.com/evanw/esbuild v0.14.10/go.mod h1:GG+zjdi59yh3ehDn4ZWfPcATxjPDUH53iU4ZJbp7dkY=
402+
github.com/evanw/esbuild v0.17.8 h1:QzE7cRRq7y3qH7ZKGN0/nUGbdZPyikfNaMaCMNUufnU=
403+
github.com/evanw/esbuild v0.17.8/go.mod h1:iINY06rn799hi48UqEnaQvVfZWe6W9bET78LbvN8VWk=
404404
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
405405
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
406406
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
@@ -1378,6 +1378,7 @@ golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBc
13781378
golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
13791379
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
13801380
golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1381+
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
13811382
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
13821383
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
13831384
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=

internal/frontend/server.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,8 +779,11 @@ func (s *Server) staticHandler() http.Handler {
779779
panic("staticPath is empty in dev mode; cannot rebuild static files")
780780
}
781781
ctx := context.Background()
782-
_, err := static.Build(static.Config{EntryPoint: s.staticPath + "/frontend", Watch: true, Bundle: true})
783-
if err != nil {
782+
if err := static.Build(static.Config{
783+
EntryPoint: s.staticPath + "/frontend",
784+
Watch: true,
785+
Bundle: true,
786+
}); err != nil {
784787
log.Error(ctx, err)
785788
}
786789
}

internal/static/static.go

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,41 +36,45 @@ type Config struct {
3636
// when cmd/frontend is run in dev mode and in
3737
// devtools/cmd/static/main.go with Watch=false for building
3838
// productionized assets.
39-
func Build(config Config) (*api.BuildResult, error) {
39+
func Build(config Config) error {
4040
files, err := getEntry(config.EntryPoint, config.Bundle)
4141
if err != nil {
42-
return nil, err
42+
return err
4343
}
4444
options := api.BuildOptions{
45-
EntryPoints: files,
46-
Bundle: config.Bundle,
47-
Outdir: config.EntryPoint,
48-
Write: true,
49-
Platform: api.PlatformBrowser,
50-
Format: api.FormatESModule,
51-
OutExtensions: map[string]string{".css": ".min.css"},
52-
External: []string{"*.svg"},
45+
EntryPoints: files,
46+
Bundle: config.Bundle,
47+
Outdir: config.EntryPoint,
48+
Write: true,
49+
Platform: api.PlatformBrowser,
50+
Format: api.FormatESModule,
51+
OutExtension: map[string]string{".css": ".min.css"},
52+
External: []string{"*.svg"},
5353
Banner: map[string]string{"css": "/*!\n" +
5454
" * Copyright 2021 The Go Authors. All rights reserved.\n" +
5555
" * Use of this source code is governed by a BSD-style\n" +
5656
" * license that can be found in the LICENSE file.\n" +
5757
" */"},
5858
}
59-
if config.Watch {
60-
options.Watch = &api.WatchMode{}
61-
}
6259
options.MinifyIdentifiers = true
6360
options.MinifySyntax = true
6461
options.MinifyWhitespace = true
6562
options.Sourcemap = api.SourceMapLinked
63+
if config.Watch {
64+
ctx, err := api.Context(options)
65+
if err != nil {
66+
return err
67+
}
68+
return ctx.Watch(api.WatchOptions{})
69+
}
6670
result := api.Build(options)
6771
if len(result.Errors) > 0 {
68-
return nil, fmt.Errorf("error building static files: %v", result.Errors)
72+
return fmt.Errorf("error building static files: %v", result.Errors)
6973
}
7074
if len(result.Warnings) > 0 {
71-
return nil, fmt.Errorf("error building static files: %v", result.Warnings)
75+
return fmt.Errorf("error building static files: %v", result.Warnings)
7276
}
73-
return &result, nil
77+
return nil
7478
}
7579

7680
// getEntry walks the the given directory and collects entry file paths

static/frontend/about/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)