-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
add-entry-module.ts
34 lines (32 loc) · 997 Bytes
/
add-entry-module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import type { Tree } from '@nrwl/devkit';
import { generateFiles, joinPathFragments } from '@nrwl/devkit';
import type { Schema } from '../schema';
export function addEntryModule(
host: Tree,
{ appName, routing, mfeType, prefix }: Schema,
appRoot: string
) {
if (mfeType === 'remote') {
generateFiles(
host,
joinPathFragments(__dirname, '../files/entry-module-files'),
`${appRoot}/src/app/remote-entry`,
{
tmpl: '',
appName,
routing,
prefix,
}
);
host.write(
`${appRoot}/src/app/app.module.ts`,
`/*
* This RemoteEntryModule is imported here to allow TS to find the Module during
* compilation, allowing it to be included in the built bundle. This is required
* for the Module Federation Plugin to expose the Module correctly.
* */
import { RemoteEntryModule } from './remote-entry/entry.module';
${host.read(`${appRoot}/src/app/app.module.ts`, 'utf-8')}`
);
}
}