fix: resolve local Fern preview component imports#772
Conversation
|
Fern preview: https://nvidia-preview-pr-772.docs.buildwithfern.com/nemo/datadesigner
|
Code Review — PR #772: fix: resolve local Fern preview component importsSummaryThis PR fixes the local Fern docs fallback preview so that custom component imports like The fix replaces the wholesale
Scope: 1 file, +21/-0. Structural risk: LOW (dev-tooling script, outside the three FindingsCorrectness
Code Quality & Style
Performance
Test Coverage
Security
Structural Impact(graphify, 2.2s) Risk: LOW (localized change)
VerdictApprove with a minor optional suggestion. The fix is correct for the common case, well-scoped, and matches project conventions. The only substantive item is the unguarded extensionless-alias |
johnnygreco
left a comment
There was a problem hiding this comment.
Nice work on this one, @andreatgretel — this is a tidy fix for a pretty awkward local-preview edge case.
Summary
This PR updates the local Fern fallback preview so components/ is materialized as a temporary tree with symlinked source files and extensionless aliases for JS/TS component imports. The implementation matches the PR description and keeps the change scoped to the fallback preview path.
Findings
No findings.
What Looks Good
- The change preserves the existing temp-root symlink behavior for non-
components/entries, so the fix stays nicely localized. - The extensionless aliases cover both top-level components like
Authors.tsxand nested data modules likedevnotes/deep-research-trajectories/example-marcia.ts. - The same-stem directory guard from the follow-up commit avoids the collision raised in the earlier review thread without complicating the common path.
Verdict
Ship it — ready to merge as-is.
This review was generated by an AI assistant.
Summary
@/components/Authors.components/tree and add extensionless symlinks for.js,.jsx,.ts, and.tsxfiles.Context
The local fallback preview path was added so docs can still be served when the hosted
nvidiaFern theme is unavailable. That path builds a temporary Fern root, removesglobal-theme: nvidia, and points Fern at the temporary root.The temporary root previously symlinked
components/as a whole. That preserved the source files, but Fern's local renderer can resolve imports like@/components/Authorsas an extensionless file path. In the real tree, the file iscomponents/Authors.tsx, so local preview could render pages withFailed to render this contenteven though the component file existed.This keeps the fallback preview behavior local to the temp root: component files are still symlinked from the source tree, and extensionless aliases are added only in the generated preview directory.
Testing
.venv/bin/ruff check --fix fern/scripts/serve-local-docs-preview.py.venv/bin/ruff format fern/scripts/serve-local-docs-preview.py.venv/bin/python fern/scripts/serve-local-docs-preview.py --root fern -- test -L components/Authorscomponents/Foo/pluscomponents/Foo.tsxmake check-fern-docs-locally- 0 errors, 1 existing warning