Skip to content

Commit 1bd6082

Browse files
committed
feat(mf): new init schematic
1 parent b24d389 commit 1bd6082

File tree

4 files changed

+88
-3
lines changed

4 files changed

+88
-3
lines changed

libs/mf/collection.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"description": "Initialize an angular project for webpack module federation"
1010
},
1111
"init": {
12-
"factory": "./src/schematics/mf/schematic#add",
13-
"schema": "./src/schematics/mf/schema.json",
14-
"description": "Initialize an angular project for webpack module federation"
12+
"factory": "./src/schematics/init/schematic#init",
13+
"schema": "./src/schematics/init/schema.json",
14+
"description": "Initialize an angular project for module federation"
1515
},
1616
"config": {
1717
"factory": "./src/schematics/mf/schematic",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export interface InitSchema {
2+
project: string;
3+
port: string;
4+
nxBuilders: boolean | undefined;
5+
type: 'host' | 'dynamic-host' | 'remote' | 'legacy';
6+
stack: 'webpack' | 'rsbuild' | 'native'
7+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"$schema": "http://json-schema.org/schema",
3+
"$id": "mf",
4+
"title": "",
5+
"type": "object",
6+
"properties": {
7+
"project": {
8+
"type": "string",
9+
"description": "The project to add module federation",
10+
"$default": {
11+
"$source": "argv",
12+
"index": 0
13+
},
14+
"x-prompt": "Project name (press enter for default project)"
15+
},
16+
"port": {
17+
"type": "number",
18+
"x-aliases": ["p"],
19+
"description": "The port to use for the federated module (remote, micro frontend, etc.)",
20+
"x-prompt": {
21+
"message": "Port to use",
22+
"type": "number"
23+
},
24+
"$default": {
25+
"$source": "argv",
26+
"index": 1
27+
}
28+
},
29+
"type": {
30+
"enum": ["host", "dynamic-host", "remote", "legacy"],
31+
"x-aliases": ["t"],
32+
"type": "string",
33+
"default": "remote"
34+
},
35+
"stack": {
36+
"type": "string",
37+
"enum": ["webpack", "rsbuild", "native"],
38+
"x-aliases": ["s"],
39+
"x-prompt": "Which stack do you want to use?",
40+
"x-enumDescriptions": {
41+
"webpack": "Module Federation with webpack: Classic option",
42+
"rsbuild": "Module Federation with rsbuild: New Experimental (!) option",
43+
"native": "Native Federation with esbuild: Technology-agnostic option"
44+
}
45+
},
46+
"nxBuilders": {
47+
"type": "boolean",
48+
"description": "Use builders provided by Nx instead of ngx-build-plus? Defaults to true for Nx workspaces and false for CLI workspaces."
49+
}
50+
},
51+
"required": ["stack"]
52+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {
2+
chain,
3+
Rule,
4+
Tree,
5+
url,
6+
apply,
7+
mergeWith,
8+
template,
9+
move,
10+
} from '@angular-devkit/schematics';
11+
12+
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
13+
14+
import {
15+
addPackageJsonDependency,
16+
getPackageJsonDependency,
17+
NodeDependencyType,
18+
} from '@schematics/angular/utility/dependencies';
19+
import { InitSchema } from './schema';
20+
21+
export default function init(options: InitSchema): Rule {
22+
return async function (tree, context) {
23+
console.log('options', options);
24+
}
25+
}
26+

0 commit comments

Comments
 (0)