@multisystemsuite/create-mf-app 1.0.5 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +832 -149
- package/dist/index.js +7379 -522
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,204 +1,817 @@
|
|
|
1
1
|
# create-mf-app
|
|
2
2
|
|
|
3
|
-
TypeScript CLI that scaffolds enterprise microfrontend
|
|
3
|
+
**`@multisystemsuite/create-mf-app`** — TypeScript CLI that scaffolds production-grade **enterprise microfrontend platforms** using React 19, Vite 7, Module Federation, React Router, Material UI, Docker, and npm workspaces.
|
|
4
|
+
|
|
5
|
+
Inspired by **Nx**, **Turborepo**, **Backstage**, and **Module Federation** — optimized for React microfrontends, Vite, runtime federation, SaaS dashboards, and internal developer platforms.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Table of contents
|
|
10
|
+
|
|
11
|
+
- [Install & run the CLI](#install--run-the-cli)
|
|
12
|
+
- [What it generates](#what-it-generates)
|
|
13
|
+
- [Quick start](#quick-start)
|
|
14
|
+
- [How to use the generated project](#how-to-use-the-generated-project)
|
|
15
|
+
- [CLI reference (create-mf-app)](#cli-reference-create-mf-app)
|
|
16
|
+
- [Custom child & shared app names](#custom-child--shared-app-names)
|
|
17
|
+
- [Enterprise platform flags](#enterprise-platform-flags)
|
|
18
|
+
- [Generated monorepo structure](#generated-monorepo-structure)
|
|
19
|
+
- [MF Platform CLI (inside generated projects)](#mf-platform-cli-inside-generated-projects)
|
|
20
|
+
- [Using corelib (shared library)](#using-corelib-shared-library)
|
|
21
|
+
- [Enterprise design system & theming](#enterprise-design-system--theming)
|
|
22
|
+
- [Module Federation](#module-federation)
|
|
23
|
+
- [SDK packages](#sdk-packages)
|
|
24
|
+
- [Task runner & build cache](#task-runner--build-cache)
|
|
25
|
+
- [Plugins & devtools](#plugins--devtools)
|
|
26
|
+
- [Runtime configuration](#runtime-configuration)
|
|
27
|
+
- [Template marketplace](#template-marketplace)
|
|
28
|
+
- [CI/CD & governance](#cicd--governance)
|
|
29
|
+
- [Code quality](#code-quality)
|
|
30
|
+
- [Root workspace scripts](#root-workspace-scripts)
|
|
31
|
+
- [Docker & deployment](#docker--deployment)
|
|
32
|
+
- [Documentation in generated projects](#documentation-in-generated-projects)
|
|
33
|
+
- [Node version](#node-version)
|
|
34
|
+
- [Troubleshooting](#troubleshooting)
|
|
35
|
+
- [Develop & publish this package](#develop--publish-this-package)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Install & run the CLI
|
|
40
|
+
|
|
41
|
+
You do **not** need to clone this repo to use the tool. Install and run via **npx** (recommended):
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npx @multisystemsuite/create-mf-app@latest my-platform --type=parent --children=billing,orders --shared=corelib --template=tsx
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Or use the short binary name (same package):
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx create-mf-app my-platform --type=parent --children=billing,orders --shared=corelib
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Global install** (optional):
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm install -g @multisystemsuite/create-mf-app
|
|
57
|
+
create-mf-app my-platform --type=parent --children=billing,orders --shared=corelib
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Interactive mode** (no project name — prompts for all options):
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npx create-mf-app
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Help:**
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx create-mf-app --help
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
After scaffolding, always:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
cd <project-name>
|
|
76
|
+
npm install
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Then use the scripts in [How to use the generated project](#how-to-use-the-generated-project).
|
|
80
|
+
|
|
81
|
+
---
|
|
4
82
|
|
|
5
83
|
## What it generates
|
|
6
84
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
85
|
+
### Single app (`--type=child`)
|
|
86
|
+
|
|
87
|
+
- React + Vite + Module Federation remote
|
|
88
|
+
- TypeScript (`.tsx`) or JavaScript (`.jsx`)
|
|
89
|
+
- Optional Docker
|
|
90
|
+
- Standalone dev on `--port` (default `3001`)
|
|
91
|
+
|
|
92
|
+
### Parent monorepo (`--type=parent`)
|
|
93
|
+
|
|
94
|
+
- **`apps/main`** — host shell (router, sidebar, navbar, command palette)
|
|
95
|
+
- **`apps/<child>`** — federated remotes (names you pass in `--children`)
|
|
96
|
+
- **`apps/corelib`** (or custom `--shared` name) — shared federated library (design system, RBAC, UI)
|
|
97
|
+
- **`packages/*`** — shared npm workspace libraries
|
|
98
|
+
- **`tools/mf-cli`** — Nx-like platform CLI (`mf generate`, `mf graph`, `mf affected`, …)
|
|
99
|
+
- **`task-runner/`** — parallel builds + hash cache (`.mf/cache`)
|
|
100
|
+
- **`plugins/`** — React, Vite, Federation, MUI, Auth, Charts, Workflow, Monitoring
|
|
101
|
+
- **`devtools/`** — federation inspector, profiler, theme inspector
|
|
102
|
+
- **`runtime-config/`** — tenant configs, remote manifests, feature flags
|
|
103
|
+
- **`templates/`** — LIMS, ERP, HMS, SaaS enterprise blueprints
|
|
104
|
+
- **`ai/`** — AI-ready prompt engine + semantic search hooks
|
|
105
|
+
- **`governance/`** — import boundaries, CODEOWNERS, dependency rules
|
|
106
|
+
- **CI/CD** — GitHub Actions, GitLab CI, Helm chart
|
|
107
|
+
- Root scripts for dev, watch, preview, release, affected builds, **per-child dev shortcuts**
|
|
108
|
+
|
|
109
|
+
---
|
|
13
110
|
|
|
14
111
|
## Quick start
|
|
15
112
|
|
|
16
|
-
Single app
|
|
113
|
+
### Single remote app
|
|
17
114
|
|
|
18
115
|
```bash
|
|
19
|
-
npx create-mf-app inventory --template=tsx --port=3001
|
|
116
|
+
npx create-mf-app inventory --template=tsx --port=3001 --type=child
|
|
20
117
|
cd inventory
|
|
21
118
|
npm install
|
|
22
119
|
npm run dev
|
|
23
120
|
```
|
|
24
121
|
|
|
25
|
-
|
|
122
|
+
Open **http://localhost:3001**
|
|
123
|
+
|
|
124
|
+
### Parent monorepo (full platform)
|
|
26
125
|
|
|
27
126
|
```bash
|
|
28
|
-
npx create-mf-app my-platform
|
|
127
|
+
npx create-mf-app my-platform \
|
|
128
|
+
--type=parent \
|
|
129
|
+
--children=billing,orders,analytics,warehouse \
|
|
130
|
+
--shared=corelib \
|
|
131
|
+
--template=tsx
|
|
132
|
+
|
|
29
133
|
cd my-platform
|
|
30
134
|
npm install
|
|
31
135
|
npm run local
|
|
32
136
|
```
|
|
33
137
|
|
|
34
|
-
|
|
138
|
+
Open **http://localhost:3000** (host). Child remotes load on routes like `/billing`, `/orders`, etc.
|
|
139
|
+
|
|
140
|
+
### Full enterprise platform (all optional modules)
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
npx create-mf-app my-platform \
|
|
144
|
+
--type=parent \
|
|
145
|
+
--children=billing,orders,analytics,warehouse \
|
|
146
|
+
--shared=corelib \
|
|
147
|
+
--template=tsx \
|
|
148
|
+
--auth \
|
|
149
|
+
--charts \
|
|
150
|
+
--storybook \
|
|
151
|
+
--monitoring \
|
|
152
|
+
--table \
|
|
153
|
+
--form-engine \
|
|
154
|
+
--i18n \
|
|
155
|
+
--testing \
|
|
156
|
+
--pwa \
|
|
157
|
+
--plugin-system
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## How to use the generated project
|
|
163
|
+
|
|
164
|
+
### First-time setup
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
cd my-platform
|
|
168
|
+
npm install # hoisted workspaces — required for federation shared deps
|
|
169
|
+
npm run local # build all apps → watch → preview all ports → live-reload
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
| Command | When to use |
|
|
173
|
+
|---------|-------------|
|
|
174
|
+
| `npm run local` | **Default daily dev** — all apps (main + every child + shared lib) |
|
|
175
|
+
| `npm run dev` | Print env + run each app's Vite dev server (no federation build watch) |
|
|
176
|
+
| `npm run dev:fast` | Dev build once, then preview + live-reload |
|
|
177
|
+
| `npm run dev:safe` | Production build, then preview only |
|
|
178
|
+
|
|
179
|
+
### Work on one module only (faster)
|
|
180
|
+
|
|
181
|
+
The generator creates **one npm script per child name** from `--children`. Each script starts only the apps that module needs:
|
|
182
|
+
|
|
183
|
+
| You run | Apps started | Typical URL |
|
|
184
|
+
|---------|--------------|-------------|
|
|
185
|
+
| `npm run billing` | main + corelib + billing | http://localhost:3000/billing |
|
|
186
|
+
| `npm run orders` | main + corelib + orders | http://localhost:3000/orders |
|
|
187
|
+
| `npm run analytics` | main + corelib + analytics | http://localhost:3000/analytics |
|
|
188
|
+
| `npm run corelib` | main + corelib | http://localhost:3000 |
|
|
189
|
+
|
|
190
|
+
**Example:** only billing team local dev:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
npm run billing
|
|
194
|
+
# edit apps/billing/src/...
|
|
195
|
+
# host reloads billing remote from localhost:3001
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Scripts are **generated dynamically** from your `--children` list — if you scaffold with `--children=invoicing,shipping`, you get `npm run invoicing` and `npm run shipping` automatically.
|
|
199
|
+
|
|
200
|
+
### Port assignment
|
|
201
|
+
|
|
202
|
+
Ports are assigned sequentially from **3000**:
|
|
203
|
+
|
|
204
|
+
| App order | Example names | Port |
|
|
205
|
+
|-----------|---------------|------|
|
|
206
|
+
| 1st | `main` (always host) | 3000 |
|
|
207
|
+
| 2nd | first child | 3001 |
|
|
208
|
+
| 3rd | second child | 3002 |
|
|
209
|
+
| … | … | … |
|
|
210
|
+
| last | shared lib (`corelib`) | highest port |
|
|
211
|
+
|
|
212
|
+
Check your generated root `README.md` or `.env` for the exact map.
|
|
213
|
+
|
|
214
|
+
### Build for environments
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
npm run build:local # localdev mode — used by npm run local
|
|
218
|
+
npm run build:dev # dev
|
|
219
|
+
npm run build:staging # staging (+ cleanup first)
|
|
220
|
+
npm run build:uat # uat
|
|
221
|
+
npm run build # production (alias: build:production)
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Release version
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
npm run release # patch bump + build
|
|
228
|
+
npm run release:minor
|
|
229
|
+
npm run release:major
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Typical developer workflow
|
|
233
|
+
|
|
234
|
+
1. **Scaffold** with `npx create-mf-app …`
|
|
235
|
+
2. **`npm install`** at monorepo root
|
|
236
|
+
3. **`npm run local`** or **`npm run <your-module>`** for focused work
|
|
237
|
+
4. Edit **`apps/<module>/src/`** — routes, pages, services
|
|
238
|
+
5. Use **`corelib`** for shared UI, theme, RBAC (see below)
|
|
239
|
+
6. **`npm run type-check`** / **`npm run lint`** before commit
|
|
240
|
+
7. **`npm run build:production`** before deploy
|
|
241
|
+
8. **`npm run federation:verify`** to check remoteEntry URLs
|
|
242
|
+
|
|
243
|
+
### Add a new remote after scaffold
|
|
244
|
+
|
|
245
|
+
Use the built-in MF CLI (recommended):
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
npm run mf -- generate app inventory
|
|
249
|
+
# wires federation, port, mf.json, and npm scripts
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Or copy an existing child app folder and update `mf.json`, `federation.config.ts`, host routes, and root `package.json` scripts manually.
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
## CLI reference (create-mf-app)
|
|
35
257
|
|
|
36
258
|
```bash
|
|
37
259
|
npx create-mf-app <project-name> [options]
|
|
38
260
|
```
|
|
39
261
|
|
|
40
|
-
|
|
262
|
+
| Option | Description |
|
|
263
|
+
|--------|-------------|
|
|
264
|
+
| `--port=3001` | Dev/preview port (**single app / child mode only**) |
|
|
265
|
+
| `--template=tsx\|jsx` | TypeScript or JavaScript |
|
|
266
|
+
| `--typescript` | Alias for `--template=tsx` |
|
|
267
|
+
| `--javascript` | Alias for `--template=jsx` |
|
|
268
|
+
| `--type=parent\|child` | Monorepo or single app (default: `child`) |
|
|
269
|
+
| `--children=billing,orders` | Child remote app **folder names** (parent mode, required) |
|
|
270
|
+
| `--shared=corelib` | Shared federated lib folder name (default: `sharedlib`) |
|
|
271
|
+
| `--docker=true\|false` | Generate Dockerfiles (default: `true`) |
|
|
272
|
+
| `--federation=true\|false` | Module Federation (default: `true`) |
|
|
273
|
+
| `-y`, `--yes` | Non-interactive (use defaults where applicable) |
|
|
274
|
+
| `-h`, `--help` | Show help |
|
|
41
275
|
|
|
42
|
-
|
|
43
|
-
- `--template=tsx|jsx`
|
|
44
|
-
- `--typescript` (alias for `--template=tsx`)
|
|
45
|
-
- `--javascript` (alias for `--template=jsx`)
|
|
46
|
-
- `--type=parent|child`
|
|
47
|
-
- `--children=billing,orders,analytics`
|
|
48
|
-
- `--shared=sharedlib`
|
|
49
|
-
- `--docker=true|false`
|
|
50
|
-
- `--federation=true|false`
|
|
51
|
-
- `-y`, `--yes`
|
|
52
|
-
- `-h`, `--help`
|
|
276
|
+
**Parent mode rules:**
|
|
53
277
|
|
|
54
|
-
|
|
278
|
+
- `main` is **always** created as the host — never pass it in `--children` or `--shared`
|
|
279
|
+
- `--children` is **required** in parent mode (comma- or space-separated)
|
|
280
|
+
- If `--shared` is omitted, generator uses `sharedlib`
|
|
281
|
+
- Child names become **`apps/<name>/`** folders and **`npm run <name>`** scripts
|
|
55
282
|
|
|
56
|
-
|
|
283
|
+
**Interactive flow** (run without project name):
|
|
57
284
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
285
|
+
1. Project name
|
|
286
|
+
2. Application type (parent / child)
|
|
287
|
+
3. Child applications (checkboxes: admin, qc, inventory, shopfloor)
|
|
288
|
+
4. Shared applications (comma-separated, default `sharedlib`)
|
|
289
|
+
5. Template (tsx / jsx)
|
|
290
|
+
6. Port
|
|
291
|
+
7. Module Federation on/off
|
|
292
|
+
8. Docker on/off
|
|
66
293
|
|
|
67
|
-
|
|
294
|
+
---
|
|
68
295
|
|
|
69
|
-
|
|
70
|
-
- `main` is auto-created and cannot be passed in `children` or `shared`.
|
|
71
|
-
- If `--shared` is omitted in parent mode, generator auto-adds `sharedlib`.
|
|
72
|
-
- Children can be passed comma-separated or space-separated.
|
|
296
|
+
## Custom child & shared app names
|
|
73
297
|
|
|
74
|
-
|
|
298
|
+
Folder names are **entirely user-defined** via CLI flags:
|
|
75
299
|
|
|
76
300
|
```bash
|
|
77
|
-
npx create-mf-app
|
|
301
|
+
npx create-mf-app acme-platform \
|
|
302
|
+
--type=parent \
|
|
303
|
+
--children=invoicing,shipping,reports \
|
|
304
|
+
--shared=corelib \
|
|
305
|
+
--template=tsx
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
**Creates:**
|
|
309
|
+
|
|
310
|
+
```text
|
|
311
|
+
apps/main/
|
|
312
|
+
apps/invoicing/ → npm run invoicing
|
|
313
|
+
apps/shipping/ → npm run shipping
|
|
314
|
+
apps/reports/ → npm run reports
|
|
315
|
+
apps/corelib/
|
|
78
316
|
```
|
|
79
317
|
|
|
80
|
-
|
|
318
|
+
**Host routes** (auto-wired): `/invoicing/*`, `/shipping/*`, `/reports/*`
|
|
319
|
+
|
|
320
|
+
**Rules for names:**
|
|
321
|
+
|
|
322
|
+
- Letters, numbers, dashes only (`^[a-z0-9-]+$`)
|
|
323
|
+
- Lowercase recommended (billing, not Billing)
|
|
324
|
+
- Do not use `main` — reserved for host
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## Enterprise platform flags
|
|
329
|
+
|
|
330
|
+
Optional modules for **parent monorepos** (core modules are always included):
|
|
81
331
|
|
|
82
|
-
|
|
332
|
+
| Flag | Generated module |
|
|
333
|
+
|------|------------------|
|
|
334
|
+
| `--auth` | OAuth/OIDC foundation in `apps/corelib/src/auth/` + `packages/auth-sdk` |
|
|
335
|
+
| `--charts` | Chart widgets in `apps/corelib/src/charts/` |
|
|
336
|
+
| `--storybook` | `.storybook/` + component stories |
|
|
337
|
+
| `--monitoring` | Logger, telemetry, Sentry, audit in `apps/corelib/src/monitoring/` |
|
|
338
|
+
| `--table` | Advanced `AppDataGrid` (on by default for parent workspaces) |
|
|
339
|
+
| `--form-engine` | Schema-driven forms in `apps/corelib/src/form-engine/` |
|
|
340
|
+
| `--i18n` | Lazy locales + RTL in `apps/corelib/src/i18n/` |
|
|
341
|
+
| `--testing` | Vitest workspace + Playwright + Cypress configs |
|
|
342
|
+
| `--pwa` | PWA manifest placeholder |
|
|
343
|
+
| `--plugin-system` | Runtime plugin registry in `apps/corelib/src/plugins/` |
|
|
344
|
+
|
|
345
|
+
**Always included** for federated parent workspaces (no flag needed):
|
|
346
|
+
|
|
347
|
+
| Module | Location |
|
|
348
|
+
|--------|----------|
|
|
349
|
+
| Design tokens | `apps/corelib/src/tokens/` |
|
|
350
|
+
| Layouts | `apps/corelib/src/layouts/` (Dashboard, Auth, Settings, Split, Fullscreen, Error) |
|
|
351
|
+
| RBAC | `apps/corelib/src/permissions/` |
|
|
352
|
+
| Federation registry | `apps/corelib/src/federation/` |
|
|
353
|
+
| Command palette | `apps/corelib/src/command-palette/` (Ctrl+K) |
|
|
354
|
+
| Production hardening | `apps/corelib/src/production/` (CSP, env validation, diagnostics) |
|
|
355
|
+
| MF Platform CLI | `tools/mf-cli/` |
|
|
356
|
+
| Project graph | `tools/project-graph/` |
|
|
357
|
+
| Task runner + cache | `task-runner/` + `.mf/cache` |
|
|
358
|
+
|
|
359
|
+
---
|
|
360
|
+
|
|
361
|
+
## Generated monorepo structure
|
|
83
362
|
|
|
84
363
|
```text
|
|
85
364
|
my-platform/
|
|
365
|
+
├── mf.json # Workspace config (like nx.json)
|
|
86
366
|
├── apps/
|
|
87
|
-
│ ├── main/
|
|
88
|
-
│ ├── billing/
|
|
367
|
+
│ ├── main/ # Host shell (port 3000)
|
|
368
|
+
│ ├── billing/ # Child remote (your --children names)
|
|
89
369
|
│ ├── orders/
|
|
90
|
-
│
|
|
91
|
-
│ └── corelib/
|
|
370
|
+
│ └── corelib/ # Shared federated library (--shared name)
|
|
92
371
|
├── packages/
|
|
93
372
|
│ ├── shared-ui/
|
|
373
|
+
│ ├── shared-auth/
|
|
94
374
|
│ ├── shared-utils/
|
|
95
|
-
│
|
|
375
|
+
│ ├── shared-config/
|
|
376
|
+
│ ├── shared-hooks/
|
|
377
|
+
│ ├── shared-services/
|
|
378
|
+
│ ├── shared-security/
|
|
379
|
+
│ ├── sdk-core/
|
|
380
|
+
│ ├── api-client/
|
|
381
|
+
│ ├── query-client/
|
|
382
|
+
│ ├── websocket-sdk/
|
|
383
|
+
│ └── auth-sdk/ # with --auth
|
|
384
|
+
├── tools/
|
|
385
|
+
│ ├── mf-cli/ # mf CLI (generate, graph, affected, …)
|
|
386
|
+
│ └── project-graph/
|
|
387
|
+
├── task-runner/
|
|
388
|
+
├── plugins/
|
|
389
|
+
├── devtools/
|
|
390
|
+
├── runtime-config/
|
|
391
|
+
├── templates/
|
|
392
|
+
├── ai/
|
|
393
|
+
├── governance/
|
|
394
|
+
├── k8s/helm/mf-platform/
|
|
395
|
+
├── docs/
|
|
96
396
|
├── scripts/
|
|
397
|
+
├── .github/workflows/
|
|
97
398
|
├── docker-compose.yml
|
|
98
|
-
├── .env
|
|
99
|
-
├── package.json
|
|
399
|
+
├── .env, .env.dev, .env.staging, .env.uat, .env.prod
|
|
100
400
|
├── live-reload.js
|
|
101
401
|
├── smart-build.js
|
|
102
|
-
|
|
103
|
-
└── README.md
|
|
402
|
+
└── package.json # npm run local, npm run billing, …
|
|
104
403
|
```
|
|
105
404
|
|
|
106
|
-
|
|
405
|
+
---
|
|
107
406
|
|
|
108
|
-
|
|
407
|
+
## MF Platform CLI (inside generated projects)
|
|
109
408
|
|
|
110
|
-
|
|
111
|
-
- `build:local`, `build:dev`, `build:staging`, `build:uat`, `build:production`
|
|
112
|
-
- app-specific scripts like `billing`, `orders`, `analytics`, `warehouse`
|
|
113
|
-
- `watch:*`, `preview:*`, `watch:local:*`, `preview:local:*`
|
|
114
|
-
- `release`, `release:minor`, `release:major`
|
|
409
|
+
After scaffolding, use the **`mf`** CLI inside your monorepo:
|
|
115
410
|
|
|
116
|
-
|
|
411
|
+
```bash
|
|
412
|
+
npm run mf -- <command>
|
|
413
|
+
# or
|
|
414
|
+
node tools/mf-cli/bin/mf.js <command>
|
|
415
|
+
```
|
|
117
416
|
|
|
118
|
-
|
|
417
|
+
### Generators
|
|
418
|
+
|
|
419
|
+
| Command | Description |
|
|
420
|
+
|---------|-------------|
|
|
421
|
+
| `mf generate app <name>` | New MFE remote (`create-app`, `create-mfe`) |
|
|
422
|
+
| `mf generate lib <name>` | Shared library package (`create-lib`) |
|
|
423
|
+
| `mf generate plugin <name>` | Platform plugin (`create-plugin`) |
|
|
424
|
+
| `mf generate page <name> [app]` | Route page (`create-page`) |
|
|
425
|
+
| `mf generate layout <name>` | Layout component (`create-layout`) |
|
|
426
|
+
| `mf generate feature <name>` | Feature module (`create-feature`) |
|
|
427
|
+
| `mf generate component <name>` | UI component in shared-ui |
|
|
428
|
+
| `mf generate dashboard <name>` | Dashboard module (`create-dashboard`) |
|
|
429
|
+
| `mf generate workflow <name>` | Workflow module (`create-workflow`) |
|
|
430
|
+
| `mf generate api-sdk <name>` | API SDK package (`create-api-sdk`) |
|
|
431
|
+
| `mf generate table <name>` | AppTable scaffold (`create-table`) |
|
|
432
|
+
| `mf generate form <name>` | Form engine scaffold (`create-form`) |
|
|
433
|
+
| `mf generate auth <name>` | Auth provider scaffold (`create-auth`) |
|
|
434
|
+
| `mf generate theme <name>` | Theme preset (`create-theme`) |
|
|
435
|
+
|
|
436
|
+
### Orchestration
|
|
437
|
+
|
|
438
|
+
| Command | Description |
|
|
439
|
+
|---------|-------------|
|
|
440
|
+
| `mf graph` | Export dependency graph to `tools/project-graph/graph-ui/graph.json` |
|
|
441
|
+
| `mf graph --federation` | Federation-only graph |
|
|
442
|
+
| `mf affected build` | Git-aware incremental build |
|
|
443
|
+
| `mf affected test` | Run tests only on affected projects |
|
|
444
|
+
| `mf affected lint` | Lint only affected projects |
|
|
445
|
+
| `mf affected <target> --base=main` | Custom git base branch |
|
|
446
|
+
| `mf run <project> [target]` | Run target on one project |
|
|
447
|
+
| `mf build` | Build all projects (parallel) |
|
|
448
|
+
| `mf test` | Test all projects |
|
|
449
|
+
| `mf lint` | Lint all projects |
|
|
450
|
+
| `mf serve` | Delegates to `npm run local` |
|
|
451
|
+
| `mf release [patch\|minor\|major]` | Release workflow |
|
|
452
|
+
|
|
453
|
+
### Federation & health
|
|
454
|
+
|
|
455
|
+
| Command | Description |
|
|
456
|
+
|---------|-------------|
|
|
457
|
+
| `mf federation doctor` | Check host/remotes/shared lib wiring |
|
|
458
|
+
| `mf federation graph` | Export federation dependency graph |
|
|
459
|
+
| `mf federation sync` | Sync remote manifests from `mf.json` |
|
|
460
|
+
| `mf doctor` | Workspace health (circular deps, boundaries, mf.json) |
|
|
461
|
+
| `npm run federation:verify` | HEAD-check remoteEntry URLs (`MF_REMOTES` env) |
|
|
462
|
+
|
|
463
|
+
### npm script shortcuts (generated)
|
|
464
|
+
|
|
465
|
+
```json
|
|
466
|
+
"mf": "node tools/mf-cli/bin/mf.js",
|
|
467
|
+
"mf:graph": "node tools/mf-cli/bin/mf.js graph",
|
|
468
|
+
"mf:affected": "node tools/mf-cli/bin/mf.js affected build",
|
|
469
|
+
"mf:doctor": "node tools/mf-cli/bin/mf.js doctor",
|
|
470
|
+
"mf:federation": "node tools/mf-cli/bin/mf.js federation doctor"
|
|
471
|
+
```
|
|
119
472
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
473
|
+
---
|
|
474
|
+
|
|
475
|
+
## Using corelib (shared library)
|
|
476
|
+
|
|
477
|
+
**corelib** (or your `--shared` name) is a **Module Federation remote** that exposes shared UI, config, and RBAC. Child remotes and the host import it at runtime.
|
|
478
|
+
|
|
479
|
+
### Host (`apps/main`) — wrap shell with providers
|
|
480
|
+
|
|
481
|
+
```tsx
|
|
482
|
+
const AppConfigProvider = React.lazy(() => import("corelib/AppConfigProvider"));
|
|
483
|
+
const AppNavbar = React.lazy(() => import("corelib/AppNavbar"));
|
|
484
|
+
const AppSidebar = React.lazy(() => import("corelib/AppSidebar"));
|
|
485
|
+
const EnterpriseSidebarNav = React.lazy(() => import("corelib/EnterpriseSidebarNav"));
|
|
486
|
+
const RoleProvider = React.lazy(() => import("corelib/RoleProvider"));
|
|
487
|
+
const CommandPalette = React.lazy(() => import("corelib/CommandPalette"));
|
|
488
|
+
|
|
489
|
+
export default function App() {
|
|
490
|
+
return (
|
|
491
|
+
<React.Suspense fallback={<div>Loading…</div>}>
|
|
492
|
+
<AppConfigProvider>
|
|
493
|
+
<RoleProvider>
|
|
494
|
+
{/* navbar, sidebar, routes */}
|
|
495
|
+
</RoleProvider>
|
|
496
|
+
</AppConfigProvider>
|
|
497
|
+
</React.Suspense>
|
|
498
|
+
);
|
|
499
|
+
}
|
|
500
|
+
```
|
|
127
501
|
|
|
128
|
-
###
|
|
502
|
+
### Child remote — use shared badge, RBAC, tokens
|
|
503
|
+
|
|
504
|
+
```tsx
|
|
505
|
+
const SharedBadge = React.lazy(() => import("corelib/SharedBadge"));
|
|
506
|
+
const RoleProvider = React.lazy(() => import("corelib/RoleProvider"));
|
|
507
|
+
|
|
508
|
+
export default function App() {
|
|
509
|
+
return (
|
|
510
|
+
<div className="remote-shell">
|
|
511
|
+
<RoleProvider>
|
|
512
|
+
<SharedBadge />
|
|
513
|
+
<AppRouter />
|
|
514
|
+
</RoleProvider>
|
|
515
|
+
</div>
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
```
|
|
129
519
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
520
|
+
### Available federation exports (corelib)
|
|
521
|
+
|
|
522
|
+
| Export | Purpose |
|
|
523
|
+
|--------|---------|
|
|
524
|
+
| `./App` | Standalone corelib demo app |
|
|
525
|
+
| `./AppConfigProvider` | Theme + MUI provider + CSS variables |
|
|
526
|
+
| `./useAppConfig` | Hook: config, palette, shell colors, toggle theme |
|
|
527
|
+
| `./AppNavbar`, `./AppSidebar`, `./ThemeToggle` | Shell UI |
|
|
528
|
+
| `./EnterpriseSidebarNav` | Role-filtered sidebar menu |
|
|
529
|
+
| `./RouteGuard`, `./RoleProvider`, `./usePermission` | RBAC |
|
|
530
|
+
| `./CommandPalette` | Ctrl+K palette |
|
|
531
|
+
| `./DashboardLayout` | Dashboard shell layout |
|
|
532
|
+
| `./PermissionProvider`, `./FederationFallback` | Permissions + error UI |
|
|
533
|
+
| `./designTokens` | Token registry |
|
|
534
|
+
|
|
535
|
+
### TypeScript — add declarations in host/child
|
|
536
|
+
|
|
537
|
+
Generated projects include `src/types/federation-remotes.d.ts` for remote module names. After adding new exposes, extend that file:
|
|
538
|
+
|
|
539
|
+
```ts
|
|
540
|
+
declare module "corelib/MyNewComponent" {
|
|
541
|
+
const Component: React.ComponentType;
|
|
542
|
+
export default Component;
|
|
543
|
+
}
|
|
544
|
+
```
|
|
137
545
|
|
|
138
|
-
|
|
546
|
+
---
|
|
139
547
|
|
|
140
|
-
|
|
548
|
+
## Enterprise design system & theming
|
|
141
549
|
|
|
142
550
|
```text
|
|
143
|
-
apps/
|
|
144
|
-
├──
|
|
145
|
-
├──
|
|
146
|
-
├──
|
|
147
|
-
├── themeGenerator.ts
|
|
148
|
-
├──
|
|
149
|
-
|
|
551
|
+
apps/corelib/src/
|
|
552
|
+
├── tokens/ # colors, spacing, typography, shadows, …
|
|
553
|
+
├── config/
|
|
554
|
+
│ ├── AppConfigProvider.tsx
|
|
555
|
+
│ ├── themeGenerator.ts # MUI theme from tokens
|
|
556
|
+
│ ├── resolveTheme.ts # contrast-safe shell colors
|
|
557
|
+
│ ├── colorUtils.ts # WCAG contrast helpers
|
|
558
|
+
│ └── defaultConfig.ts # enterprise-light / enterprise-dark presets
|
|
559
|
+
├── layouts/
|
|
560
|
+
├── permissions/
|
|
561
|
+
├── shared-ui/
|
|
562
|
+
└── …
|
|
150
563
|
```
|
|
151
564
|
|
|
152
|
-
|
|
565
|
+
### Runtime theme in your components
|
|
153
566
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
- sidebar/navbar/layout toggles
|
|
157
|
-
- dark/light mode switching
|
|
158
|
-
- preset themes
|
|
159
|
-
- import/export config JSON
|
|
160
|
-
- localStorage persistence
|
|
567
|
+
```tsx
|
|
568
|
+
import { useAppConfig } from "corelib/useAppConfig";
|
|
161
569
|
|
|
162
|
-
|
|
570
|
+
function MyWidget() {
|
|
571
|
+
const { config, palette, shell, toggleColorMode } = useAppConfig();
|
|
572
|
+
return (
|
|
573
|
+
<div style={{ color: palette.textPrimary, background: palette.surface }}>
|
|
574
|
+
{config.appName}
|
|
575
|
+
</div>
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
```
|
|
163
579
|
|
|
164
|
-
|
|
580
|
+
**Features:**
|
|
165
581
|
|
|
166
|
-
|
|
582
|
+
- Enterprise-light / enterprise-dark presets + Azure, Atlassian, Linear-dark, etc.
|
|
583
|
+
- Light/dark toggle with **full palette sync** (background + text together)
|
|
584
|
+
- **Contrast-safe** navbar/sidebar text (no dark-on-dark)
|
|
585
|
+
- CSS variables (`--ds-*`) applied to `document.documentElement`
|
|
586
|
+
- Responsive collapsible sidebar (flex layout, no overlap)
|
|
587
|
+
- MUI component overrides from design tokens
|
|
167
588
|
|
|
168
|
-
|
|
169
|
-
- `/settings/layout`
|
|
170
|
-
- `/settings/branding`
|
|
589
|
+
**Clear cached theme** (after upgrades or bad colors):
|
|
171
590
|
|
|
172
|
-
|
|
591
|
+
```js
|
|
592
|
+
localStorage.removeItem('mf-enterprise-config')
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
Then hard-refresh the browser.
|
|
596
|
+
|
|
597
|
+
---
|
|
598
|
+
|
|
599
|
+
## Module Federation
|
|
600
|
+
|
|
601
|
+
### Architecture
|
|
602
|
+
|
|
603
|
+
```text
|
|
604
|
+
┌─────────────────────────────────────────────────────────┐
|
|
605
|
+
│ apps/main (host) :3000 │
|
|
606
|
+
│ ├── loads corelib remote (shared UI, theme, RBAC) │
|
|
607
|
+
│ ├── loads billing remote on /billing/* │
|
|
608
|
+
│ └── loads orders remote on /orders/* │
|
|
609
|
+
└─────────────────────────────────────────────────────────┘
|
|
610
|
+
│ shared singletons: react, react-dom, MUI, …
|
|
611
|
+
▼
|
|
612
|
+
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
|
|
613
|
+
│ apps/billing │ │ apps/orders │ │ apps/corelib │
|
|
614
|
+
│ :3001 │ │ :3002 │ │ :3003 │
|
|
615
|
+
└──────────────┘ └──────────────┘ └──────────────┘
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
### Shared dependency rules (important)
|
|
619
|
+
|
|
620
|
+
The generator configures federation so **one React/MUI instance** is shared:
|
|
621
|
+
|
|
622
|
+
**Host (`apps/main/federation.config.ts`):**
|
|
623
|
+
|
|
624
|
+
- Provides shared deps with **exact semver** keys: `version: "19.0.0"` (not `^19.0.0`)
|
|
625
|
+
- `singleton: true`, `import: true`
|
|
626
|
+
|
|
627
|
+
**Remotes (children + corelib):**
|
|
628
|
+
|
|
629
|
+
- Consume host share scope: `requiredVersion: "^19.0.0"`
|
|
630
|
+
- `singleton: true`
|
|
631
|
+
|
|
632
|
+
**Shared packages:** `react`, `react-dom`, `react-router-dom`, `@mui/material`, `@mui/icons-material`, `@emotion/react`, `@emotion/styled`, `@mui/x-data-grid`
|
|
633
|
+
|
|
634
|
+
**After changing federation config:**
|
|
635
|
+
|
|
636
|
+
```bash
|
|
637
|
+
npm run build:local # rebuild ALL apps
|
|
638
|
+
npm run local # restart
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
Use **hoisted install** (generated `.npmrc`: `install-strategy=hoisted`).
|
|
642
|
+
|
|
643
|
+
### Remote URLs (local dev)
|
|
644
|
+
|
|
645
|
+
Each app's `federation.config.ts` points to:
|
|
173
646
|
|
|
174
647
|
```text
|
|
175
|
-
|
|
176
|
-
├── AppButton/
|
|
177
|
-
├── AppCard/
|
|
178
|
-
├── AppDialog/
|
|
179
|
-
├── AppTable/
|
|
180
|
-
├── AppInput/
|
|
181
|
-
├── AppNavbar/
|
|
182
|
-
├── AppSidebar/
|
|
183
|
-
└── ThemeProvider/
|
|
648
|
+
http://localhost:<port>/assets/remoteEntry.js
|
|
184
649
|
```
|
|
185
650
|
|
|
186
|
-
|
|
651
|
+
Match ports from root `.env` when customizing.
|
|
652
|
+
|
|
653
|
+
---
|
|
654
|
+
|
|
655
|
+
## SDK packages
|
|
656
|
+
|
|
657
|
+
| Package | Purpose |
|
|
658
|
+
|---------|---------|
|
|
659
|
+
| `@<project>/sdk-core` | Trace IDs, error normalization |
|
|
660
|
+
| `@<project>/api-client` | Axios wrapper, interceptors, API versioning |
|
|
661
|
+
| `@<project>/auth-sdk` | Token refresh helpers (`--auth`) |
|
|
662
|
+
| `@<project>/query-client` | Query key utilities |
|
|
663
|
+
| `@<project>/websocket-sdk` | Reconnecting WebSocket |
|
|
664
|
+
|
|
665
|
+
Import from workspace packages in apps via `file:../../packages/<name>` dependencies.
|
|
666
|
+
|
|
667
|
+
---
|
|
668
|
+
|
|
669
|
+
## Task runner & build cache
|
|
670
|
+
|
|
671
|
+
```text
|
|
672
|
+
task-runner/
|
|
673
|
+
├── orchestrator.js # Parallel execution, dependency-aware runs
|
|
674
|
+
├── cache-engine.js # Hash-based local cache
|
|
675
|
+
├── executors/ # build, test, lint
|
|
676
|
+
└── pipelines/ # default: build → test → lint
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
- Cache directory: `.mf/cache/` (gitignored)
|
|
680
|
+
- Cache key: hash of project + target + inputs
|
|
681
|
+
- CI: cache `.mf/cache` in pipeline for faster rebuilds
|
|
682
|
+
|
|
683
|
+
---
|
|
684
|
+
|
|
685
|
+
## Plugins & devtools
|
|
686
|
+
|
|
687
|
+
**Plugins** (`plugins/*-plugin/`): register generators, executors, hooks (preBuild, postBuild, appCreated).
|
|
688
|
+
|
|
689
|
+
**Devtools** (`devtools/`):
|
|
690
|
+
|
|
691
|
+
- **Federation inspector** — inspect loaded remotes in browser
|
|
692
|
+
- **Performance profiler** — Web Vitals + route transition timing
|
|
693
|
+
- **MFE debugger** — `window.__MF_DEBUG__` remote load tracing
|
|
694
|
+
- **Theme inspector** — CSS variable viewer
|
|
695
|
+
- **Dependency viewer** — CLI dependency tree
|
|
696
|
+
|
|
697
|
+
---
|
|
698
|
+
|
|
699
|
+
## Runtime configuration
|
|
700
|
+
|
|
701
|
+
```text
|
|
702
|
+
runtime-config/
|
|
703
|
+
├── tenant-config.js # Multi-tenant SaaS configs
|
|
704
|
+
├── manifest-loader.js # CDN remote manifest fetch
|
|
705
|
+
├── feature-flags.js # Runtime feature toggles
|
|
706
|
+
└── branding.js # Dynamic logo/colors injection
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
---
|
|
710
|
+
|
|
711
|
+
## Template marketplace
|
|
712
|
+
|
|
713
|
+
Enterprise blueprints in `templates/`:
|
|
714
|
+
|
|
715
|
+
| Template | Domain |
|
|
716
|
+
|----------|--------|
|
|
717
|
+
| `lims-template` | Laboratory Information Management |
|
|
718
|
+
| `hms-template` | Healthcare Management |
|
|
719
|
+
| `erp-template` | Enterprise Resource Planning |
|
|
720
|
+
| `analytics-template` | Analytics dashboards |
|
|
721
|
+
| `admin-template` | Admin portal |
|
|
722
|
+
| `saas-template` | Multi-tenant SaaS |
|
|
723
|
+
| `workflow-template` | Workflow automation |
|
|
724
|
+
|
|
725
|
+
---
|
|
187
726
|
|
|
188
|
-
##
|
|
727
|
+
## CI/CD & governance
|
|
189
728
|
|
|
190
|
-
|
|
729
|
+
**GitHub Actions:**
|
|
191
730
|
|
|
192
|
-
-
|
|
193
|
-
-
|
|
731
|
+
- `.github/workflows/mf-platform-ci.yml` — doctor, affected lint/test/build, security audit
|
|
732
|
+
- `.github/workflows/mf-affected-deploy.yml` — affected deploy on main
|
|
194
733
|
|
|
195
|
-
|
|
734
|
+
**Also generated:**
|
|
196
735
|
|
|
197
|
-
-
|
|
736
|
+
- `.gitlab-ci.yml`
|
|
737
|
+
- `k8s/helm/mf-platform/` — Helm chart for host + remotes
|
|
738
|
+
- `governance/module-boundaries.json` — import boundary rules
|
|
739
|
+
- `governance/CODEOWNERS` — team ownership
|
|
740
|
+
- `governance/dependency-rules.json` — license governance
|
|
198
741
|
|
|
199
|
-
|
|
742
|
+
**Deploy strategy:**
|
|
200
743
|
|
|
201
|
-
|
|
744
|
+
1. `mf affected build` on merge
|
|
745
|
+
2. Upload `apps/*/dist` to CDN
|
|
746
|
+
3. Host loads remote manifests at runtime
|
|
747
|
+
4. Helm/Kubernetes for containerized host + ingress
|
|
748
|
+
|
|
749
|
+
---
|
|
750
|
+
|
|
751
|
+
## Code quality
|
|
752
|
+
|
|
753
|
+
Generated parent workspaces include:
|
|
754
|
+
|
|
755
|
+
| Script | Purpose |
|
|
756
|
+
|--------|---------|
|
|
757
|
+
| `npm run lint` / `lint:fix` | ESLint across apps + packages |
|
|
758
|
+
| `npm run format` / `format:check` | Prettier |
|
|
759
|
+
| `npm run stylelint` | CSS / SCSS |
|
|
760
|
+
| `npm run type-check` | TypeScript every workspace app |
|
|
761
|
+
| `npm run test` / `test:watch` / `test:ci` | Vitest + coverage |
|
|
762
|
+
| `npm run cleanup` | lint:fix → imports → type-check |
|
|
763
|
+
| `npm run analyze:bundle` | Rollup visualizer per app |
|
|
764
|
+
| `npm run security:audit` | npm audit |
|
|
765
|
+
| `npm run production:hygiene` | Fail on console/debugger in sources |
|
|
766
|
+
|
|
767
|
+
Husky: lint-staged + type-check + tests on pre-commit; lint + tests on pre-push. Commitlint for Conventional Commits.
|
|
768
|
+
|
|
769
|
+
---
|
|
770
|
+
|
|
771
|
+
## Root workspace scripts
|
|
772
|
+
|
|
773
|
+
### Full platform
|
|
774
|
+
|
|
775
|
+
| Script | Purpose |
|
|
776
|
+
|--------|---------|
|
|
777
|
+
| `local` | **Main dev command** — build:local + watch + preview + live-reload (all apps) |
|
|
778
|
+
| `dev` | print-env + parallel Vite dev servers |
|
|
779
|
+
| `dev:watch` | Same as `local` |
|
|
780
|
+
| `dev:fast` | dev build once + preview + live-reload |
|
|
781
|
+
| `dev:safe` | production build + preview only |
|
|
782
|
+
| `build` | Production build (runs cleanup first) |
|
|
783
|
+
| `build:local` | localdev mode build for all apps |
|
|
784
|
+
| `build:dev` / `build:staging` / `build:uat` | Environment-specific builds |
|
|
785
|
+
| `watch:<app>` | Vite watch for one app |
|
|
786
|
+
| `preview:<app>` | Vite preview for one app |
|
|
787
|
+
| `release` / `release:minor` / `release:major` | Version bump + build |
|
|
788
|
+
| `federation:verify` | Remote entry health check |
|
|
789
|
+
| `mf`, `mf:graph`, `mf:affected`, `mf:doctor` | Platform CLI shortcuts |
|
|
790
|
+
|
|
791
|
+
### Per-module dev (dynamic — one script per `--children` name)
|
|
792
|
+
|
|
793
|
+
| Script | Apps included |
|
|
794
|
+
|--------|----------------|
|
|
795
|
+
| `npm run billing` | main + corelib + billing |
|
|
796
|
+
| `npm run orders` | main + corelib + orders |
|
|
797
|
+
| `npm run <child>` | main + corelib + `<child>` |
|
|
798
|
+
| `npm run corelib` | main + corelib |
|
|
799
|
+
|
|
800
|
+
Supporting scripts (auto-generated):
|
|
801
|
+
|
|
802
|
+
- `build:local:<child>-only` — build subset for that scenario
|
|
803
|
+
- `watch:local:<child>-only` — watch subset
|
|
804
|
+
- `watch:local:<app>` / `preview:local:<app>` — per-app watch/preview in localdev mode
|
|
805
|
+
|
|
806
|
+
---
|
|
807
|
+
|
|
808
|
+
## Docker & deployment
|
|
809
|
+
|
|
810
|
+
- **Dockerfile** per app (Node 22 Alpine, healthcheck)
|
|
811
|
+
- **docker-compose.yml** — all apps on mapped ports
|
|
812
|
+
- **`.npmrc`** — `install-strategy=hoisted` for federation shared deps
|
|
813
|
+
|
|
814
|
+
**Per-app environment:**
|
|
202
815
|
|
|
203
816
|
```env
|
|
204
817
|
VITE_PORT=3001
|
|
@@ -206,44 +819,114 @@ VITE_APP_NAME=billing
|
|
|
206
819
|
VITE_REMOTE_ENTRY=http://localhost:3001/assets/remoteEntry.js
|
|
207
820
|
```
|
|
208
821
|
|
|
209
|
-
|
|
822
|
+
Root `.env` lists all app ports and remote URLs (`.env.dev`, `.env.staging`, `.env.uat`, `.env.prod` variants).
|
|
823
|
+
|
|
824
|
+
```bash
|
|
825
|
+
docker compose up --build
|
|
826
|
+
```
|
|
827
|
+
|
|
828
|
+
For container-to-container federation, replace `localhost` remote URLs with Docker service hostnames.
|
|
829
|
+
|
|
830
|
+
---
|
|
831
|
+
|
|
832
|
+
## Documentation in generated projects
|
|
210
833
|
|
|
211
|
-
|
|
834
|
+
| File | Contents |
|
|
835
|
+
|------|----------|
|
|
836
|
+
| `README.md` | Ports, quick start, Docker, quality scripts |
|
|
837
|
+
| `docs/ENTERPRISE_ARCHITECTURE.md` | Design system, RBAC, federation, SDK, deployment |
|
|
838
|
+
| `docs/PLATFORM_ARCHITECTURE.md` | MF CLI, graph, cache, plugins, CI/CD |
|
|
839
|
+
| `mf.json` | Project registry, tags, federation config |
|
|
840
|
+
| `templates/README.md` | Template marketplace usage |
|
|
841
|
+
| `ai/README.md` | AI layer integration guide |
|
|
212
842
|
|
|
213
|
-
|
|
214
|
-
- parent mode generates `docker-compose.yml`
|
|
843
|
+
---
|
|
215
844
|
|
|
216
|
-
## Node version
|
|
845
|
+
## Node version
|
|
217
846
|
|
|
218
|
-
Generated projects use Vite 7
|
|
847
|
+
Generated projects use **Vite 7**. Requires:
|
|
219
848
|
|
|
220
849
|
- `>=20.19.0` or
|
|
221
|
-
- `>=22.12.0` (recommended: Node 22)
|
|
850
|
+
- `>=22.12.0` (**recommended: Node 22**)
|
|
222
851
|
|
|
223
|
-
|
|
852
|
+
Node 18 will fail on Vite 7 commands.
|
|
853
|
+
|
|
854
|
+
---
|
|
224
855
|
|
|
225
856
|
## Troubleshooting
|
|
226
857
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
858
|
+
| Issue | Fix |
|
|
859
|
+
|-------|-----|
|
|
860
|
+
| `"local" cannot be used as a mode name` | Generator uses `localdev` mode in Vite scripts |
|
|
861
|
+
| `useRoutes() may be used only in context of a <Router>` | Share `react-router-dom` as federation singleton |
|
|
862
|
+
| MUI/CSS not applied across remotes | Share `@mui/material`, `@emotion/*` as singletons |
|
|
863
|
+
| `Cannot find module 'billing/App'` | Add federation `.d.ts` declarations in host |
|
|
864
|
+
| `Task not found: live-reload` | Root `"live-reload": "node live-reload.js"` |
|
|
865
|
+
| Vite binary missing after install | Clean reinstall (see below) |
|
|
866
|
+
| Sidebar overlaps main content | Use generated flex sidebar in corelib |
|
|
867
|
+
| **Text invisible on dark header/sidebar** | Clear `localStorage` key `mf-enterprise-config`; hard refresh |
|
|
868
|
+
| `provider support react(undefined)` / `useState` null | Rebuild all apps after federation config change; host uses exact `version: "19.0.0"`, remotes use `requiredVersion: "^19.0.0"` |
|
|
869
|
+
| `ENOENT @mui/icons-material` in host | Hoisted install + federation shared versions on host |
|
|
870
|
+
| Build error `Could not resolve enterpriseGlobalCss` | Update to latest `@multisystemsuite/create-mf-app` |
|
|
871
|
+
|
|
872
|
+
**Clean reinstall:**
|
|
873
|
+
|
|
874
|
+
```bash
|
|
875
|
+
rmdir /s /q node_modules
|
|
876
|
+
del package-lock.json
|
|
877
|
+
npm cache verify
|
|
878
|
+
npm install
|
|
879
|
+
npm run build:local
|
|
880
|
+
```
|
|
881
|
+
|
|
882
|
+
**Reset theme cache:**
|
|
883
|
+
|
|
884
|
+
```js
|
|
885
|
+
localStorage.removeItem('mf-enterprise-config')
|
|
886
|
+
```
|
|
887
|
+
|
|
888
|
+
---
|
|
889
|
+
|
|
890
|
+
## Develop & publish this package
|
|
891
|
+
|
|
892
|
+
For **contributors** working on the CLI itself (this repo):
|
|
893
|
+
|
|
894
|
+
```bash
|
|
895
|
+
git clone https://github.com/your-org/create-mf-app
|
|
896
|
+
cd create-mf-app
|
|
897
|
+
npm install
|
|
898
|
+
npm run build # tsup → dist/
|
|
899
|
+
npm run dev # run dist/index.js locally
|
|
900
|
+
|
|
901
|
+
# test code changes
|
|
902
|
+
node dist/index.js test-app --type=child --port=3001 --template=tsx
|
|
903
|
+
|
|
904
|
+
# dry-run npm pack contents
|
|
905
|
+
npm run pack:check
|
|
906
|
+
|
|
907
|
+
# publish to npm (maintainers)
|
|
908
|
+
npm run rebuild
|
|
909
|
+
npm publish --access public
|
|
910
|
+
```
|
|
911
|
+
|
|
912
|
+
**Package name:** `@multisystemsuite/create-mf-app`
|
|
913
|
+
**Binary:** `create-mf-app`
|
|
914
|
+
**Published files:** `dist/`, `README.md`
|
|
915
|
+
|
|
916
|
+
---
|
|
917
|
+
|
|
918
|
+
## Summary
|
|
919
|
+
|
|
920
|
+
| Layer | How you use it |
|
|
921
|
+
|-------|----------------|
|
|
922
|
+
| **Scaffold** | `npx create-mf-app <name> --type=parent --children=… --shared=corelib` |
|
|
923
|
+
| **Daily dev** | `npm run local` (all apps) or `npm run billing` (one module) |
|
|
924
|
+
| **Shared UI / theme** | Import from `corelib/*` federation exposes |
|
|
925
|
+
| **New remote** | `npm run mf -- generate app <name>` |
|
|
926
|
+
| **Enterprise modules** | Flags: `--auth`, `--charts`, `--i18n`, … |
|
|
927
|
+
| **Monorepo platform** | `mf graph`, `mf affected build`, `mf doctor` |
|
|
928
|
+
| **Federation** | Host :3000 loads remotes; shared React/MUI singletons |
|
|
929
|
+
| **Design system** | `AppConfigProvider` + tokens + runtime theme toggle |
|
|
930
|
+
| **Deploy** | `npm run build` → CDN dist + Helm / Docker |
|
|
931
|
+
|
|
932
|
+
**Module Federation + Vite — React-first, enterprise-grade, plugin-driven.**
|