manic dev

Development server via bun --watch on ~manic.ts, plugin bunfig, and config hot reload.

manic dev

manic dev is the local development entry point. It does not embed the whole server in the CLI process—it spawns Bun with --watch on your ~manic.ts file so filesystem changes reload the server.

Implementation: packages/manic/src/cli/commands/dev.ts.


Lifecycle

Initializing diagram...

What runs

After loadConfig():

  1. bunfig.toml — Aggregates plugin.bunfig strings from manic.config.ts. [serve.static].plugins arrays from multiple plugins are merged into one section; everything else is appended. File starts with # Auto-generated by manic dev — do not edit. Skip writing if there is nothing to emit besides the header.

  2. Child process:

    bun --watch [--preload <absolute-plugin-preload.ts> ...] ~manic.ts

    Each plugins[].preload becomes two argv tokens: --preload and the plugin script path.

PieceResolved pathPurpose
Entry file~manic.ts at repo rootYour createManicServer bootstrap
Preloadsplugins[].preload absolute pathsBun executes --preload before ~manic.ts
  1. Environment passed to the child:

    VariableMeaning
    PORT--port / -p, else config.server.port, else 6070
    HOST0.0.0.0 if --network, else localhost
    NETWORKtrue or false
  2. Config watch — If manic.config.ts or manic.config.js exists at the repo root, fs.watch debounces (100ms) kill + respawn after re-importing the config module so plugins and bunfig stay in sync.


Fast Refresh & HMR

React Fast Refresh is driven by the OXC transform pipeline injected during dev transforms (see oxc plugin). Behavior matches standard Fast Refresh expectations (preserve state where possible).

Toggle server.hmr in manic.config.ts if you disable HMR at the framework level (not a manic dev --no-hmr flag—the CLI does not define one).


View transitions

Controlled by router.viewTransitions in manic.config.ts (and runtime setViewTransitions). There is no manic dev --no-view-transitions switch.


CLI flags (supported today)

FlagRole
-p, --portSets PORT for the spawned bun process (see CLI Overview for server.port vs PORT).
--networkNETWORK=true, HOST=0.0.0.0.

Global manic --help documents all commands.


Plugin preloads

Plugins may declare preload so Bun executes them before ~manic.ts:

// manic.config.ts
import { defineConfig } from 'manicjs/config';

export default defineConfig({
  plugins: [
    {
      name: 'my-plugin',
      preload: `${process.cwd()}/plugins/my-plugin-preload.ts`,
    },
  ],
});

The dev command expands each preload into --preload flags automatically.


See also

On this page