import { createLazyComponent } from '@closure-next/core';
const MyLazyComponent = createLazyComponent(() => import('./MyComponent'));
// Usage
const component = await MyLazyComponent.get();
// or preload
MyLazyComponent.preload();
import { Cache, ComponentPool, ResourcePreloader } from '@closure-next/core';
// Component caching
const cache = new Cache({ maxSize: 100, ttl: 5 * 60 * 1000 });
cache.set('myComponent', component);
// Component pooling
const pool = new ComponentPool(50);
const component = pool.acquire();
pool.release(component);
// Resource preloading
const preloader = new ResourcePreloader();
await preloader.preloadScript('/path/to/script.js');
import { createBundleConfig, defaultChunks } from '@closure-next/core';
const config = createBundleConfig({
chunks: defaultChunks,
minChunkSize: 20000,
maxAsyncRequests: 30
});
For detailed framework integration guides, see: - React Integration Guide - Vue Integration Guide - Angular Integration Guide - Svelte Integration Guide
For detailed SSR implementation details, see: - SSR Guide
The core package (@closure-next/core) provides the foundation for all framework integrations:
import { Component, DomHelper } from '@closure-next/core';
class MyComponent extends Component {
protected override createDom(): void {
this.element = this.domHelper.createElement('div');
this.element.textContent = 'Hello World';
}
}
Each framework integration package provides framework-specific bindings:
// React
import { ClosureComponent } from '@closure-next/react';
<ClosureComponent component={MyComponent} />
// Vue
import { ClosureComponent } from '@closure-next/vue';
<closure-component :component="MyComponent" />
// Angular
import { ClosureModule } from '@closure-next/angular';
<closure-component [component]="MyComponent"></closure-component>
// Svelte
import { ClosureComponent } from '@closure-next/svelte';
<ClosureComponent component={MyComponent} />
Performance-critical operations are optimized using WebAssembly:
import { useWasmDom } from '@closure-next/wasm';
const { createElement, appendChild } = useWasmDom();
const element = createElement('div');
appendChild(container, element);
Server-side rendering is implemented with progressive hydration:
// Server
const html = await renderToString(MyComponent);
// Client
await hydrateComponent(MyComponent, container);
Comprehensive testing utilities are provided:
import { createTestComponent } from '@closure-next/testing';
const component = createTestComponent(MyComponent);
await simulateEvent(component.getElement(), 'click');