Skip to content

fix: ReferenceError in production builds from qrcodegen namespace emi… - #622

Merged
LGLabGreg merged 3 commits into
mainfrom
fix/production-build-crash-621
Sep 8, 2026
Merged

fix: ReferenceError in production builds from qrcodegen namespace emi…#622
LGLabGreg merged 3 commits into
mainfrom
fix/production-build-crash-621

Conversation

@LGLabGreg

@LGLabGreg LGLabGreg commented Sep 8, 2026

Copy link
Copy Markdown
Owner

…t (#621)

Convert the vendored qrcodegen library from TypeScript namespaces to plain ES module exports and target ES2020 in the library build. The namespace merge emit (let t; … t ||= ns.QrCode ||= {}) was mis-compiled by consumers' minifiers when down-levelling to ES2020, dropping the declaration and throwing ReferenceError: l is not defined at load time.

Claude-Session: https://claude.ai/code/session_013HWYkRT6siHoTpX2cAYLoU

Summary by CodeRabbit

  • Bug Fixes

    • Fixed a production-build crash that could occur when bundlers processed QR code generation code.
    • Improved compatibility with modern build tools by publishing output targeting ES2020.
  • Documentation

    • Added documentation describing the production-build issue and the updated module format.

#621)

Convert the vendored qrcodegen library from TypeScript namespaces to plain
ES module exports and target ES2020 in the library build. The namespace
merge emit (`let t; … t ||= ns.QrCode ||= {}`) was mis-compiled by
consumers' minifiers when down-levelling to ES2020, dropping the
declaration and throwing `ReferenceError: l is not defined` at load time.

Claude-Session: https://claude.ai/code/session_013HWYkRT6siHoTpX2cAYLoU
@vercel

vercel Bot commented Sep 8, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
reactqrcode-com Ready Ready Preview Sep 8, 2026 5:21pm UTC

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Warning

Review limit reached

Next included review available in 41 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 53dc27cd-6c4d-4b6a-8ef2-239e483b7666

📥 Commits

Reviewing files that changed from the base of the PR and between 0fdbcd5 and 3765be7.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • .github/workflows/ci.yml
  • package.json
  • packages/react-qr-code/package.json
  • packages/react-qr-code/scripts/smoke-test.mjs
  • pnpm-workspace.yaml

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 724ab9a0-33e6-4354-8ce5-2a249c78ecc8

📥 Commits

Reviewing files that changed from the base of the PR and between 56c8085 and 0fdbcd5.

📒 Files selected for processing (7)
  • .changeset/fix-production-build-crash.md
  • packages/react-qr-code/src/constants.ts
  • packages/react-qr-code/src/hooks/use-qr-code.tsx
  • packages/react-qr-code/src/lib/qrcodegen/README.md
  • packages/react-qr-code/src/lib/qrcodegen/index.ts
  • packages/react-qr-code/src/types/lib.ts
  • packages/react-qr-code/vite.config.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

The QR code generator was converted from a TypeScript namespace default export to named ES module exports. Consumers and types now use those exports. The Vite build targets ES2020, and documentation records the production-build crash fix.

Changes

QR code build fix

Layer / File(s) Summary
Convert qrcodegen to named exports
packages/react-qr-code/src/lib/qrcodegen/index.ts
QrCode, QrSegment, Ecc, and Mode are now named exports. Encoding logic remains unchanged.
Update consumer and type wiring
packages/react-qr-code/src/constants.ts, packages/react-qr-code/src/hooks/use-qr-code.tsx, packages/react-qr-code/src/types/lib.ts
Imports, QR code calls, and type declarations now reference named exports.
Set build target and document release
packages/react-qr-code/vite.config.ts, packages/react-qr-code/src/lib/qrcodegen/README.md, .changeset/fix-production-build-crash.md
The library targets ES2020. Documentation and the changeset record the production crash fix.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 0fdbc

The QR generator now uses ES module exports and ships an ES2020-targeted build to prevent the documented production load-time crash. Consumer wiring and error-correction behavior remain aligned, with no outstanding merge-readiness risk identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: fixing the production-build ReferenceError caused by qrcodegen namespace emit.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 5 files. (2 skipped: 2 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/production-build-crash-621

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit sees exports stand clear,
No hidden namespace bugs appear.
The QR paths hop in ES2020 light,
Minifiers now keep the code right.
Four named classes lead the way,
And production builds can safely stay.

Comment @coderabbitai help to get the list of available commands.

Run dist/index.es.js through esbuild (pinned to 0.28.1, the last release
that reproduces #621) at es2015/es2020/es2022/esnext, then execute each
result by rendering a QR code with react-dom/server. Guards against
consumer bundlers mis-compiling the shipped output.

Claude-Session: https://claude.ai/code/session_013HWYkRT6siHoTpX2cAYLoU
Parse dist/index.es.js with acorn at ecmaVersion 2020. If the bundle
contains only ES2020 syntax, no consumer bundler has to down-level it,
which rules out the #621 class of bug independently of any minifier's
version. esbuild is unpinned and the Dependabot ignore is removed.

Claude-Session: https://claude.ai/code/session_013HWYkRT6siHoTpX2cAYLoU
@LGLabGreg
LGLabGreg merged commit 5eb4dc9 into main Sep 8, 2026
5 checks passed
@LGLabGreg
LGLabGreg deleted the fix/production-build-crash-621 branch September 8, 2026 17:46
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.

1 participant