LARC Package Guide
Complete guide to choosing the right LARC Core package for your needs.
๐ Package Comparison
| Feature | @larcjs/core-lite | @larcjs/core | core-lite + routing + debug | |---------|-------------------|--------------|----------------------------| | Bundle Size (minified) | 9KB โ | 40KB | 20KB | | Pub/Sub Messaging | โ | โ | โ | | Retained Messages | โ | โ | โ | | Request/Reply | โ | โ | โ | | Dynamic Routing | โ | โ | โ (8KB add-on) | | Debug/Tracing | โ | โ | โ (3KB add-on) | | Rate Limiting | โ | โ | โ | | Message Validation | โ | โ | โ | | Statistics | โ | โ | โ | | LRU Cache | โ | โ | โ | | Zero Dependencies | โ | โ | โ |
๐ฏ Which Package Should I Use?
Use @larcjs/core-lite (9KB)
โ Perfect for:
- Production applications prioritizing bundle size
- Simple pub/sub messaging needs
- Component communication without complex routing
- Projects that don't need debugging tools in production
- Add
@larcjs/core-debugonly in development builds - Upgrade to full version if routing becomes necessary
- 78% smaller than full version
npm install @larcjs/core-lite
<script type="module" src="https://unpkg.com/@larcjs/core-lite@latest/src/pan.js"></script>
Use @larcjs/core (40KB)
โ Perfect for:
- Applications needing dynamic routing
- Development environments with debugging enabled
- Complex message flows with transforms and predicates
- Teams wanting batteries-included solution
- Ideal for rapid prototyping
- Use when bundle size isn't the primary concern
- Includes all features out of the box
npm install @larcjs/core
<pan-bus enable-routing="true" debug="true"></pan-bus>
Use ร La Carte (core-lite + add-ons)
โ Perfect for:
- Fine-grained control over bundle size
- Need routing OR debug, but not both
- Conditional loading based on environment
- Optimizing production vs development builds
- Use core-lite as base (9KB)
- Add
@larcjs/core-routing(8KB) only if needed - Add
@larcjs/core-debug(3KB) only in dev builds
npm install @larcjs/core-lite
npm install --save-dev @larcjs/core-debug
npm install @larcjs/core-routing # if routing needed
// Production
import '@larcjs/core-lite';
// Development only
if (process.env.NODE_ENV === 'development') {
await import('@larcjs/core-debug');
}
๐ฆ Package Details
@larcjs/core-lite
Size: 9KB minified (3KB gzipped) Includes:pan.mjs(autoloader) - 3.6KBpan-bus-lite.mjs(message bus) - 3.0KBpan-client.mjs(client API) - 2.0KBpan-storage.mjs(optional persistence) - 3.2KB
- Landing pages with minimal JavaScript
- Component libraries
- Micro-frontends
- Mobile-first applications
- No dynamic routing
- No debug/tracing tools
- No rate limiting
- No message size validation
- Simple retained message storage (no LRU)
@larcjs/core
Size: 40KB minified (12KB gzipped) Includes:- Everything in core-lite
pan-routes.mjs(routing system) - 8.3KBpan-debug.mjs(debug manager) - 3.0KB- Rate limiting & security features
- Message size validation
- Statistics tracking
- LRU cache for retained messages
- Complex applications
- Admin dashboards
- Development environments
- Applications with sophisticated message flows
- Batteries included
- No additional setup
- Full feature set
- Lazy-loads routing/debug when enabled
@larcjs/core-routing
Size: 8.3KB minified (3KB gzipped) Add to: core-lite Provides:- Declarative route definitions
- Pattern matching with predicates
- Message transformations
- Multiple action types (EMIT, LOG, FORWARD, CALL)
- Runtime route management
- Performance statistics
- Need conditional message routing
- Want to decouple routing logic from components
- Implementing feature flags via routing
- Building analytics pipelines
- Need transform/enrich messages
import '@larcjs/core-lite';
import '@larcjs/core-routing';
window.pan.routes.add({
name: 'Route VIP Orders',
match: {
type: 'order.created',
where: { op: 'gte', path: 'payload.total', value: 1000 }
},
actions: [
{ type: 'EMIT', message: { type: 'alert.vip-order' } }
]
});
@larcjs/core-debug
Size: 3.0KB minified (1KB gzipped) Add to: core-lite Provides:- Message tracing and history
- Performance metrics
- State snapshots (export/import)
- Timeline visualization
- Filtering by topic patterns
- Development environment
- Debugging complex message flows
- Profiling performance
- Capturing state for bug reports
- Integration with
// Only in development
if (process.env.NODE_ENV === 'development') {
await import('@larcjs/core-debug');
window.pan.debug.enableTracing();
}
๐ Migration Between Packages
From core-lite to core
npm uninstall @larcjs/core-lite
npm install @larcjs/core
Code changes: None required! API is identical.
From core to core-lite
npm uninstall @larcjs/core
npm install @larcjs/core-lite
Check for:
- Remove
enable-routingattribute if present - Remove routing-specific code
- Remove debug-specific code
- Verify no dependencies on rate limiting or validation
Adding routing to core-lite
npm install @larcjs/core-routing
<pan-bus enable-routing="true"></pan-bus>
<script type="module">
import '@larcjs/core-lite';
import '@larcjs/core-routing';
// Now you have window.pan.routes
</script>
Adding debug to core-lite
npm install --save-dev @larcjs/core-debug
<pan-bus debug="true" enable-tracing="true"></pan-bus>
<script type="module">
import '@larcjs/core-lite';
import '@larcjs/core-debug';
// Now you have window.pan.debug
</script>
๐ฐ Cost-Benefit Analysis
Scenario 1: Simple SPA
Need: Pub/sub between 10-20 components Recommendation: @larcjs/core-lite (9KB)- Savings: 31KB vs full version
- Trade-off: None (don't need routing/debug)
- ROI: โญโญโญโญโญ
Scenario 2: Admin Dashboard
Need: Complex routing, debugging, analytics Recommendation: @larcjs/core (40KB)- Savings: None, but worth it for features
- Trade-off: Larger bundle, more capabilities
- ROI: โญโญโญโญ (worth the features)
Scenario 3: E-commerce Site
Need: Pub/sub + routing for feature flags Recommendation: core-lite + routing (17KB)- Savings: 23KB vs full version
- Trade-off: No debug in production (good!)
- ROI: โญโญโญโญโญ
Scenario 4: Component Library
Need: Minimal messaging, distributed to many apps Recommendation: @larcjs/core-lite (9KB)- Savings: 31KB, critical for libraries
- Trade-off: Users can add routing if needed
- ROI: โญโญโญโญโญ
๐ Additional Resources
- @larcjs/core - Full-featured version
- @larcjs/core-lite - Lightweight version
- @larcjs/core-routing - Routing add-on
- @larcjs/core-debug - Debug add-on
๐ค Still Unsure?
Start with @larcjs/core-lite (9KB). You can always upgrade later if you need routing or debugging. The API is identical across all packages.npm install @larcjs/core-lite
If you later need routing:
npm install @larcjs/core-routing
If you later need everything:
npm uninstall @larcjs/core-lite
npm install @larcjs/core
The modular approach saves 78% bundle size while maintaining full flexibility.