Skip to content

Commit d4bf6f0

Browse files
committed
feat(nf): migrate to angular 20
1 parent 114749d commit d4bf6f0

File tree

14 files changed

+18190
-20223
lines changed

14 files changed

+18190
-20223
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,5 @@ migrations.json
4747
.angular
4848

4949
.nx
50+
.cursor/rules/nx-rules.mdc
51+
.github/instructions/nx.instructions.md

apps/mfe1/project.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"projectType": "application",
55
"sourceRoot": "apps/mfe1/src",
66
"prefix": "angular-architects",
7+
"tags": [],
78
"targets": {
89
"build": {
910
"executor": "@angular-architects/native-federation:build",
@@ -61,7 +62,8 @@
6162
"buildTarget": "mfe1:build:development"
6263
}
6364
},
64-
"defaultConfiguration": "development"
65+
"defaultConfiguration": "development",
66+
"continuous": true
6567
},
6668
"extract-i18n": {
6769
"executor": "@angular-devkit/build-angular:extract-i18n",
@@ -82,6 +84,5 @@
8284
"jestConfig": "apps/mfe1/jest.config.ts"
8385
}
8486
}
85-
},
86-
"tags": []
87+
}
8788
}

apps/mfe2/project.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"projectType": "application",
55
"sourceRoot": "apps/mfe2/src",
66
"prefix": "angular-architects",
7+
"tags": [],
78
"targets": {
89
"build": {
910
"executor": "@angular-architects/native-federation:build",
@@ -62,7 +63,8 @@
6263
}
6364
},
6465
"defaultConfiguration": "development",
65-
"options": {}
66+
"options": {},
67+
"continuous": true
6668
},
6769
"extract-i18n": {
6870
"executor": "@angular-devkit/build-angular:extract-i18n",
@@ -83,6 +85,5 @@
8385
"jestConfig": "apps/mfe2/jest.config.ts"
8486
}
8587
}
86-
},
87-
"tags": []
88+
}
8889
}

apps/playground/project.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"projectType": "application",
55
"sourceRoot": "apps/playground/src",
66
"prefix": "angular-architects",
7+
"tags": [],
78
"targets": {
89
"demo": {
910
"executor": "@angular-architects/native-federation:build",
@@ -68,7 +69,8 @@
6869
"buildTarget": "playground:build:development"
6970
}
7071
},
71-
"defaultConfiguration": "development"
72+
"defaultConfiguration": "development",
73+
"continuous": true
7274
},
7375
"extract-i18n": {
7476
"executor": "@angular-devkit/build-angular:extract-i18n",
@@ -93,6 +95,5 @@
9395
"jestConfig": "apps/playground/jest.config.ts"
9496
}
9597
}
96-
},
97-
"tags": []
98+
}
9899
}

jest.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { getJestProjects } from '@nx/jest';
1+
import { getJestProjectsAsync } from '@nx/jest';
22

3-
export default {
4-
projects: getJestProjects(),
5-
};
3+
export default async () => ({
4+
projects: await getJestProjectsAsync(),
5+
});

libs/mf/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ We are going to provide at least one major per Angular major to keep track with
5656
- Angular 17: @angular-architects/module-federation: ^17.0.0
5757
- Angular 18: @angular-architects/module-federation: ^18.0.0
5858
- Angular 19: @angular-architects/module-federation: ^19.0.0
59+
- Angular 20: @angular-architects/module-federation: ^20.0.0
5960

6061
Beginning with Angular 13, we had to add some changes to adjust to the Angular CLI. Please see the next section for this.
6162

libs/native-federation-core/src/lib/core/bundle-shared.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export async function bundleShared(
4848
const packageInfos = [...inferedPackageInfos, ...configuredPackageInfos];
4949

5050
const configState =
51-
'BUNDLER_CHUNKS' + // TODO: Replace this with lib version
51+
'BUNDLER_CHUNKS' + // TODO: Replace this with lib version
5252
fs.readFileSync(path.join(__dirname, '../../../package.json')) +
5353
JSON.stringify(config);
5454

@@ -158,7 +158,9 @@ export async function bundleShared(
158158

159159
// TODO: Decide whether/when to add .map files
160160
const chunks = bundleResult.filter(
161-
(br) => !br.fileName.endsWith('.map') && !result.find((r) => r.outFileName === path.basename(br.fileName))
161+
(br) =>
162+
!br.fileName.endsWith('.map') &&
163+
!result.find((r) => r.outFileName === path.basename(br.fileName))
162164
);
163165

164166
addChunksToResult(chunks, result, fedOptions.dev);
@@ -234,7 +236,7 @@ function buildResult(
234236
version: pi.version,
235237
// TODO: Decide whether/when we need debug infos
236238
// dev: !fedOptions.dev
237-
// ? undefined
239+
// ? undefined
238240
// : {
239241
// entryPoint: normalize(pi.entryPoint),
240242
// },

libs/native-federation-node/project.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
"projectType": "library",
66
"release": {
77
"version": {
8-
"generatorOptions": {
9-
"packageRoot": "dist/{projectRoot}",
10-
"currentVersionResolver": "git-tag"
11-
}
8+
"currentVersionResolver": "git-tag",
9+
"preserveLocalDependencyProtocols": false,
10+
"manifestRootsToUpdate": ["dist/{projectRoot}"]
1211
}
1312
},
1413
"tags": ["org:softarc", "scope:nf"],

libs/native-federation/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular-architects/native-federation",
3-
"version": "19.0.23",
3+
"version": "20.0.0",
44
"main": "src/index.js",
55
"generators": "./collection.json",
66
"builders": "./builders.json",

libs/native-federation/src/builders/build/builder.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616

1717
import { normalizeOptions } from '@angular-devkit/build-angular/src/builders/dev-server/options';
1818

19+
1920
import { setLogLevel, logger } from '@softarc/native-federation/build';
2021

2122
import { FederationOptions } from '@softarc/native-federation/build';
@@ -136,6 +137,10 @@ export async function* runBuilder(
136137

137138
setLogLevel(options.verbose ? 'verbose' : 'info');
138139

140+
if (!options.outputPath) {
141+
options.outputPath = `dist/${context.target.project}`;
142+
}
143+
139144
const outputPath = options.outputPath;
140145
const outputOptions: Required<
141146
Exclude<ApplicationBuilderOptions['outputPath'], string>
@@ -212,11 +217,11 @@ export async function* runBuilder(
212217
const lookup = mrmime.lookup;
213218
const mimeType = lookup(path.extname(fileName)) || 'text/javascript';
214219
const rawBody = fs.readFileSync(fileName, 'utf-8');
215-
220+
216221
// TODO: Evaluate need for debug infos
217222
// const body = addDebugInformation(url, rawBody);
218223
const body = rawBody;
219-
224+
220225
res.writeHead(200, {
221226
'Content-Type': mimeType,
222227
'Access-Control-Allow-Origin': '*',
@@ -299,13 +304,13 @@ export async function* runBuilder(
299304
for await (const output of builderRun) {
300305
lastResult = output;
301306

302-
if (!write && output.outputFiles) {
303-
memResults.add(output.outputFiles.map((file) => new EsBuildResult(file)));
307+
if (!write && output['outputFiles']) {
308+
memResults.add(output['outputFiles'].map((file) => new EsBuildResult(file)));
304309
}
305310

306-
if (!write && output.assetFiles) {
311+
if (!write && output['assetFiles']) {
307312
memResults.add(
308-
output.assetFiles.map((file) => new NgCliAssetResult(file))
313+
output['assetFiles'].map((file) => new NgCliAssetResult(file))
309314
);
310315
}
311316

0 commit comments

Comments
 (0)