@@ -3,7 +3,6 @@ description: Build system and package management standards for LFX UI Core
33globs: tsconfig.json,package.json,src/scripts/**/*,**/package.json
44alwaysApply: false
55---
6-
76# Build System Standards for LFX UI Core
87
98## Package.json Standards
@@ -14,14 +13,18 @@ alwaysApply: false
1413- Set appropriate package metadata (author, license, etc.)
1514
1615## Build Script Guidelines
17- - `build:tokens`: Generate design tokens from source
18- - `build:browser`: Create browser-compatible bundles
19- - `build`: Full build including formatting and TypeScript compilation
16+ - `build:tokens`: Generate design tokens from source using TypeScript
17+ - `build:browser`: Create browser-compatible bundles for web components
18+ - `build`: Full build including tokens, formatting, TypeScript compilation, and browser bundles
2019- `format`: Run Prettier on all source files
20+ - `start`: Alias for Storybook development server
21+ - `storybook`: Start Storybook development server on port 6006
22+ - `build-storybook`: Build static Storybook for deployment
2123- Scripts should be idempotent and handle failures gracefully
2224
2325## TypeScript Configuration
2426- Target ES2020 for modern browser support
27+ - Use CommonJS module system for Node.js compatibility
2528- Enable strict mode for better type safety
2629- Generate declaration files for TypeScript consumers
2730- Configure proper rootDir and outDir
@@ -36,40 +39,85 @@ dist/
3639├── index.js # Main entry point
3740├── index.d.ts # TypeScript declarations
3841├── components/ # Component exports
39- ├── browser/ # Browser bundles
40- └── design/ # Generated tokens
42+ ├── browser/ # Browser bundles for web components
43+ ├── design/ # Generated tokens and presets
44+ └── core/ # Core configurations (prettier, etc.)
4145```
4246
4347### Export Configuration
4448- Main entry: CommonJS for Node.js compatibility
4549- Module entry: ES modules for bundlers
46- - Browser field: Browser-optimized builds
47- - Separate exports for components and configurations
50+ - Separate exports for components, prettier-config, and design tokens
51+ - Browser bundles available in dist/browser/ directory
4852
4953## Token Build Process
50- 1. Read source tokens from `src/design/tokens/`
51- 2. Transform using build scripts in `src/scripts/`
52- 3. Generate platform-specific outputs (CSS, JS, JSON)
53- 4. Output to `dist/design/` with proper file structure
54+ 1. Read source tokens from `src/design/tokens/tokens.json`
55+ 2. Transform using TypeScript build scripts in `src/scripts/`
56+ 3. Generate platform-specific outputs (TypeScript modules)
57+ 4. Create hierarchical token structure (primitive → semantic → component)
58+ 5. Generate preset configurations for easy consumption
59+ 6. Output to `dist/design/` with proper file structure
5460
5561## Browser Bundle Guidelines
5662- Use Browserify with TypeScript plugin (tsify)
57- - Create separate bundles for each major component
58- - Minify production bundles
63+ - Create separate bundles for each web component
64+ - Extract component information from components index
65+ - Generate browser-compatible bundles in `dist/browser/`
5966- Include source maps for development
67+ - Support both individual component and full library consumption
68+
69+ ## Storybook Integration
70+ - Use Storybook 8.4.5 with web-components-vite framework
71+ - Configure for web components and MDX documentation
72+ - Enable autodocs for automatic documentation generation
73+ - Include essential addons: links, interactions, and essentials
74+ - Support both development and static build workflows
75+
76+ ## Package Manager
77+ - Use npm as the primary package manager
78+ - Maintain package-lock.json for dependency locking
79+ - Configure proper peerDependencies for external tools
80+ - Use exact versions for critical dependencies
81+
82+ ## File Organization
83+ ```
84+ src/
85+ ├── components/ # Web components
86+ ├── core/ # Core configurations and utilities
87+ ├── design/ # Design tokens and presets
88+ └── scripts/ # Build and utility scripts
89+ ```
90+
91+ ## Quality Checks
92+ - Run Prettier formatting before build
93+ - Validate TypeScript compilation
94+ - Check for missing exports
95+ - Verify package.json structure
96+ - Test bundle integrity
97+ - Validate Storybook build
6098
61- ## Version Management
62- - Follow semantic versioning (semver)
63- - Use git tags for version releases
64- - Automate version bumping in CI/CD
65- - Update CHANGELOG.md with each release
99+ ## Performance Considerations
100+ - Use tree-shaking friendly exports
101+ - Minimize bundle sizes
102+ - Avoid including unnecessary dependencies
103+ - Optimize token generation for large token sets
104+ - Support incremental builds
105+
106+ ## Publishing Workflow
107+ 1. Run full build and tests
108+ 2. Update version number
109+ 3. Generate changelog
110+ 4. Create git tag
111+ 5. Publish to npm registry
112+ 6. Update documentation
113+ 7. Deploy Storybook static build
66114
67- ## File Inclusion
68- Only include necessary files in the published package:
69- - `dist/` directory with built assets
70- - `README.md ` for documentation
71- - `LICENSE ` for legal requirements
72- - Exclude source files, tests, and development configs
115+ ## Development Workflow
116+ - Use `npm start` for Storybook development
117+ - Use `npm run build` for full production build
118+ - Use `npm run format ` for code formatting
119+ - Use `npm run build:tokens ` for token-only builds
120+ - Use `npm run build:browser` for component-only builds
73121
74122## Example Build Script Structure
75123```typescript
@@ -95,23 +143,21 @@ async function build() {
95143build();
96144```
97145
98- ## Quality Checks
99- - Run Prettier formatting before build
100- - Validate TypeScript compilation
101- - Check for missing exports
102- - Verify package.json structure
103- - Test bundle integrity
146+ ## Browser Build Process
147+ ```typescript
148+ // src/scripts/build-browser.ts
149+ function buildBrowser(): void {
150+ const components = extractComponents();
104151
105- ## Performance Considerations
106- - Use tree-shaking friendly exports
107- - Minimize bundle sizes
108- - Avoid including unnecessary dependencies
109- - Optimize token generation for large token sets
152+ for (const component of components) {
153+ buildComponent(component);
154+ }
155+ }
156+ ```
110157
111- ## Publishing Workflow
112- 1. Run full build and tests
113- 2. Update version number
114- 3. Generate changelog
115- 4. Create git tag
116- 5. Publish to npm registry
117- 6. Update documentation
158+ ## Token Generation Process
159+ - Parse `tokens.json` source file
160+ - Generate TypeScript modules for each token category
161+ - Create preset configurations for easy consumption
162+ - Maintain type safety throughout the process
163+ - Support hierarchical token relationships
0 commit comments