|
1 | 1 | # markopack |
2 | 2 |
|
3 | | -Rspack integration packages for `@marko/run`. |
| 3 | +**Rspack integration for [`@marko/run`](https://github.com/marko-js/run)** — build Marko SSR applications using raw Rspack with zero framework overhead. |
4 | 4 |
|
5 | | -## Packages |
| 5 | +## Overview |
6 | 6 |
|
7 | | -- `@markopack/core`: shared route building/codegen/middleware utilities |
8 | | -- `@markopack/compiler`: Marko compiler plugin and loader for rspack |
9 | | -- `@markopack/rspack`: direct rspack integration with `build()` / `dev()` APIs |
10 | | -- `@markopack/adapter-node`: Node adapter |
11 | | -- `@markopack/adapter-static`: Static adapter |
12 | | -- `@markopack/adapter-netlify`: Netlify adapter |
| 7 | +markopack is a monorepo that lets you use Marko's file-based routing and SSR system with [Rspack](https://rspack.rs/) instead of Vite. Drop it into any Marko project and get the same route conventions, adapters, and hot reload you'd get from `@marko/run` — without Vite. |
13 | 8 |
|
14 | | -## Example |
15 | 9 |
|
16 | | -- `examples/rspack-basic`: runnable `@marko/run` + rspack setup |
| 10 | +## Quick Start |
| 11 | + |
| 12 | +```bash |
| 13 | +npm create markopack@latest |
| 14 | +``` |
| 15 | + |
| 16 | +The CLI will ask for a project name, adapter, and whether to use TypeScript, then scaffold and install everything for you. |
| 17 | + |
| 18 | +**Non-interactive:** |
| 19 | + |
| 20 | +```bash |
| 21 | +npm create markopack@latest my-app -- --adapter node --typescript |
| 22 | +``` |
| 23 | + |
| 24 | +Once scaffolded: |
| 25 | + |
| 26 | +```bash |
| 27 | +cd my-app |
| 28 | +npm run dev # start the dev server |
| 29 | +npm run build # production build |
| 30 | +``` |
| 31 | + |
| 32 | +## Architecture |
| 33 | + |
| 34 | +``` |
| 35 | +@markopack/core ← @markopack/compiler ← @markopack/rspack |
| 36 | + ↕ |
| 37 | + adapters (node, static, netlify) |
| 38 | +``` |
| 39 | + |
| 40 | +Every build produces two Rspack bundles coordinated by a **MultiCompiler**: |
| 41 | + |
| 42 | +- **browser** (`dist/client/`) — DOM hydration bundle, compiled with `output: "dom"` |
| 43 | +- **server** (`dist/server/`) — CJS SSR bundle, compiled with `output: "html"` |
| 44 | + |
| 45 | +`MarkoRspackPlugin` syncs dynamic entry points (one per Marko component used server-side) and the client asset manifest between the two compilers. |
| 46 | + |
| 47 | +## Route Conventions |
| 48 | + |
| 49 | +markopack inherits all `@marko/run` conventions: |
| 50 | + |
| 51 | +| File | Purpose | |
| 52 | +|---|---| |
| 53 | +| `+page.marko` | Page template | |
| 54 | +| `+layout.marko` | Layout wrapper | |
| 55 | +| `+handler.ts` | API / route handler | |
| 56 | +| `+middleware.ts` | Per-route middleware | |
| 57 | +| `+meta.ts` | Route metadata | |
| 58 | +| `$slug/` | Dynamic segment | |
| 59 | +| `$$rest/` | Catch-all segment | |
| 60 | +| `_group/` | Pathless layout group | |
| 61 | +| `+404.marko` | Not-found page | |
| 62 | +| `+500.marko` | Error page | |
| 63 | + |
| 64 | +Routes live in `src/routes/` by default and map directly to URL paths. |
| 65 | + |
| 66 | +## Repository Commands |
| 67 | + |
| 68 | +```bash |
| 69 | +# Build all packages |
| 70 | +npm run build |
| 71 | + |
| 72 | +# Build packages + run the example dev server |
| 73 | +npm run dev:example |
| 74 | + |
| 75 | +# Build packages + smoke-test the example |
| 76 | +npm run verify:example |
| 77 | + |
| 78 | +# Test route generation |
| 79 | +npm run test:routes |
| 80 | + |
| 81 | +# Sync vendored code from upstream @marko/run |
| 82 | +npm run sync:marko-run # apply changes |
| 83 | +npm run sync:marko-run:check # dry-run (no writes) |
| 84 | +``` |
| 85 | + |
| 86 | +## Examples |
| 87 | + |
| 88 | +- **[`examples/rspack-basic`](./examples/rspack-basic)** — Multi-page app demonstrating static routes, dynamic segments, catch-all routes, layout groups, API handlers, and hot reload. |
| 89 | + |
| 90 | +## Contributing |
| 91 | + |
| 92 | +See [`UPSTREAM_SYNC.md`](./UPSTREAM_SYNC.md) for how vendored `@marko/run` internals are kept in sync with upstream. |
| 93 | + |
| 94 | +## License |
| 95 | + |
| 96 | +MIT |
0 commit comments