Repository navigation
fix: allow importing the bundle without a DOM - #210
Conversation
The webpack build picked the browser build of react-textarea-autosize, which reads document at import time. Bundle its default build instead, which checks for document first. Fixes microlinkhq#149 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@theluckystrike is attempting to deploy a commit to the Microlink Team on Vercel. A member of the Team first needs to authorize it. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughWebpack now resolves ChangesSSR bundle import
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The change lets the bundle be imported without a DOM by using the default build of react-textarea-autosize. No actionable merge-blocking risk remains. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change is narrowly scoped to server-compatible bundle loading. No new privileged capability or boundary bypass was identified. Verification remains limited because the exact dependency entry and generated bundle were unavailable. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Awesome, thanks! |
|
@Kikobeats, thanks for merging both. Since #210 changed how the bundle loads, #146 looks like the right next one, where the default import comes back as a module object under Vite 8 and you'd asked for a PR. I'll check what #142 changed in package.json first. Then I'll send the smallest fix a test can prove. Thank you, |
|
@Kikobeats, thanks for merging #210. Requiring the package in Node no longer throws "document is not defined", so Next.js and other SSR setups can import it, and that closed #149. It's my third merged change here, after #102 back in March and #211 the same morning.
More of what I work on is at https://github.com/theluckystrike. Even a small one-time sponsorship at https://github.com/sponsors/theluckystrike would tell me the time on these fixes was appreciated, and I'd gladly keep sending more to react-json-view. Totally fine if not.
Thank you,
Michael Lip
Founder of https://zovo.one, 108 Chrome extensions with 150,000+ users
Also building https://makeroll.com and https://ml0x.com, open-source guardrails for Claude Code agents
Open source has to win, and small fixes like this one are my part of it
|
Fixes #149
What
require('@microlink/react-json-view')throwsReferenceError: document is not definedin Node. So the package breaks during SSR, for example in Next.js.Why
dist/main.jsis built with webpack for the web target. Forreact-textarea-autosize, webpack picks its browser build. That build runs this line when the module loads:The package also ships a default build that checks
typeof document !== 'undefined'first. That one works in both Node and the browser.How
One alias in
webpack/webpack.config.jspointsreact-textarea-autosizeat its default build. Nothing insrcchanges. In the browser it behaves the same. The minified bundle grows from 110501 to 112002 bytes.Tests
New test
test/tests/js/Bundle-test.jsbuilds the bundle with the real webpack config. Then it runs it in a freshvmcontext with nowindowordocument.Before the fix:
After the fix the full suite passes, 204 tests. I also checked the built
dist/main.jsby hand on Node 25:require('./dist/main.js')worksrenderToStringof<ReactJsonView src={{ a: 1 }} />returns HTMLimport('./index.mjs')worksstandardreports no new findings on the changed files.Summary by CodeRabbit