How jolacdev/template-react-component-library works
Main Components
• Source Code & Components:
– Highlight the “src” folder as the heart of the project. Under “src” are the “components” directory (which holds individual component folders such as Button and Input) and a top-level index to export them.
• Build & Bundling System:
– Mark the TypeScript (tsconfig.json and tsconfig.build.json), Vite configuration (vite.config.ts), and the build scripts as the pipeline that compiles TypeScript with tsc and bundles the code using Vite. Also note the use of plugins like vite-plugin-dts for generating declaration files and vite-plugin-lib-inject-css for CSS injection.
• Documentation & Storybook:
– Include the “.storybook” directory, which configures Storybook to provide isolated component documentation and an interactive environment. Also, the __docs__ subdirectories in components (e.g., Button/__docs__) hold MDX and stories files.
• Testing Framework:
– Represent the “Vitest” configuration details (from setupTests.ts and scripts in package.json) that run tests for each component found in __test__ folders.
• Code Quality & Development Tools:
– Include configuration for ESLint (eslint.config.js and eslint.constants.mjs) and Prettier (.prettierrc.mjs) that enforce code consistency and linting. The setup for Git hooks (lefthook.yml) for runnning format and lint tasks before commits should also be noted.
• Continuous Integration/Deployment:
Relationships and Interactions
• “Build Process” to “Distribution Output” (e.g., dist directory mentioned in package.json) which makes the library ready for publishing.
• An interaction from “Source Code” to both “Testing” (Vitest, React Testing Library) and “Documentation (Storybook)” since tests and stories are generated based on the component code.
• Link “Code Quality” tools (ESLint, Prettier, and Git Hooks) to the “Source Code” module to indicate that all commits and code edits are automatically checked and formatted.
Architectural Patterns and Important Design Principles
• That there is a modular structure that supports both a full-library export and individual component exports (evidenced by the exports structure in package.json and the generation of multiple entry points in vite.config.ts).
• The separation of concerns is clearly seen: components are separated, documentation is maintained close to components, and build/test/integration scripts are isolated in dedicated folders (.github, .storybook).
• Design patterns like “component isolation” (Storybook), “fail-fast” in Git hooks (lefthook), and “automation” in CI/CD pipelines.
Tools, Frameworks, and Technologies
• Core Frameworks: React (with JSX/TSX) and TypeScript.
• Build Tools: Vite (with vite-plugin-dts and vite-plugin-lib-inject-css).
• Testing: Vitest and React Testing Library, with environment simulated by jsdom.
• Code Quality: ESLint and Prettier configurations along with Git hooks (Lefthook).
• CI/CD: GitHub Actions orchestrate CI (lint, test, build) and CD (release generation with semantic-release).
• Documentation: Storybook configured for dynamic component showcasing through MDX and TSX stories.
• For each module, break down the sub-components (e.g., within “Source” show individual components with folders like Button and Input).