Repository navigation
Conversation
Problem: On Node 21+, every cloudflare-worker test fails before running with "TypeError: Cannot set property navigator of #<Object> which has only a getter". Root Cause: Node 21 added a global `navigator` defined as a getter with no setter. `Object.assign(global, makeServiceWorkerEnv())` tries to assign the mock's `navigator` and throws. Solution: Delete the global `navigator` before `Object.assign`, which then installs the mock's `navigator` as it did on Node 18. The property is configurable, so the delete succeeds; on Node 18 it does not exist and the delete does nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem: On Node 22+, `yarn build` fails for donate-button-v4 with "Can't resolve 'src/autoPlayMode'", and 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 "Function.prototype.apply was called on undefined" on Node 22+. preact-cli then falls back to its default config without the `src/` alias. preact-cli is no longer developed and recommends Vite. Solution: Build v4 with Vite 8 and @preact/preset-vite. - index.html at the package root is the demo page and the build entry; Vite serves it in development with hot reload and swaps its script for the built index.js. - Bundle as a classic IIFE named index.js, copied to button.js. - Use the Vercel deployment URL as the asset base in production builds and "/" otherwise. - Keep the MD4 icon names preact-cli gave, and target ES2015 as the old bundle did. - Move src/assets to public/assets, which Vite copies to assets/. - Resolve src/ imports from tsconfig, parse the version with semver, and bump v4 Prettier to 3.0 for JSON import attributes. - Set engines.node, .tool-versions, and CI to Node 24. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
johnemau
added this pull request to stack #469
October 8, 2026 14:28
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
johnemau
commented
Oct 8, 2026
| 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'); |
Contributor
Author
There was a problem hiding this comment.
This is removed in
There was a problem hiding this comment.
🟡 Changes recommended
The non-Vercel production asset base generates broken URLs for assets published through assets.every.org.
1 open finding
What changed in this PR
Migrates donate-button v4 from Preact CLI to Vite 8 and standardizes the repository on Node 24.
Changes:
- Adds Vite-based v4 builds with legacy-compatible output and asset hashing.
- Updates assets and dependencies for Vite.
- Updates Node tooling, CI, and worker-test compatibility.
| File | Description |
|---|---|
.github/workflows/ci.yml |
Runs CI with Node 24. |
.tool-versions |
Selects Node 24.16.0. |
package.json |
Requires Node 24. |
packages/cloudflare-worker/test/_setup.ts |
Removes Node’s getter-only navigator before mocking. |
packages/donate-button-v4/index.html |
Adds the Vite module entry. |
packages/donate-button-v4/package.json |
Replaces Preact CLI scripts and dependencies with Vite. |
packages/donate-button-v4/preact.config.js |
Removes the obsolete Webpack configuration. |
packages/donate-button-v4/public/assets/close.svg |
Moves the close icon into Vite’s public tree. |
packages/donate-button-v4/public/assets/logo.svg |
Moves the logo into Vite’s public tree. |
packages/donate-button-v4/vite.config.mjs |
Configures output layout, target, base URL, and asset hashing. |
yarn.lock |
Records the Vite dependency graph and removes Preact CLI packages. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+16
to
+18
| base: process.env.VERCEL_URL | ||
| ? `https://${process.env.VERCEL_URL}/${VERSION_SLUG}/` | ||
| : '/', |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Move donate-button-v4 to Vite 8 and the repo to Node 24 so v4 builds on Node 22+.
Replaces
Problem
yarn buildfails on Node 22 and 24:Can't resolve 'src/autoPlayMode'.Cannot set property navigator of #<Object> which has only a getter.Root Cause
esmloader fails on Node 22+, dropping thesrc/alias.Function.prototype.applyerror.Solution
@preact/preset-vite; see docs: Add notice forcreact-preactpreactjs/preact-cli#1808.VERCEL_URL) as the asset base for production builds and/otherwise.--openssl-legacy-providerand retain the ES2015 target.navigatorbefore worker tests assignservice-worker-mockglobals.engines.node,.tool-versions, and CI to Node 24.Visual check
yarn devBoth screenshots were captured at 1280×800 after clicking "Donate".
They are byte-identical, so both columns use the same hosted image.
Build output
button.js(Vercel, gzip)~3K savings by moving from babel to rollup bundlers (preact-cli -> vite)
🤖 Generated with Claude Code