From 4582d8a7d65b7160b4c8075ac3a73661b28beda7 Mon Sep 17 00:00:00 2001 From: John Emau Date: Thu, 8 Oct 2026 11:40:38 -0700 Subject: [PATCH 1/2] Fix preact-cli config loading and worker tests on Node 24 Problem: On Node 22+, `yarn build` fails with `Can't resolve 'src/autoPlayMode'`, and cloudflare-worker tests fail with `Cannot set property navigator of # which has only a getter`. Vercel no longer builds with Node 20. Root cause: preact-cli 3.5.0 loads preact.config.js through the archived `esm` package, which throws on Node 22+; preact-cli catches the error and builds with its default config, dropping the `src/` path alias. Node 21+ defines a getter-only global `navigator`, so `Object.assign` cannot install the service-worker-mock globals. Solution: Patch preact-cli to load the config with `require` (applied by a v4 postinstall through the existing patch-package) and export the config with `module.exports`. Delete the global `navigator` before assigning the mocks. Set `engines.node` to 24.x so Vercel builds with Node 24. Co-Authored-By: Claude Opus 5.5 --- package.json | 3 +++ packages/cloudflare-worker/test/_setup.ts | 2 ++ packages/donate-button-v4/package.json | 1 + packages/donate-button-v4/patches/preact-cli+3.5.0.patch | 6 ++++++ packages/donate-button-v4/preact.config.js | 2 +- 5 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 packages/donate-button-v4/patches/preact-cli+3.5.0.patch diff --git a/package.json b/package.json index 2d657c86..69ae5fa4 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,9 @@ "postinstall": "patch-package" }, "private": true, + "engines": { + "node": "24.x" + }, "workspaces": [ "packages/cloudflare-worker", "packages/donate-button", diff --git a/packages/cloudflare-worker/test/_setup.ts b/packages/cloudflare-worker/test/_setup.ts index d7dd252c..9f18b77a 100644 --- a/packages/cloudflare-worker/test/_setup.ts +++ b/packages/cloudflare-worker/test/_setup.ts @@ -1,4 +1,6 @@ // Setup mocks for the service worker environment import makeServiceWorkerEnv = require('service-worker-mock'); declare const global: WorkerGlobalScope; +// Node 21+ defines a getter-only `navigator` that Object.assign cannot overwrite. +Reflect.deleteProperty(global, 'navigator'); Object.assign(global, makeServiceWorkerEnv()); diff --git a/packages/donate-button-v4/package.json b/packages/donate-button-v4/package.json index d5bb2067..59b528a3 100644 --- a/packages/donate-button-v4/package.json +++ b/packages/donate-button-v4/package.json @@ -9,6 +9,7 @@ "scripts": { "tsc": "tsc", "test": "echo 'no tests'", + "postinstall": "node ../../node_modules/patch-package", "build": "preact build --no-prerender --no-sw && yarn postbuild", "postbuild": "cp dist/donate-button/0.4/index.js dist/donate-button/0.4/button.js", "serve": "preact serve", diff --git a/packages/donate-button-v4/patches/preact-cli+3.5.0.patch b/packages/donate-button-v4/patches/preact-cli+3.5.0.patch new file mode 100644 index 00000000..757b1315 --- /dev/null +++ b/packages/donate-button-v4/patches/preact-cli+3.5.0.patch @@ -0,0 +1,6 @@ +diff --git a/node_modules/preact-cli/src/util.js b/node_modules/preact-cli/src/util.js +--- a/node_modules/preact-cli/src/util.js ++++ b/node_modules/preact-cli/src/util.js +@@ -69 +69 @@ +-exports.esmImport = require('esm')(module); ++exports.esmImport = require; diff --git a/packages/donate-button-v4/preact.config.js b/packages/donate-button-v4/preact.config.js index c2b4d630..8c848b69 100644 --- a/packages/donate-button-v4/preact.config.js +++ b/packages/donate-button-v4/preact.config.js @@ -53,4 +53,4 @@ const config = { }); } }; -export default config; +module.exports = config; From 4cc01f5caea5d11fcd407e6652e32126a688a11a Mon Sep 17 00:00:00 2001 From: John Emau Date: Thu, 8 Oct 2026 12:13:08 -0700 Subject: [PATCH 2/2] Run CI and local tooling on Node 24 CI installed Node 18.17.1 and .tool-versions selected Node 20.11.0, so neither exercised the Node 24 runtime declared in engines.node, where the esm config failure and the getter-only navigator occur. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 12 ++++++------ .tool-versions | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d6aa3fbf..c351efc7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,30 +11,30 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Use Node.js 18.17.1 + - name: Use Node.js 24.x uses: actions/setup-node@v1 with: - node-version: 18.17.1 + node-version: 24.x - run: yarn - run: yarn build test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Use Node.js 18.17.1 + - name: Use Node.js 24.x uses: actions/setup-node@v1 with: - node-version: 18.17.1 + node-version: 24.x - run: yarn - run: yarn test lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Use Node.js 18.17.1 + - name: Use Node.js 24.x uses: actions/setup-node@v1 with: - node-version: 18.17.1 + node-version: 24.x - run: yarn - run: yarn lint # Not currently working, always some differences diff --git a/.tool-versions b/.tool-versions index 557ea46d..bc3d15a3 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1 @@ -nodejs 20.11.0 +nodejs 24.16.0