Bundler Standalone Guide
Build your own framework/runtime on top of @manicjs/bundler without using manicjs as the framework package.
Bundler Standalone Guide
@manicjs/bundler can be used as a standalone build spine for custom frameworks, app shells, or internal platforms.
Repository: github.com/manic-js/bundler
What you get
buildApplication()pipeline orchestration (lint, client, API, server, minify, provider hooks)- bundler utility helpers (
resolver,getDirSize,countRoutes,minifyDir) - a simple CLI entrypoint (
manic-bundler build)
This lets you keep your own runtime/framework contract while reusing the same Bun + OXC build engine.
Install
bun add @manicjs/bundlerMinimal integration
Create your own build.ts (or CLI command) and call buildApplication() directly:
import { buildApplication, type PageRoute } from '@manicjs/bundler';
const config = {
mode: 'fullstack',
app: { name: 'My Framework App' },
};
await buildApplication({
config,
dist: '.dist',
runLint: true,
// Provide your own route discovery + manifest writer.
writeRoutesManifest: async () => {
// generate routes manifest for your runtime
},
discoverPageRoutes: async (): Promise<PageRoute[]> => {
// return your route table
return [];
},
clientPlugins: [],
serverPlugins: [],
plugins: [],
providers: [],
onPending: msg => console.log(`[build] ${msg}`),
onSuccess: msg => console.log(`[build] ${msg}`),
onError: msg => console.error(`[build] ${msg}`),
});Required contract
buildApplication() assumes these project-level surfaces exist (unless your hooks replace them):
- app entry:
app/main.tsx(resolved via./app/main) - server entry:
~manic.ts-style server bootstrap (or your compatible equivalent) - optional API roots:
app/api/**/index.ts
If your framework structure differs, provide compatible wrappers/hook adapters around route discovery and server entry generation.
Plugin + provider model
You can pass your own plugin/provider arrays:
plugins[]:- optional
preloadBun plugin module - optional
build(ctx)hook
- optional
providers[]:build(context)export step for deployment targets
BundlerPluginContext gives:
config,cwd,dist,prodpageRoutes,apiRoutesemitClientFile(relativePath, content)injectHtml(tags)
Safe optimization strategy
For third-party compatibility, prefer conservative defaults:
- enable client chunk splitting
- avoid blanket side-effect pruning on external packages
- keep provider builds after minification
- verify with smoke tests (
build -> start -> endpoint checks)
Smoke test checklist
- Build succeeds with no lint regressions.
- Server starts on custom port and serves root HTML.
- API catalog/OpenAPI endpoints respond (if API mode enabled).
- Dev/start shutdown only targets listener-owner process cleanup.
CLI mode
You can also drive the package with:
manic-bundler build bundler.config.tsWhere bundler.config.ts exports:
export default {
config: { mode: 'fullstack', app: { name: 'Standalone' } },
dist: '.dist',
clientPlugins: [],
serverPlugins: [],
};