Skip to content

Commit c4ab610

Browse files
committed
Migrate webpack to RSPack
1 parent 5d64caf commit c4ab610

File tree

15 files changed

+18302
-11614
lines changed

15 files changed

+18302
-11614
lines changed

.circleci/config.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,24 @@ jobs:
100100
javascript-tests:
101101
executor:
102102
name: node/default
103-
# The Node version here must be kept in sync with that in `package.json`.
104-
tag: '22.11.0'
103+
# The Node version here should be compatible with `package.json` engines.
104+
tag: '22'
105105
steps:
106106
- checkout
107-
- node/install-packages:
108-
# `yarn install --frozen-lockfile` is run and cache is enabled by default for this orb configuration
109-
pkg-manager: yarn
110107
- run:
111-
command: yarn lint
108+
name: Install pnpm
109+
command: corepack enable && corepack prepare [email protected] --activate
110+
- run:
111+
name: Install dependencies
112+
command: pnpm install --frozen-lockfile
113+
- run:
114+
command: pnpm lint
112115
name: Run linting
113116
- run:
114-
command: yarn markdownlint
117+
command: pnpm markdownlint
115118
name: Check markdown linting
116119
- run:
117-
command: yarn test:coverage
120+
command: pnpm test:coverage
118121
name: Run Jest tests
119122
- codecov/upload
120123

@@ -123,10 +126,6 @@ jobs:
123126
- image: 'cimg/python:3.10-node'
124127
steps:
125128
- checkout
126-
- restore_cache:
127-
name: Restore Yarn Package Cache
128-
keys:
129-
- node-deps-v1-{{ .Branch }}
130129
- run: pip install tox
131130
- run:
132131
command: tox -e docs

.markdownlintignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
docs/index.md
2-
node_modules
2+
node_modules
3+
venv
4+
CLAUDE.md

.npmrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# pnpm configuration for Treeherder
2+
3+
# Equivalent to yarn's ignore-engines - don't check engine compatibility
4+
engine-strict=false
5+
6+
# Save exact versions instead of ranges when adding packages
7+
save-exact=true
8+
9+
# Don't run lifecycle scripts during install for security
10+
ignore-scripts=true
11+
12+
# Hoist all dependencies to node_modules root for compatibility
13+
# This makes pnpm behavior similar to npm/yarn flat node_modules
14+
shamefully-hoist=true
15+
16+
# Auto-install peers to avoid peer dependency warnings
17+
auto-install-peers=true

.yarnrc

Lines changed: 0 additions & 20 deletions
This file was deleted.

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ services:
6060
# https://hub.docker.com/_/node
6161
image: node:23.5.0-alpine3.20
6262
# Installing JS dependencies at runtime so that they share the `node_modules` from the
63-
# host, improving speed (both install and build due to the webpack cache) and ensuring
63+
# host, improving speed (both install and build due to the rspack cache) and ensuring
6464
# the host copy stays in sync (for people that switch back and forth between UI-only
6565
# and full stack Treeherder development).
6666
working_dir: /app
6767
environment:
6868
BACKEND: http://backend:8000
69-
command: sh -c "yarn && yarn start --host 0.0.0.0"
69+
command: sh -c "corepack enable && corepack prepare [email protected] --activate && pnpm install && pnpm start --host 0.0.0.0"
7070
volumes:
7171
- .:/app
7272
ports:

docker/Dockerfile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
## Frontend stage
2-
FROM node:22.11.0 AS frontend
2+
FROM node:22-slim AS frontend
33

44
WORKDIR /app
55

6+
# Install pnpm
7+
RUN corepack enable && corepack prepare [email protected] --activate
8+
69
COPY ui/ /app/ui/
7-
COPY package.json babel.config.json webpack.config.js yarn.lock /app/
10+
COPY package.json rspack.config.js pnpm-lock.yaml .npmrc /app/
811

9-
RUN npm install -g --force [email protected]
10-
RUN yarn install
11-
RUN yarn build
12+
RUN pnpm install --frozen-lockfile
13+
RUN pnpm build
1214

1315

1416
## Backend stage
@@ -38,7 +40,7 @@ RUN python manage.py collectstatic --noinput
3840
# WhiteNoise can then serve in preference to the originals. This is required
3941
# since WhiteNoise's Django storage backend only gzips assets handled by
4042
# collectstatic, and so does not affect files in the `.build/` directory
41-
# since they are instead generated by webpack.
43+
# since they are instead generated by rspack.
4244
RUN python -m whitenoise.compress .build
4345

4446
RUN groupadd --gid 9500 treeherder && \

docs/backend_tasks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ docker-compose run backend bash
1616

1717
...which saves having to wait for docker-compose to spin up for every test run.
1818

19-
`yarn build` will generate a `.build` directory which will be seen within the `backend` container.
20-
If you don't have `yarn` working on your host you can run this instead `docker-compose run frontend sh -c "yarn && yarn build"`
19+
`pnpm build` will generate a `.build` directory which will be seen within the `backend` container.
20+
If you don't have `pnpm` working on your host you can run this instead `docker-compose run frontend sh -c "corepack enable && pnpm install && pnpm build"`
2121

2222
Then run the individual tools within that shell, like so:
2323

docs/code_style.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Javascript in the [Installation section](installation.md#validating-javascript))
88

99
Prettier is also used to format JSON/CSS/HTML/Markdown/YAML. However these are not supported
1010
by ESLint, so instead are validated using Prettier's CLI. To manually check their formatting
11-
(as well as that of JS/JSX) using Prettier, run `yarn format:check`, or to apply formatting
12-
fixes run `yarn format`.
11+
(as well as that of JS/JSX) using Prettier, run `pnpm format:check`, or to apply formatting
12+
fixes run `pnpm format`.
1313

1414
However we recommend that you instead
1515
[add Prettier to your editor/IDE](https://prettier.io/docs/en/editors.html)

docs/common_tasks.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ The docs will then be available at: <http://localhost:8000>
1818

1919
## Updating package.json
2020

21-
- Always use `yarn` to make changes, not `npm`, so that `yarn.lock` remains in sync.
22-
- Add new packages using `yarn add <PACKAGE>` (`yarn.lock` will be automatically updated).
23-
- After changes to `package.json` use `yarn install` to install them and automatically update `yarn.lock`.
24-
- For more details see the [Yarn documentation].
21+
- Always use `pnpm` to make changes, not `npm`, so that `pnpm-lock.yaml` remains in sync.
22+
- Add new packages using `pnpm add <PACKAGE>` (`pnpm-lock.yaml` will be automatically updated).
23+
- After changes to `package.json` use `pnpm install` to install them and automatically update `pnpm-lock.yaml`.
24+
- For more details see the [pnpm documentation].
2525

26-
[yarn documentation]: https://yarnpkg.com/en/docs/usage
26+
[pnpm documentation]: https://pnpm.io/cli/add
2727

2828
## Debugging Tools
2929

docs/installation.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ From here on, linting checks will be executed every time you commit.
2828

2929
To get started:
3030

31-
- Install [Node.js] and [Yarn] (see [package.json] for known compatible versions, listed under `engines`).
32-
- Run `yarn install` to install all dependencies.
33-
- Run `yarn build` to build necessary files.
31+
- Install [Node.js] and [pnpm] (see [package.json] for known compatible versions, listed under `engines` and `packageManager`).
32+
- Run `pnpm install` to install all dependencies.
33+
- Run `pnpm build` to build necessary files.
3434

3535
### Running the standalone development server
3636

@@ -40,7 +40,7 @@ production site. You do not need to set up the Docker environment unless making
4040
- Start the development server by running:
4141

4242
```bash
43-
yarn start
43+
pnpm start
4444
```
4545

4646
<!-- prettier-ignore -->
@@ -54,7 +54,7 @@ production site. You do not need to set up the Docker environment unless making
5454
To run the unminified UI with data from the staging site instead of the production site, type:
5555

5656
```bash
57-
yarn start:stage
57+
pnpm start:stage
5858
```
5959

6060
## Server and Full-stack Development
@@ -81,7 +81,7 @@ export those env variables in the shell first or inline with the command below.
8181

8282
- Visit <http://localhost:5000> in your browser (NB: not port 8000).
8383

84-
Both Django's runserver and webpack-dev-server will automatically refresh every time there's a change in the code.
84+
Both Django's runserver and rspack-dev-server will automatically refresh every time there's a change in the code.
8585
Proceed to [Running the ingestion tasks](#running-the-ingestion-tasks) to get data.
8686

8787
### Using the minified UI
@@ -91,7 +91,7 @@ If you would like to use the minified production version of the UI with the deve
9191
- Run the build task:
9292

9393
```bash
94-
docker-compose run frontend sh -c "yarn && yarn build"
94+
docker-compose run frontend sh -c "corepack enable && pnpm install && pnpm build"
9595
```
9696

9797
- Start Treeherder's backend:
@@ -102,7 +102,7 @@ If you would like to use the minified production version of the UI with the deve
102102

103103
- Visit <http://localhost:8000> (NB: port 8000, unlike above)
104104

105-
Requests to port 8000 skip webpack-dev-server, causing Django's runserver to serve the
105+
Requests to port 8000 skip rspack-dev-server, causing Django's runserver to serve the
106106
production UI from `.build/` instead. In addition to being minified and using the
107107
non-debug versions of React, the assets are served with the same `Content-Security-Policy`
108108
header as production.
@@ -224,6 +224,6 @@ Continue to **Working with the Server** section after looking at the [Code Style
224224
[git]: https://git-scm.com
225225
[treeherder repo]: https://github.com/mozilla/treeherder
226226
[node.js]: https://nodejs.org/en/download/current/
227-
[yarn]: https://yarnpkg.com/en/docs/install
227+
[pnpm]: https://pnpm.io/installation
228228
[package.json]: https://github.com/mozilla/treeherder/blob/master/package.json
229229
[settings]: https://github.com/mozilla/treeherder/blob/master/treeherder/config/settings.py#L318

0 commit comments

Comments
 (0)