Commit 69539d6
committed
fix: 2FA setup and /tools/qr-code-generator crash on v5.2.1
v5.2.1 bumped vite ^7.3.1 -> ^8.0.7, which switched the default
bundler from Rollup to Rolldown. Rolldown emits a different __toESM
interop helper for default imports of CJS modules. With isNodeMode=1
(used for default imports), the helper unconditionally writes
synth.default = wholeModule even when the source has its own
`default` export, so:
import QRCode from 'react-qr-code'
resolves to the whole module object
{ __esModule, default: fn, QRCode: fn } instead of the component, and
<QRCode /> ends up as createElement(<object>, ...) which throws React
#130. The follow-up #418 hydration warning is React's recovery path
remounting the tree.
react-qr-code only ships a CJS entry (no `module:` or `exports:` field
in its package.json), and its CJS entry is interop-CJS shaped:
Object.defineProperty(exports, '__esModule', { value: true });
exports.QRCode = X;
exports.default = X;
Switching to the named import bypasses the broken interop because
Rolldown does not emit __toESM for named CJS imports - the consumer
just gets the module exports namespace and reads .QRCode directly.
The lib's .d.ts only declares the default export, so there's a small
module augmentation in app/types.d.ts to expose the
existing-but-undeclared QRCode named export to TypeScript.
Same fix is needed in web/app/routes/tools.qr-code-generator.tsx,
which has the same import shape and crashes when typing into the
input.
Verified by inspecting the rebuilt user-settings chunk:
- before: jsx(oi.default, { value }) with oi = __toESM(\$qrLib(), 1)
- after: jsx(oi.QRCode, { value }) with oi = \$qrLib()1 parent 108aa6d commit 69539d6
3 files changed
Lines changed: 26 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
0 commit comments