Skip to content

Commit 62c04cb

Browse files
committed
Step 1 - Align plugin config with Angular Devkit standards; update executors for seamless NX integration.
1 parent 6db714c commit 62c04cb

File tree

5 files changed

+70
-9
lines changed

5 files changed

+70
-9
lines changed

apps/mf1-application/project.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"tags": [],
88
"targets": {
99
"build": {
10-
"executor": "@angular-devkit/build-angular:application",
10+
"dependsOn": ["^build"],
11+
"executor": "./dist/libs/nx-angular-mf:build",
1112
"outputs": ["{options.outputPath}"],
1213
"options": {
1314
"outputPath": "dist/apps/mf1-application",
@@ -49,7 +50,8 @@
4950
"defaultConfiguration": "production"
5051
},
5152
"serve": {
52-
"executor": "@angular-devkit/build-angular:dev-server",
53+
"dependsOn": ["^build"],
54+
"executor": "./dist/libs/nx-angular-mf:serve",
5355
"configurations": {
5456
"production": {
5557
"buildTarget": "mf1-application:build:production"

apps/mf2-application/project.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"tags": [],
88
"targets": {
99
"build": {
10-
"executor": "@angular-devkit/build-angular:application",
10+
"dependsOn": ["^build"],
11+
"executor": "./dist/libs/nx-angular-mf:build",
1112
"outputs": ["{options.outputPath}"],
1213
"options": {
1314
"outputPath": "dist/apps/mf2-application",
@@ -49,7 +50,8 @@
4950
"defaultConfiguration": "production"
5051
},
5152
"serve": {
52-
"executor": "@angular-devkit/build-angular:dev-server",
53+
"dependsOn": ["^build"],
54+
"executor": "./dist/libs/nx-angular-mf:serve",
5355
"configurations": {
5456
"production": {
5557
"buildTarget": "mf2-application:build:production"
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
import { BuilderContext, createBuilder } from '@angular-devkit/architect';
2+
import { buildApplication } from '@angular-devkit/build-angular';
23

34
import { BuildExecutorSchema } from './schema';
45

6+
57
export async function* runBuilder(
68
options: BuildExecutorSchema,
79
context: BuilderContext
810
) {
911
context.logger.info('Run build mf');
10-
yield {
11-
success: true,
12+
13+
const { mf: defaultOptionsMfe, ...defaultOptions } = options;
14+
15+
const extensions = {
16+
codePlugins: [],
17+
indexHtmlTransformer: (input) => {
18+
return input;
19+
},
1220
};
21+
22+
yield* buildApplication(defaultOptions as any, context, extensions);
1323
}
1424

1525
export default createBuilder(runBuilder);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export type SchemaMf = {
2-
mf?: {};
2+
mf?: Record<string, unknown>;
33
};
Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,62 @@
11
import { BuilderContext, createBuilder } from '@angular-devkit/architect';
2+
import { normalizeOptions } from '@angular-devkit/build-angular/src/builders/dev-server/options';
3+
import {
4+
serveWithVite,
5+
buildApplicationInternal,
6+
} from '@angular/build/private';
7+
28

39
import { ServeExecutorSchema } from './schema';
410

11+
12+
function getBuilderAction() {
13+
return async function* (options, context, extensions) {
14+
15+
for await (const result of buildApplicationInternal(
16+
options,
17+
context,
18+
extensions
19+
)) {
20+
yield result;
21+
}
22+
};
23+
}
24+
525
export async function* runBuilder(
626
options: ServeExecutorSchema,
727
context: BuilderContext
828
) {
929
context.logger.info('Run serve mf');
10-
yield {
11-
success: true,
30+
31+
32+
const normalizeOuterOptions = await normalizeOptions(
33+
context,
34+
context.target.project,
35+
options as any
36+
);
37+
38+
const extensions = {
39+
middleware: [],
40+
buildPlugins: [],
1241
};
42+
43+
const transforms = {
44+
indexHtml: async (input: string) => {
45+
return input
46+
},
47+
};
48+
49+
const runServer = serveWithVite(
50+
normalizeOuterOptions,
51+
'@angular-devkit/build-angular:application',
52+
getBuilderAction(),
53+
context,
54+
transforms,
55+
extensions
56+
);
57+
for await (const output of runServer) {
58+
yield output;
59+
}
1360
}
1461

1562
export default createBuilder(runBuilder);

0 commit comments

Comments
 (0)