Dependency patches
Dependency patches
A patch on a dependency carries an upstream fix that is not released yet. It lives in patches/, is listed in package.json under patchedDependencies, and bun install applies it. Each one is temporary: it goes as soon as a release has the fix.
Current patches
| Package | Why | Upstream | Remove when |
|---|---|---|---|
@tanstack/react-router@1.170.41 | Firefox and Safari cancel a pending route chunk when the page starts to unload, with the same message as a missing chunk. lazyRouteComponent took that for a stale deploy and reloaded, so a full navigation (a typed address, a plain link, the Stripe checkout redirect) put the user back on the page they were leaving. | Issue TanStack/router#8827, PR TanStack/router#8830 | A release contains PR #8830 |
The react-router patch is PR #8830 applied to the built files (dist/esm and dist/cjs), with two additions from its review. A page-wide flag, set at the first beforeunload and cleared by pageshow, pointerdown or keydown, also covers an import that starts after beforeunload, which PR #8830 alone missed in about one run in three. The retry after the page stays clears only the error it was made for. A bare beforeunload listener does not keep the page out of the back/forward cache in modern browsers (web.dev/articles/bfcache, 2026-10-16). Proof: RunMist's e2e/tests/workspace/onboarding.spec.ts on webkit failed "onboarding page redirects to dashboard if already complete" every time without the patch, 3 times in 10 with PR #8830 alone, and passed 40 of 40 tests over 10 runs with the patch as it is.
bun install does not check a patch
Checked on 2026-11-24 with bun 1.4.3:
- An upgrade of the patched package installs the new version unpatched, with no warning and exit code 0.
- A patch whose context no longer matches the file still applied, with no error.
So scripts/dependency-patches.test.ts, part of bun test, checks every entry in patchedDependencies: the installed version is the patched one, and every line the patch adds is in the installed file. A failing first test after an upgrade means the patch was dropped: check whether the new release has the upstream fix, then delete the patch or redo it.
Adding or removing one
- Add:
bun patch <package>, edit the files undernode_modules/<package>,bun patch --commit 'node_modules/<package>'. Add a row above with the upstream issue and pull request, and name both in the commit message. - Remove: delete the file in
patches/and itspatchedDependenciesentry,bun install, and delete the row above. - Both ship to the other apps: the patch file and this doc through
make template.push, thepackage.jsonentry throughmake template.port.