Registry / web-framework / mini-star

mini-star

JSON →
library2.1.8jsnpmunverified

mini-star is a robust frontend micro-kernel framework, bundler, and loader designed to help projects implement a plugin-based architecture. It facilitates the independent development and deployment of features as separate plugins. The library, currently at version 2.1.8, supports TypeScript natively and is framework-agnostic, meaning it can be integrated with React, Vue, Angular, jQuery, or other modern web frameworks. Key differentiators include its bundler for building AMD-based plugins, automatic processing of plugin and dependency paths, dynamic asynchronous module loading to optimize project size, and a powerful mechanism for sharing common dependencies across all plugins, reducing boilerplate and bundle size. Unlike `requirejs`, `mini-star` operates at a module level, aligning with modern frontend practices, and it distinguishes itself from micro-frontend solutions like `qiankun` by prioritizing dependency reuse and an isomorphic technology stack rather than isolation for heterogeneous applications. It offers a complete toolchain encompassing CLI, runtime, and bundler functionalities. The project appears to have an active development and maintenance cadence, with recent documentation updates indicating ongoing support.

npm install mini-star
INSTALL
IMPORT
SIG · MINI-STAR
M
mini-star
web-frameworkjavascriptv2.1.8
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MiniStar
import { MiniStar } from 'mini-star';
const MiniStar = require('mini-star');
The `MiniStar` class is the primary entry point for the runtime, enabling plugin loading and management. CommonJS `require` syntax is not recommended for modern usage and may lead to issues with ESM-only builds since v2.
MiniStarConfig
import type { MiniStarConfig } from 'mini-star';
To ensure type safety when configuring the `MiniStar` instance, import `MiniStarConfig` for the configuration object. TypeScript types are shipped with the package.
Plugin
import type { Plugin } from 'mini-star';
When defining or interacting with plugin structures, import the `Plugin` type to leverage TypeScript's type-checking capabilities for plugin interfaces.

This quickstart demonstrates how to initialize `mini-star`, register shared dependencies like React and ReactDOM, and dynamically load a plugin. It shows basic configuration, error handling, and how a plugin's exposed methods can be invoked.

import { MiniStar } from 'mini-star'; interface MyPluginInstance { render: (selector: string) => void; // ... other methods/properties exposed by the plugin } async function initializeMiniStar() { const ministar = new MiniStar({ // Optional: Configure base path for plugins, e.g., for local development or CDN base: '/plugins/', // Optional: Global error handler for plugin loading failures errorHandler: (error, pluginName) => { console.error(`Failed to load plugin ${pluginName}:`, error); } }); // Register shared dependencies that plugins might use, preventing duplication // This should be done before loading plugins that depend on them. ministar.registerShared('react', window.React || require('react')); ministar.registerShared('react-dom', window.ReactDOM || require('react-dom')); console.log('Shared dependencies registered.'); try { // Load a plugin by its registered name or path const myPlugin = await ministar.loadPlugin<MyPluginInstance>('my-plugin-entry'); console.log('Plugin loaded successfully:', myPlugin); // Assume the plugin exports a render function if (myPlugin && typeof myPlugin.render === 'function') { myPlugin.render('#app-root'); console.log('Plugin rendered to #app-root'); } } catch (error) { console.error('Error during plugin loading or rendering:', error); } } // Ensure React and ReactDOM are available globally for demonstration if not bundled // In a real app, these would be proper imports in your host application (window as any).React = require('react'); (window as any).ReactDOM = require('react-dom'); initializeMiniStar();
mini-star --version
Debug
Known issues
gotchaEnsure all shared dependencies are registered with `ministar.registerShared()` *before* attempting to load any plugins that rely on those dependencies. Failing to do so will result in runtime errors within the plugin due to missing globals.
fix
Call `ministar.registerShared('dependencyName', dependencyObject);` for all common libraries (e.g., React, Vue, lodash) in your host application's initialization phase, prior to any `ministar.loadPlugin()` calls.
affects: >=1.0.0
gotchaPlugin path resolution can be tricky, especially when moving between development and production environments. Relative paths or incorrect `base` configuration in `MiniStar` can lead to 'Plugin not found' errors.
fix
Thoroughly test plugin loading paths. For production, consider using absolute URLs or a CDN-based `base` path in `MiniStar` configuration. Ensure your bundler outputs plugins to the expected location and that the host application can access them.
affects: >=1.0.0
breaking`mini-star` has moved towards a modern module approach. Older CommonJS `require()` patterns for the main `mini-star` library itself might not work as expected or could lead to compatibility issues in projects configured for ESM.
fix
Always use `import { ... } from 'mini-star';` for consuming the `mini-star` library in your host application. Ensure your project's build setup (e.g., Webpack, Rollup) correctly handles ESM.
affects: >=2.0.0
gotchaWhen a plugin fails to load or execute, `mini-star`'s default error handling might be generic. Implementing a custom `errorHandler` in `MiniStarConfig` is crucial for better diagnostics in production.
fix
Provide a custom `errorHandler` function in the `MiniStar` constructor options to log detailed information, capture stack traces, or report to an error monitoring service, enabling quicker debugging of plugin issues.
affects: >=1.0.0
Errors
Common errors & fixes
Uncaught ReferenceError: React is not defined
A plugin attempted to use `React` but it was not globally available or registered as a shared dependency with `mini-star`.
fix
Ensure `React` (and other global dependencies) are properly imported and then registered using `ministar.registerShared('react', React);` in the host application before any plugins are loaded.
Error: Plugin 'my-plugin-name' not found or failed to load. (Network error, or script parsing error)
The specified plugin script could not be fetched from the `base` URL or parsed correctly due to network issues, incorrect path, or syntax errors in the plugin bundle.
fix
Verify the `base` path in `MiniStar` configuration. Check the network tab in browser dev tools for 404s on the plugin URL. Ensure the plugin's bundle is correctly built and accessible at the expected location.
TypeScript Error: Property 'render' does not exist on type 'Plugin'
The loaded plugin object does not match the expected interface, often because the plugin itself does not correctly expose the `render` method or the TypeScript type assertion is incorrect.
fix
Ensure your plugin's entry file explicitly exports the `render` function (or whatever methods you expect). If using TypeScript, cast the loaded plugin to its specific interface: `await ministar.loadPlugin<MyPluginInterface>('my-plugin');`
Upgrade
Version history
2.1.8latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
mini-star — npm install mini-star · libregistry