aboutsummaryrefslogtreecommitdiff
path: root/internal/frontend
diff options
context:
space:
mode:
authorMichael Matloob <matloob@golang.org>2023-08-24 14:28:48 -0400
committerMichael Matloob <matloob@golang.org>2023-08-25 19:10:21 +0000
commitecfc750c92e7b14f5f963fa20865251bcdf5f2ca (patch)
treefa8b69d11c237fa3c1b7367d8ba02fafcc600879 /internal/frontend
parentc1de6c58cffb7d62c85e8c9a41823f0d0015a9f9 (diff)
downloadgo-x-pkgsite-ecfc750c92e7b14f5f963fa20865251bcdf5f2ca.tar.xz
cmd/frontend: move typescript compile watching into main
To remove the dependency from cmd/pkgsite on to github.com/evanw/esbuild, this change moves the code that starts the watcher for recompiling typescript files into cmd/frontend. This means the dev mode functionality in cmd/pkgsite for watching and recompiling typescript files is gone. For golang/go#61399 Change-Id: If1325461de30dfd2f71b63d810cab8e9b4cdeb06 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/522735 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> kokoro-CI: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'internal/frontend')
-rw-r--r--internal/frontend/fetchserver/fetch_test.go1
-rw-r--r--internal/frontend/frontend_test.go1
-rw-r--r--internal/frontend/server.go19
3 files changed, 0 insertions, 21 deletions
diff --git a/internal/frontend/fetchserver/fetch_test.go b/internal/frontend/fetchserver/fetch_test.go
index a4eb381c..c98585df 100644
--- a/internal/frontend/fetchserver/fetch_test.go
+++ b/internal/frontend/fetchserver/fetch_test.go
@@ -70,7 +70,6 @@ func newTestServerWithFetch(t *testing.T, proxyModules []*proxytest.Module, cach
// Integration tests will use the actual directories.
StaticFS: static.FS,
ThirdPartyFS: thirdparty.FS,
- StaticPath: "../../static",
})
if err != nil {
t.Fatal(err)
diff --git a/internal/frontend/frontend_test.go b/internal/frontend/frontend_test.go
index c43257b3..2fe64269 100644
--- a/internal/frontend/frontend_test.go
+++ b/internal/frontend/frontend_test.go
@@ -48,7 +48,6 @@ func newTestServer(t *testing.T, cacher Cacher) (*Server, http.Handler) {
// Integration tests will use the actual directories.
StaticFS: static.FS,
ThirdPartyFS: thirdparty.FS,
- StaticPath: "../../static",
})
if err != nil {
t.Fatal(err)
diff --git a/internal/frontend/server.go b/internal/frontend/server.go
index 264669b8..c0df2168 100644
--- a/internal/frontend/server.go
+++ b/internal/frontend/server.go
@@ -35,7 +35,6 @@ import (
"golang.org/x/pkgsite/internal/memory"
"golang.org/x/pkgsite/internal/middleware/stats"
"golang.org/x/pkgsite/internal/queue"
- "golang.org/x/pkgsite/internal/static"
"golang.org/x/pkgsite/internal/version"
"golang.org/x/pkgsite/internal/vuln"
"golang.org/x/text/cases"
@@ -54,7 +53,6 @@ type Server struct {
devMode bool
localMode bool // running locally (i.e. ./cmd/pkgsite)
localModules []LocalModule // locally hosted modules; empty in production
- staticPath string // used only for dynamic loading in dev mode
errorPage []byte
appVersionLabel string
googleTagManagerID string
@@ -95,7 +93,6 @@ type ServerConfig struct {
DevMode bool
LocalMode bool
LocalModules []LocalModule
- StaticPath string // used only for dynamic loading in dev mode
Reporter derrors.Reporter
VulndbClient *vuln.Client
}
@@ -118,7 +115,6 @@ func NewServer(scfg ServerConfig) (_ *Server, err error) {
devMode: scfg.DevMode,
localMode: scfg.LocalMode,
localModules: scfg.LocalModules,
- staticPath: scfg.StaticPath,
templates: ts,
reporter: scfg.Reporter,
fileMux: http.NewServeMux(),
@@ -738,21 +734,6 @@ func parsePageTemplates(fsys template.TrustedFS) (map[string]*template.Template,
}
func (s *Server) staticHandler() http.Handler {
- // In dev mode compile TypeScript files into minified JavaScript files
- // and rebuild them on file changes.
- if s.devMode {
- if s.staticPath == "" {
- panic("staticPath is empty in dev mode; cannot rebuild static files")
- }
- ctx := context.Background()
- if err := static.Build(static.Config{
- EntryPoint: s.staticPath + "/frontend",
- Watch: true,
- Bundle: true,
- }); err != nil {
- log.Error(ctx, err)
- }
- }
return http.StripPrefix("/static/", http.FileServer(http.FS(s.staticFS)))
}