Home for the new vite-based OpenComponents templates. This monorepo contains templates and tools for building OpenComponents (OC) micro frontends using modern JavaScript frameworks and Vite.
Create a new OpenComponent using the interactive CLI:
npm create oc@latestOr specify the component name and template directly:
npm create oc@latest my-component --template react- Node.js version 20 or higher
- npm or yarn package manager
The create-oc CLI supports the following templates:
Template ID: es6
A lightweight template using vanilla JavaScript with TypeScript support. Perfect for simple components without framework overhead.
Features:
- TypeScript support
- Minimal dependencies
- Fast build times
- OC server development mode
Template ID: react
Full-featured React template with modern development tools and testing setup.
Features:
- React 18.3.1 with TypeScript
- ESLint configuration
- Vitest for testing
- React Testing Library
- Hot module replacement
- Production-ready build configuration
Template ID: solid
Template using SolidJS for high-performance reactive components.
Features:
- SolidJS framework
- TypeScript support
- Reactive state management
- Small bundle size
Template ID: preact
Lightweight alternative to React with the same API but smaller footprint.
Features:
- Preact framework
- React-compatible API
- Smaller bundle size
- TypeScript support
Template ID: vue
Vue.js template for building components with the Vue ecosystem.
Features:
- Vue 3 Composition API
- TypeScript support
- Single File Components
- Vite configuration
Template ID: svelte
Svelte template for compile-time optimized components.
Features:
- Svelte framework
- Compile-time optimization
- TypeScript support
- Minimal runtime
Template ID: elm
Functional programming template using the Elm language.
Features:
- Elm language support
- Functional programming paradigm
- Strong type system
- No runtime exceptions
Template ID: esm
Experimental template using ES modules with modern JavaScript features.
Features:
- Native ES modules
- Modern JavaScript
- Experimental features
- Beta status
Each generated component follows a consistent structure:
my-component/
โโโ package.json # Component configuration and dependencies
โโโ src/
โ โโโ server.ts # Server-side data fetching logic
โ โโโ App.tsx # Main component (React example)
โ โโโ styles.css # Component styles
โโโ public/ # Static assets
โโโ tsconfig.json # TypeScript configuration
โโโ vite.config.ts # Vite build configuration
src/server.ts: Contains the server-side logic for data fetching and processingsrc/App.tsx(or equivalent): The main component template filepackage.json: Includes OC-specific configuration in theocfieldpublic/: Static assets that will be served alongside the component
After creating a component:
-
Install dependencies:
cd my-component npm install -
Start development server:
npm start # or npm run dev -
Build for production:
npm run build
-
Run tests (where available):
npm test
Each template includes an oc configuration in package.json:
{
"oc": {
"files": {
"data": "src/server.ts",
"template": {
"src": "src/App.tsx",
"type": "oc-template-react"
},
"static": ["public"]
}
}
}data: Server-side data fetching logictemplate.src: Main component filetemplate.type: Template renderer typestatic: Static asset directories
This monorepo includes the following template renderer packages:
| Template | Package | Version |
|---|---|---|
| ES6/Vanilla | oc-template-es6 |
|
| React | oc-template-react |
|
| Preact | oc-template-preact |
|
| Solid | oc-template-solid |
|
| Vue | oc-template-vue |
|
| Svelte | oc-template-svelte |
|
| Elm | oc-template-elm |
|
| ESM | oc-template-esm |
| Package | Description | Version |
|---|---|---|
create-oc |
CLI tool for scaffolding components | |
oc-server |
Development server for OC components | |
oc-vite |
Vite integration for OpenComponents | |
oc-vite-compiler |
Vite-based compiler for OC templates |
Templates are configured to load framework dependencies from CDN in production:
- React: Loaded from unpkg.com with global
ReactandReactDOM - Vue: Loaded from unpkg.com with global
Vue - Solid: Bundled with the component
- Other frameworks: Various CDN configurations
This approach reduces bundle sizes and allows for better caching across components.
This is a monorepo managed with Turbo. To contribute:
- Clone the repository
- Install dependencies:
npm install - Make your changes
- Test across templates
- Submit a pull request
MIT