Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/pkgsite: migrating to typescript #43359

Closed
jamalc opened this issue Dec 24, 2020 · 15 comments
Closed

x/pkgsite: migrating to typescript #43359

jamalc opened this issue Dec 24, 2020 · 15 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. pkgsite/frontend Issues related to pkgsite HTML/CSS/JavaScript and frontend development pkgsite

Comments

@jamalc
Copy link

jamalc commented Dec 24, 2020

We're working to improve frontend development ergonomics for pkgsite. This is the second in a series of issues about our plans. Comment below with any feedback or suggestions related to this issue!

Summary

New frontend code for pkgsite will be written in TypeScript and existing code will be ported over piecemeal. TypeScript code will be compiled and minified with esbuild and the Closure Compiler will be removed from our build process.

Details

As a command line tool esbuild can compile our TypeScript into JavaScript with no additional configuration. A one line command is all that’s needed to compile the code, minify it, and create source maps.

esbuild content/static/ts --minify --sourcemap --outdir=content/static/js.

In development mode esbuild will start a web server that serves compiled assets from the provided port. Requests for frontend assets will be proxied to this server during development.

esbuild content/static/ts --sourcemap=inline --serve=localhost:5000

Given our browser support matrix and the user agents visiting us, we plan to migrate fully to JavaScript Modules (<script type="module">) and serve JavaScript assets unbundled.

Related Issues

@jamalc jamalc added NeedsFix The path to resolution is known, but the work has not been done. pkgsite labels Dec 24, 2020
@jamalc jamalc added this to the pkgsite/frontend milestone Dec 24, 2020
@jamalc jamalc self-assigned this Dec 24, 2020
@jamalc jamalc changed the title x/pkgsite: migrating to typescript x/pkgsite: migrating to typescript with esbuild Dec 24, 2020
@jamalc jamalc changed the title x/pkgsite: migrating to typescript with esbuild x/pkgsite: migrating to typescript Dec 30, 2020
@gopherbot
Copy link

Change https://golang.org/cl/280705 mentions this issue: root: add config and scripts for processing ts and css files

gopherbot pushed a commit to golang/pkgsite that referenced this issue Dec 30, 2020
Adds dependencies for PostCSS and TypeScript with build
and develop scripts that use them in package.json.

Removes tsconfig parser option from eslintrc because it interferes
with a change in the tsconfig to exclude test files. We want eslint
to still lint test files. This is okay for now because none of our
lint rules depend on type information. If we add rules that require
type info we can create a separate tsconfig for eslint.

This change adds TypeScript but not esbuild. It is not
clear that we need minification so we will start with just
the TypeScript compiler for now. Looking at some of the sources
we currently minify with the closure compiler typical savings in
a file is less than 1kb. Once we have some TypeScript
code to compare minified and unminified performance with we
can consider adding esbuild or some other minifier.

For golang/go#43359
For golang/go#43360

Change-Id: I1a181952f546b0a0eb9b755128b2b83481e8ed92
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/280705
Reviewed-by: Julie Qiu <julie@golang.org>
Trust: Jamal Carvalho <jamal@golang.org>
@gopherbot
Copy link

Change https://golang.org/cl/280893 mentions this issue: content: move clipboard.js code to content/ts

gopherbot pushed a commit to golang/pkgsite that referenced this issue Jan 5, 2021
Migrates CopyToClipboardController to TypeScript
and adds a unit test.

For golang/go#43359
For golang/go#43361

Change-Id: I2e1179aa7cecb0e280a57d420ee2f885c4d6db3c
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/280893
Reviewed-by: Julie Qiu <julie@golang.org>
Trust: Jamal Carvalho <jamal@golang.org>
@gopherbot
Copy link

Change https://golang.org/cl/299251 mentions this issue: content,internal: consolidate smaller JS scripts into sitewide entry file

@gopherbot
Copy link

Change https://golang.org/cl/299259 mentions this issue: content/static: rewrite unit_fixed_header.js with typescript

@gopherbot
Copy link

Change https://golang.org/cl/299255 mentions this issue: content,internal: rewrite jump.js with typescript

@gopherbot
Copy link

Change https://golang.org/cl/299253 mentions this issue: content,internal: rewrite badge.js with typescript

@gopherbot
Copy link

Change https://golang.org/cl/299260 mentions this issue: content/static: rewrite unit.js with typescript

@gopherbot
Copy link

Change https://golang.org/cl/299258 mentions this issue: content/static: rewrite toggle-tip.js with typescript

@gopherbot
Copy link

Change https://golang.org/cl/299256 mentions this issue: content,internal: rewrite keyboard.js with typescript

@gopherbot
Copy link

Change https://golang.org/cl/299261 mentions this issue: content,third_party: remove unused JS files

@gopherbot
Copy link

Change https://golang.org/cl/299257 mentions this issue: content/static: fix unit page type error

@gopherbot
Copy link

Change https://golang.org/cl/299254 mentions this issue: content,internal: rewrite fetch.js with typescript

gopherbot pushed a commit to golang/pkgsite that referenced this issue Mar 8, 2021
…file

Moves analytics, utm_source and base site code to a new file called
site.ts. This file contains all initialization scripts for pkg.go.dev
that should be run before other scripts are added to the page.

For golang/go#43359

Change-Id: I49dbf7afdaffa9c0638266ae58e1059802936fc1
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/299251
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
gopherbot pushed a commit to golang/pkgsite that referenced this issue Mar 8, 2021
For golang/go#43359

Change-Id: I48e21ddecb5a26e28d112f0ede5779ec599b8b4f
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/299253
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
gopherbot pushed a commit to golang/pkgsite that referenced this issue Mar 8, 2021
For golang/go#43359

Change-Id: Id668a6e7c307233b55388235bbc5011a339e5680
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/299254
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
gopherbot pushed a commit to golang/pkgsite that referenced this issue Mar 8, 2021
For golang/go#43359

Change-Id: I4ceef713fac50cf69ca4f79954a0a9bdb932f1d8
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/299255
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
gopherbot pushed a commit to golang/pkgsite that referenced this issue Mar 8, 2021
For golang/go#43359

Change-Id: I5d5331c5aa072650bb97d4bf70c6a1df00a3602f
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/299256
Trust: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
gopherbot pushed a commit to golang/pkgsite that referenced this issue Mar 8, 2021
Makes expandAll toggle for ExpandableRowsTableController
optional to fix a type error in unit.ts

For golang/go#43359

Change-Id: I5680283ea71d0aabde3511c76ac8ee39ab288905
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/299257
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
gopherbot pushed a commit to golang/pkgsite that referenced this issue Mar 8, 2021
For golang/go#43359

Change-Id: Ifca0779ae6a949c06c765b20d7a3e0f1c591f60a
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/299258
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
gopherbot pushed a commit to golang/pkgsite that referenced this issue Mar 8, 2021
For golang/go#43359

Change-Id: Iae32a7872f207abd7b2667097ac1d3e57f4bbd92
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/299259
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
gopherbot pushed a commit to golang/pkgsite that referenced this issue Mar 8, 2021
For golang/go#43359

Change-Id: I4256144908205463a70a6bd1b6c8b5b751ec2cc6
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/299260
Trust: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
gopherbot pushed a commit to golang/pkgsite that referenced this issue Mar 8, 2021
For golang/go#43359

Change-Id: Ib2aed959229e630fc779534859121ced469054a9
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/299261
Trust: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
@gopherbot
Copy link

Change https://golang.org/cl/300069 mentions this issue: content/static: rewrite sidenav.js with typescript

@gopherbot
Copy link

Change https://golang.org/cl/300070 mentions this issue: content/static: rewrite worker.js with typescript

gopherbot pushed a commit to golang/pkgsite that referenced this issue Mar 9, 2021
For golang/go#43359

Change-Id: Icd5d9bdf06694e823b898d7972ba2fb697454896
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/300069
Trust: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
gopherbot pushed a commit to golang/pkgsite that referenced this issue Mar 9, 2021
For golang/go#43359

Change-Id: I3322816e860f7107dee9ab49f85c891af920242a
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/300070
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Trust: Jamal Carvalho <jamal@golang.org>
@gopherbot
Copy link

Change https://golang.org/cl/300074 mentions this issue: devtools,internal/frontend: configuration for esbuild

@golang golang locked and limited conversation to collaborators Mar 10, 2022
@hyangah hyangah added the pkgsite/frontend Issues related to pkgsite HTML/CSS/JavaScript and frontend development label May 20, 2022
@rsc rsc unassigned jamalc Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. pkgsite/frontend Issues related to pkgsite HTML/CSS/JavaScript and frontend development pkgsite
Projects
None yet
Development

No branches or pull requests

3 participants