refactor(website): client-safe SITE_ORIGIN leaf module#577
Merged
Conversation
site-metadata.ts transitively imports lib/blog (Node fs), so it can't be imported from 'use client' components. Extract SITE_ORIGIN into a leaf module (site-origin.ts) with no fs-tainted imports; re-export it from site-metadata; import it in PageActions instead of the inline duplicate. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
A bare `export { SITE_ORIGIN } from './site-origin'` re-export creates no
local binding, but getCanonicalUrl() uses SITE_ORIGIN internally — `next
build` failed with "Cannot find name 'SITE_ORIGIN'". Import then export.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix the root cause behind the
PageActionsinline workaround:lib/site-metadata.tstransitively importslib/blog.ts(import fs from 'fs'), so it can't be imported from any'use client'component (breaks the client bundle with "Module not found: Can't resolve 'fs'").apps/website/src/lib/site-origin.tsexporting justSITE_ORIGIN(nofs-tainted imports).site-metadata.tsnow re-exportsSITE_ORIGINfrom it (server importers likelayout.tsxandblog/rss.xml/route.tsare unaffected).PageActions.tsximports from the leaf module and drops the inline duplicate + keep-in-sync comment.Test Plan
PageActions.spec.tsx— 2/2e2e/docs.spec.ts— 8/8eslinton changed files — clean/docs/langgraph/guides/streamingreturns HTTP 200 (client bundle compiles, nofserror)🤖 Generated with Claude Code