Skip to content

Commit ba3632e

Browse files
committed
chore: migrate dependency management to pnpm
Replace the root and demo npm lockfiles with a single committed pnpm-lock.yaml and add pnpm-workspace.yaml covering the root package, subpackages, test/ts, and demo. Pin packageManager to pnpm@11.1.0 and move the Volta Node pin to 24.15.0 so the repository runs on a Node version supported by pnpm 11. Enable pnpm supply-chain hardening in workspace config: strict minimum release age, no-downgrade trust policy, blocked exotic transitive dependencies, strict dependency builds, engine strictness, and an explicit install-script allowBuilds policy. Keep trust-policy exceptions narrow and version-specific for chokidar@4.0.3, preact-render-to-string@6.5.0, reselect@5.1.1, and semver@6.3.1 instead of using a broad age-based bypass. Allow only esbuild build scripts and explicitly deny optional/native watcher or compatibility scripts for @parcel/watcher, fsevents, and styled-components. Update CI and developer workflows for pnpm: use pnpm/action-setup@v6, pnpm cache keys, frozen installs, pnpm script invocations, pnpm exec for the Husky hook, and pnpm contributor docs. Declare nano-staged as a dev dependency because pnpm exec requires hook tools to be local instead of relying on npx to fetch them. Keep npm pack and npm publish behavior intact for the package release path. Tighten dependency declarations exposed by pnpm's isolated linker: add demo's explicit sass-embedded dependency for SCSS builds, pin Vite resolutions that were previously coming from npm lockfiles, pin the direct undici dev dependency, and update @actions/github and @actions/glob dev tooling to current versions to avoid older trust-downgrade transitive resolution. Verification run: pnpm install --frozen-lockfile; pnpm ignored-builds; pnpm run build; pnpm run lint; pnpm run test:unit; pnpm --dir demo run build; npm pack --ignore-scripts --dry-run --json. Also ran pnpm run format:check, which still fails on existing repository-wide formatting and CRLF diagnostics unrelated to this migration.
1 parent 7d8929f commit ba3632e

12 files changed

Lines changed: 8358 additions & 12392 deletions

.github/workflows/build-test.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,22 @@ jobs:
2626
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2727
with:
2828
ref: ${{ inputs.ref || '' }}
29-
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
29+
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
30+
with:
31+
run_install: false
32+
- uses: actions/setup-node@v4
3033
with:
3134
node-version-file: 'package.json'
32-
- run: npm ci
35+
cache: 'pnpm'
36+
cache-dependency-path: pnpm-lock.yaml
37+
- run: pnpm install --frozen-lockfile
3338
- name: test
3439
env:
3540
CI: true
3641
COVERAGE: true
3742
FLAKEY: false
38-
# Not using `npm test` since it rebuilds source which npm ci has already done
39-
run: npm run lint && npm run test:unit
43+
# Not using `pnpm test` since it rebuilds source which install has already done
44+
run: pnpm run lint && pnpm run test:unit
4045
- name: Coveralls GitHub Action
4146
uses: coverallsapp/github-action@643bc377ffa44ace6394b2b5d0d3950076de9f63 # v2.3.0
4247
timeout-minutes: 2

.github/workflows/run-bench.yml

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: Benchmark Worker
44
#
55
# This workflow expects calling workflows to have uploaded an artifact named
66
# "bench-environment" that contains any built artifacts required to run the
7-
# benchmark. This typically is the dist/ folder that running `npm run build`
7+
# benchmark. This typically is the dist/ folder that running `pnpm run build`
88
# produces and/or a tarball of a previous build to bench the local build against
99

1010
on:
@@ -34,29 +34,16 @@ jobs:
3434
- uses: actions/checkout@v4
3535
with:
3636
submodules: 'recursive'
37-
- uses: actions/setup-node@v4
38-
with:
39-
node-version-file: 'package.json'
40-
cache: 'npm'
41-
cache-dependency-path: '**/package-lock.json'
42-
43-
# Setup pnpm
44-
- name: Install pnpm
45-
uses: pnpm/action-setup@v3
37+
- uses: pnpm/action-setup@v6
4638
with:
47-
version: 8
4839
run_install: false
49-
- name: Get pnpm store directory
50-
id: pnpm-cache
51-
run: |
52-
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
53-
- uses: actions/cache@v4
54-
name: Setup pnpm cache
40+
- uses: actions/setup-node@v4
5541
with:
56-
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
57-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
58-
restore-keys: |
59-
${{ runner.os }}-pnpm-store-
42+
node-version-file: 'package.json'
43+
cache: 'pnpm'
44+
cache-dependency-path: |
45+
pnpm-lock.yaml
46+
benchmarks/pnpm-lock.yaml
6047
6148
# Install benchmark dependencies
6249
- uses: actions/download-artifact@v4
@@ -119,4 +106,4 @@ jobs:
119106
with:
120107
name: ${{ steps.log-artifact-name.outputs.artifact_name }}
121108
path: benchmarks/out/${{ inputs.benchmark }}_logs.tgz
122-
if-no-files-found: ignore
109+
if-no-files-found: ignore

.github/workflows/size.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v4
11+
- uses: pnpm/action-setup@v6
12+
with:
13+
run_install: false
1114
- uses: actions/setup-node@v4
1215
with:
1316
node-version-file: 'package.json'
14-
cache: 'npm'
15-
cache-dependency-path: '**/package-lock.json'
17+
cache: 'pnpm'
18+
cache-dependency-path: pnpm-lock.yaml
1619
- uses: preactjs/compressed-size-action@v2
1720
with:
1821
repo-token: '${{ secrets.GITHUB_TOKEN }}'
1922
# Our `prepare` script already builds the app post-install,
2023
# building it again would be redundant
21-
build-script: 'npm run --if-present noop'
24+
build-script: 'pnpm run --if-present noop'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.DS_Store
22
node_modules
33
npm-debug.log
4+
package-lock.json
45
dist
56
*/package-lock.json
67
yarn.lock

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
npx nano-staged
1+
pnpm exec nano-staged

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ These steps will help you set up your development environment. That includes all
88

99
1. Clone the git repository: `git clone git@github.com:preactjs/preact.git`
1010
2. Go into the cloned folder: `cd preact/`
11-
3. Install all dependencies: `npm install`
11+
3. Install all dependencies: `pnpm install`
1212

1313
## The Repo Structure
1414

@@ -100,7 +100,7 @@ The short summary is:
100100

101101
## Commonly used scripts for contributions
102102

103-
Scripts can be executed via `npm run [script]`.
103+
Scripts can be executed via `pnpm run [script]`.
104104

105105
- `build` - compiles all packages ready for publishing to npm
106106
- `build:core` - builds just Preact itself
@@ -142,7 +142,7 @@ it.only('should test something', () => {
142142

143143
## Benchmarks
144144

145-
We have a benchmark suite that we use to measure the performance of Preact. Our benchmark suite lives in our [preactjs/benchmarks repository](https://github.com/preactjs/benchmarks), but is included here as Git submodule. To run the benchmarks, first ensure [PNPM](https://pnpm.io/installation) is installed on your system and initialize and setup the submodule (it uses `pnpm` as a package manager):
145+
We have a benchmark suite that we use to measure the performance of Preact. Our benchmark suite lives in our [preactjs/benchmarks repository](https://github.com/preactjs/benchmarks), but is included here as Git submodule. To run the benchmarks, first ensure [pnpm](https://pnpm.io/installation) is installed on your system and initialize and setup the submodule:
146146

147147
```bash
148148
pnpm -v # Make sure pnpm is installed
@@ -212,13 +212,13 @@ Before using the automated npm publishing flow, make sure npm trusted publishing
212212
> **ATTENTION:** Make sure that you've cleared the project correctly
213213
> when switching from a 10.x branch.
214214
215-
0. Run `rm -rf dist node_modules && npm i` to make sure to have the correct dependencies.
215+
0. Run `rm -rf dist node_modules && pnpm install` to make sure to have the correct dependencies.
216216
1. [Write the release notes](#writing-release-notes) and keep them as a draft in GitHub
217217
1. I'd recommend writing them in an offline editor because each edit to a draft will change the URL in GitHub.
218218
2. Make a PR where **only** the version number is incremented in `package.json` (note: We follow `SemVer` conventions)
219219
3. Wait until the PR is approved and merged.
220220
4. Switch back to the `main` branch and pull the merged PR
221-
5. Run `npm run build && npm publish`
221+
5. Run `pnpm run build && npm publish`
222222
1. Make sure you have 2FA enabled in npm, otherwise the above command will fail.
223223
2. If you're doing a pre-release add `--tag next` to the `npm publish` command to publish it under a different tag (default is `latest`)
224224
6. Publish the release notes and create the correct git tag.

0 commit comments

Comments
 (0)