Skip to content

Commit c251f8e

Browse files
committed
Step 2 - Add wrapper to handle TypeScript module resolution errors; improve flexibility for defining routes.
1 parent 596a372 commit c251f8e

File tree

7 files changed

+37
-6
lines changed

7 files changed

+37
-6
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
<lib-test-shared-library/>
2+
<a routerLink="/">main</a> | <a routerLink="/first">first1aa</a>
13
<router-outlet></router-outlet>

apps/host-application/src/app/app.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Component } from '@angular/core';
22
import { RouterModule } from '@angular/router';
3+
import { TestSharedLibraryComponent } from '@nx-angular-mf/test-shared-library';
34

45
@Component({
5-
imports: [RouterModule],
6+
imports: [RouterModule, TestSharedLibraryComponent],
67
selector: 'app-root',
78
templateUrl: './app.component.html',
89
styleUrl: './app.component.css',
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { Route } from '@angular/router';
2+
import { loadModule } from '@klerick/nx-angular-mf/loadModule';
23

34
export const appRoutes: Route[] = [{
45
path: '',
56
loadComponent: () => import('./nx-welcome.component').then(r => r.NxWelcomeComponent)
6-
}];
7+
}, {
8+
path: 'first',
9+
loadChildren: () =>
10+
loadModule<{ firstRoutes: Route[] }>('firstRemote/FirstRemoteRoute').then(
11+
(r) => r.firstRoutes
12+
),
13+
},];

apps/mf1-application/tsconfig.app.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,18 @@
44
"outDir": "../../dist/out-tsc",
55
"types": []
66
},
7-
"files": ["src/main.ts", "../../libs/nx-angular-mf/src/index.ts", "src/app/remote/second/index.ts"],
8-
"include": ["src/**/*.d.ts"],
9-
"exclude": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts"]
7+
"files": [
8+
"src/main.ts",
9+
"src/app/remote/second/index.ts",
10+
"../../libs/nx-angular-mf/src/loadModule.ts",
11+
"../../libs/nx-angular-mf/src/index.ts"
12+
],
13+
"include": [
14+
"src/**/*.d.ts"
15+
],
16+
"exclude": [
17+
"jest.config.ts",
18+
"src/**/*.test.ts",
19+
"src/**/*.spec.ts"
20+
]
1021
}

libs/nx-angular-mf/project.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@
4949
"glob": "executors.json",
5050
"output": "."
5151
}
52-
]
52+
],
53+
"additionalEntryPoints": [
54+
"libs/nx-angular-mf/src/loadModule.ts"
55+
],
56+
"generateExportsField": true
5357
}
5458
},
5559
"nx-release-publish": {

libs/nx-angular-mf/src/loadModule.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export async function loadModule<T = any>(url: string): Promise<T> {
2+
return import(/* @vite-ignore */ url);
3+
}

tsconfig.base.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
"baseUrl": ".",
1717
"paths": {
1818
"@klerick/nx-angular-mf": ["libs/nx-angular-mf/src/index.ts"],
19+
"@klerick/nx-angular-mf/loadModule": [
20+
"libs/nx-angular-mf/src/loadModule.ts"
21+
],
1922
"@nx-angular-mf/test-shared-library": [
2023
"libs/test-shared-library/src/index.ts"
2124
]

0 commit comments

Comments
 (0)