Skip to content

Commit

Permalink
rename ssr to build:render and fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
fiji-flo committed Apr 26, 2024
1 parent d6e8dd6 commit 4dc5262
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dev-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ jobs:
yarn build --sitemap-index
# SSR all pages
yarn ssr
yarn build:render
# Generate whatsdeployed files.
yarn tool whatsdeployed --output client/build/_whatsdeployed/code.json
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
yarn build:prepare
# BUILD_FOLDERSEARCH=mdn/kitchensink yarn build
BUILD_FOLDERSEARCH=web/javascript/reference/global_objects/array/foreach yarn build
yarn build:render
- name: Serve and lhci
env:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/prod-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ jobs:
# Build the curriculum
yarn build:curriculum
# SSR all pages
yarn build:render
# Generate whatsdeployed files.
yarn tool whatsdeployed --output client/build/_whatsdeployed/code.json
yarn tool whatsdeployed $CONTENT_ROOT --output client/build/_whatsdeployed/content.json
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stage-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ jobs:
yarn build:curriculum
# SSR all pages
yarn ssr
yarn build:render
# Generate whatsdeployed files.
yarn tool whatsdeployed --output client/build/_whatsdeployed/code.json
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ jobs:
run: |
yarn build:prepare
yarn build
yarn build:render
yarn start:static-server > /tmp/stdout.log 2> /tmp/stderr.log &
sleep 1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/xyz-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ jobs:
yarn build:curriculum
# SSR all pages
yarn ssr
yarn build:render
# Generate whatsdeployed files.
yarn tool whatsdeployed --output client/build/_whatsdeployed/code.json
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,18 @@ pages, but you can pre-emptively build all the content in advance if desired.
One potential advantage is that you can get a more complete list of all possible
"flaws" across all documents before you even visit them.

The most fundamental CLI command is:
The two most fundamental CLI commands are:

yarn build
yarn build:render

### What gets built

Every `index.html` becomes two files:
`yarn build` builds every `index.md` into an `index.json` which contains all
input data for our React client to render a page.

- `index.html` — a fully formed and complete HTML file
- `index.json` — the state information React needs to build the page in the
client
`yarn build:render` renders every of the previously built `index.json` into a
`index.html` which contains the fully formed and complete HTML for the page.

### Flaw checks

Expand Down
2 changes: 2 additions & 0 deletions build/ssr.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { fdir } from "fdir";
import { BUILD_OUT_ROOT } from "../libs/env/index.js";
import { readFile, writeFile } from "node:fs/promises";
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import { renderHTML } from "../ssr/dist/main.js";
import { HydrationData } from "../libs/types/hydration.js";

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"build:dist": "tsc -p tsconfig.dist.json",
"build:glean": "cd client && cross-env VIRTUAL_ENV=venv glean translate src/telemetry/metrics.yaml src/telemetry/pings.yaml -f typescript -o src/telemetry/generated",
"build:prepare": "yarn build:client && yarn build:ssr && yarn tool popularities && yarn tool spas && yarn tool gather-git-history && yarn tool build-robots-txt",
"build:render": "cross-env NODE_ENV=production NODE_OPTIONS='--no-warnings=ExperimentalWarning --loader ts-node/esm' node build/cli.ts render",
"build:ssr": "cross-env NODE_ENV=production NODE_OPTIONS='--no-warnings=ExperimentalWarning --loader ts-node/esm' node ssr/prepare.ts && cd ssr && webpack --mode=production",
"build:sw": "cd client/pwa && yarn && yarn build:prod",
"build:sw-dev": "cd client/pwa && yarn && yarn build",
Expand All @@ -38,7 +39,6 @@
"prepare": "(husky || true) && yarn install:all && yarn install:all:npm",
"prettier-check": "prettier --check .",
"prettier-format": "prettier --write .",
"ssr": "cross-env NODE_ENV=production NODE_OPTIONS='--no-warnings=ExperimentalWarning --loader ts-node/esm' node build/cli.ts render",
"start": "(test -f client/build/index.html || yarn build:client) && (test -f ssr/dist/main.js || yarn build:ssr) && (test -f popularities.json || yarn tool popularities) && (test -d client/build/en-us/_spas || yarn tool spas) && nf -j Procfile.start start",
"start:client": "cd client && cross-env NODE_ENV=development BABEL_ENV=development BROWSER=none PORT=3000 node scripts/start.js",
"start:server": "node-dev --experimental-loader ts-node/esm server/index.ts",
Expand Down
1 change: 1 addition & 0 deletions scripts/testing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export ENV_FILE=".env.testing"

yarn build:prepare
yarn build
yarn build:render

nohup yarn start:static-server > testing.log 2>&1 &
PID=$!
Expand Down
1 change: 1 addition & 0 deletions testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ To run these tests, first run:
export ENV_FILE=.env.testing
yarn build:prepare
yarn build
yarn build:render
yarn start:static-server
```

Expand Down
1 change: 1 addition & 0 deletions testing/scripts/functional-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export ENV_FILE=.env.testing

yarn build:prepare
yarn build
yarn build:render

yarn test:testing $@

0 comments on commit 4dc5262

Please sign in to comment.