Skip to content

Build donate button v4 with Vite - #468

Open
johnemau wants to merge 2 commits into
mainfrom
john-with-claude/node-24-donate-testing-80be4e
Open

johnemau wants to merge 2 commits into
mainfrom
john-with-claude/node-24-donate-testing-80be4e

Conversation

@johnemau

@johnemau johnemau commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Move donate-button-v4 to Vite 8 so we can drop preact-cli

Replaces

Problem

  • yarn build fails on Node 22 and 24: Can't resolve 'src/autoPlayMode'.
  • Node 21+ breaks cloudflare-worker tests: Cannot set property navigator of #<Object> which has only a getter.

Root Cause

  • preact-cli's archived esm loader fails on Node 22+, dropping the src/ alias.
  • preact-cli#1821 reports the same Function.prototype.apply error.

Solution

  • Build v4 with Vite 8 and @preact/preset-vite; see docs: Add notice for creact-preact preactjs/preact-cli#1808.
  • Move assets to root and public/assets to match Vite defaults.
  • Use the Vercel deployment URL (VERCEL_URL) as the asset base for production builds and / otherwise.
  • Preserve MD4 icon names with --openssl-legacy-provider and retain the ES2015 target.
  • Delete the getter-only global navigator before worker tests assign service-worker-mock globals.
  • Set engines.node, .tool-versions, and CI to Node 24.

Visual check

Both screenshots were captured at 1280×800 after clicking "Donate".
They are byte-identical, so both columns use the same hosted image.

View Before After
Demo page widget Before: live demo donation widget After: yarn dev donation widget

Build output

vite build output
button.js (Vercel, gzip) Before (bytes) After (bytes) Change (bytes)
Live → PR preview 53,648 49,920 −3,728

~3K savings by moving from babel to rollup bundlers (preact-cli -> vite)

🤖 Generated with Claude Code

@vercel

vercel Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
donate-button Ready Ready Preview Oct 16, 2026 10:38pm UTC

Request Review

@socket-security

socket-security Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedvite@​8.3.4991008296100
Added@​preact/​preset-vite@​2.10.69910010092100

View full report

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');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnemau
johnemau marked this pull request as ready for review October 8, 2026 16:39
Copilot AI balanced review requested due to automatic review settings October 8, 2026 16:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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}/`
: '/',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds real?

@johnemau johnemau changed the title Build donate button v4 with Vite and move to Node 24 Build donate button v4 with Vite Oct 16, 2026
@johnemau
johnemau force-pushed the john-with-claude/node-24-donate-testing-80be4e branch from 6e6f03b to 1431928 Compare October 16, 2026 17:03
johnemau and others added 2 commits October 16, 2026 15:35
preact-cli 3.5.0 is archived and only builds on Node 24 through a patch that bypasses its `esm` config loader. Vite builds the same IIFE bundle to dist/donate-button/0.4 with the VERCEL_URL asset base, so the preact-cli patch, its postinstall, and preact.config.js are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem: Without VERCEL_URL, `yarn build` emitted icon URLs as `/<hash>.svg`. The bundle checked into docs/ runs on third-party pages, so those URLs resolve against the host page and the crypto icons break.

Root Cause: The Vite `base` fallback was `/`, while preact.config.js used `https://assets.every.org/dist/donate-button/0.4/` for non-Vercel production builds.

Solution: Restore the assets.every.org base for non-Vercel builds and keep `/` for the dev server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@johnemau
johnemau force-pushed the john-with-claude/node-24-donate-testing-80be4e branch from 7c561c0 to d47a729 Compare October 16, 2026 22:36

This branch was successfully deployed

1 active deployment
Preview — d47a7293 Deployed Oct 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants