feat: Add Angular Material-style barrel modules for better DX#148
feat: Add Angular Material-style barrel modules for better DX#148
Conversation
Possible awesome-ci commands for this Pull Request
Need more help? Have a look at my repo This message was created by awesome-ci and can be disabled by the env variable |
There was a problem hiding this comment.
Pull Request Overview
This PR introduces Angular Material-style barrel modules to simplify component imports. Instead of importing 10+ individual components, developers can now import a single barrel module (e.g., FsNavFrameModule) and spread it into the imports array. The implementation uses readonly component arrays following Angular Material's proven pattern while maintaining full backward compatibility.
Key Changes
- Created three barrel modules:
FsNavFrameModule(12 components/directives),FsCalendarModule(3 components/directives), andFsThemeMenuModule(3 components) - Updated peer dependencies in library package.json from Angular 19 to Angular 20
- Demonstrated usage in lib-workspace by reducing imports from 13 individual components to 2 barrel modules
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| projects/ngx-mat-components/src/fs-theme-menu/public-api.ts | Exports new FsThemeMenuModule barrel module |
| projects/ngx-mat-components/src/fs-theme-menu/fs-theme-menu.module.ts | Creates barrel module with 3 theme menu components |
| projects/ngx-mat-components/src/fs-nav-frame/public-api.ts | Exports new FsNavFrameModule barrel module |
| projects/ngx-mat-components/src/fs-nav-frame/fs-nav-frame.module.ts | Creates barrel module with 12 nav frame components/directives |
| projects/ngx-mat-components/src/fs-calendar/public-api.ts | Exports new FsCalendarModule barrel module |
| projects/ngx-mat-components/src/fs-calendar/fs-calendar.module.ts | Creates barrel module with 3 calendar components |
| projects/ngx-mat-components/package.json | Updates peer dependencies from Angular 19 to 20 |
| projects/lib-workspace/src/app/app.ts | Demonstrates barrel module usage with spread operator |
| .github/copilot-instructions.md | Adds documentation for managing peer dependencies during Angular upgrades |
Comments suppressed due to low confidence (5)
projects/ngx-mat-components/src/fs-theme-menu/fs-theme-menu.module.ts:1
- The example shows direct import of
FsThemeMenuModule, but the actual usage pattern requires spreading the array with...FsThemeMenuModule. This inconsistency between documentation and implementation could confuse developers. Update the example to showimports: [...FsThemeMenuModule]to match the actual usage pattern demonstrated in app.ts.
import { FsThemeMenu } from './fs-theme-menu';
projects/ngx-mat-components/src/fs-nav-frame/fs-nav-frame.module.ts:1
- The example shows direct import of
FsNavFrameModule, but the actual usage requires spreading the array with...FsNavFrameModule. This inconsistency between documentation and implementation could confuse developers. Update the example to showimports: [...FsNavFrameModule]to match the actual usage pattern demonstrated in app.ts.
/**
projects/ngx-mat-components/src/fs-calendar/fs-calendar.module.ts:1
- The example shows direct import of
FsCalendarModule, but the actual usage requires spreading the array with...FsCalendarModule. This inconsistency between documentation and implementation could confuse developers. Update the example to showimports: [...FsCalendarModule]to match the actual usage pattern demonstrated in app.ts.
/**
projects/ngx-mat-components/src/fs-nav-frame/fs-nav-frame.module.ts:1
- The example shows direct import of
FsNavFrameModule, but the actual usage requires spreading the array with...FsNavFrameModule. This inconsistency between documentation and implementation could confuse developers. Update the example to showimports: [...FsNavFrameModule]to match the actual usage pattern demonstrated in app.ts.
/**
projects/ngx-mat-components/src/fs-calendar/fs-calendar.module.ts:1
- The example shows direct import of
FsCalendarModule, but the actual usage requires spreading the array with...FsCalendarModule. This inconsistency between documentation and implementation could confuse developers. Update the example to showimports: [...FsCalendarModule]to match the actual usage pattern demonstrated in app.ts.
/**
Summary
Introduces barrel modules (readonly component arrays) following Angular Material's proven pattern to drastically improve developer experience. Instead of importing 10+ individual components, developers can now use single barrel module imports.
Motivation
Problem: Using ngx-mat-components required importing many individual components/directives:
Solution: Angular Material-style barrel modules for clean imports:
Changes Made
New Barrel Modules
FsNavFrameModule(fs-nav-frame/fs-nav-frame.module.ts)FsCalendarModule(fs-calendar/fs-calendar.module.ts)FsThemeMenuModule(fs-theme-menu/fs-theme-menu.module.ts)Implementation Pattern
Updated Public APIs
fs-nav-frame/public-api.ts- Exports FsNavFrameModule and FS_NAV_FRAME_COMPONENTSfs-calendar/public-api.ts- Exports FsCalendarModule and FS_CALENDAR_COMPONENTSfs-theme-menu/public-api.ts- Exports FsThemeMenuModule and FS_THEME_MENU_COMPONENTSTesting
lib-workspace/src/app/app.tsto use barrel modulesBenefits
Better Developer Experience
Type Safety
as constensures readonly arraysTree-Shakable
Backward Compatible
Consistent with Ecosystem
Migration Guide
No action required! This is a non-breaking feature addition.
To adopt barrel modules (recommended):
Documentation
CHANGELOG-local.mdwith complete feature documentationChecklist
Related Issues
Resolves internal DX improvement initiative.
🏷️ Version Bump
From: 20.0.0 (Angular 20 migration)
To: 20.1.0 (Minor feature release)
Semver Reasoning: