You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This occurs when trying to retrieve example source code for components in monorepo configurations after integrating doc-core into the organization structure.
Context: Related Fixes
This is related to but NOT a duplicate of issue #118:
Configure content entries pointing to packages with example files
Access an example endpoint: /api/v6/components/alert/react/examples/AlertDynamicLiveRegion
Observe ENOENT error when the code tries to resolve the example file path
Completion Criteria
The issue is resolved when:
Example files are successfully resolved in monorepos: The API endpoint can locate and return example source code when running in a monorepo configuration
Package-aware path resolution: Import paths are resolved using the content configuration's package base paths rather than naive filesystem relative paths
Backward compatibility maintained: Non-monorepo setups continue to work without regression
Problem Summary
The example file API endpoint (
/api/v6/components/{component}/{tab}/examples/{example}) fails in monorepo setups with the error:This occurs when trying to retrieve example source code for components in monorepo configurations after integrating doc-core into the organization structure.
Context: Related Fixes
This is related to but NOT a duplicate of issue #118:
Issue Monorepos are not properly supported #118 (Fixed in PR fix(cli): support monorepos #136, v1.13.1): Fixed monorepo support at the CLI level by implementing package discovery that walks up the directory tree to find
node_modulesin monorepo structuresCommit 9fd87fb (PR fix(API): address issues with text API in monorepos #185): Fixed monorepo issues in the text API endpoint by adding fallback tab handling
Current Issue Example file API fails in monorepos #213: The examples API endpoint still uses naive path resolution and needs the same monorepo-aware treatment
Steps to Reproduce
/api/v6/components/alert/react/examples/AlertDynamicLiveRegionCompletion Criteria
The issue is resolved when:
Technical Notes
The issue is in
src/pages/api/[version]/[section]/[page]/[tab]/examples/[example].ts:114Current implementation uses
resolve(contentEntryFilePath, '../', cleanFilePath)which doesn't understand monorepo package structureThe
content.tsfile already contains absolutebasepaths to packages (generated by the CLI's monorepo-aware package discovery)Import paths in MDX files use relative paths that work in bundler context but not in raw filesystem resolution
Related Links
Related issue: Monorepos are not properly supported #118 (Monorepos are not properly supported) - CLOSED
Jira: PF-3601
Fix for CLI monorepo support: PR fix(cli): support monorepos #136 (commit 33f76fb)
Fix for text API monorepo issues: PR fix(API): address issues with text API in monorepos #185 (commit 9fd87fb)
Impact
This blocks the use of the examples API in monorepo configurations, preventing retrieval of example source code for documentation.
Jira Issue: PF-3601