feat(angular): add static-server target to ssr mf remote (#13440)

This commit is contained in:
Colum Ferry 2022-11-28 13:11:34 +00:00 committed by GitHub
parent fd1e478b80
commit 9469dbaac9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 0 deletions

View File

@ -182,6 +182,26 @@ Object {
}
`;
exports[`MF Remote App Generator --ssr should generate the correct files 12`] = `
"import { Route } from '@angular/router';
import { RemoteEntryComponent } from './entry.component';
export const remoteRoutes: Route[] = [{ path: '', component: RemoteEntryComponent }];"
`;
exports[`MF Remote App Generator --ssr should generate the correct files 13`] = `
Object {
"dependsOn": Array [
"build",
"server",
],
"executor": "nx:run-commands",
"options": Object {
"command": "PORT=4201 node dist/apps/test/server/main.js",
},
}
`;
exports[`MF Remote App Generator should generate a remote mf app with a host 1`] = `
"const { withModuleFederation } = require('@nrwl/angular/module-federation');
const config = require('./module-federation.config');

View File

@ -50,6 +50,17 @@ export async function addSsr(
port,
};
project.targets['static-server'] = {
dependsOn: ['build', 'server'],
executor: 'nx:run-commands',
options: {
command: `PORT=${port} node ${joinPathFragments(
project.targets.server.options.outputPath,
'main.js'
)}`,
},
};
updateProjectConfiguration(tree, appName, project);
const installTask = addDependenciesToPackageJson(

View File

@ -241,6 +241,10 @@ describe('MF Remote App Generator', () => {
tree.read(`apps/test/src/app/remote-entry/entry.routes.ts`, 'utf-8')
).toMatchSnapshot();
expect(project.targets.server).toMatchSnapshot();
expect(
tree.read(`apps/test/src/app/remote-entry/entry.routes.ts`, 'utf-8')
).toMatchSnapshot();
expect(project.targets['static-server']).toMatchSnapshot();
});
});
});