Skip to content

Commit

Permalink
feat(angular): add static-server target to ssr mf remote (#13440)
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 authored Nov 28, 2022
1 parent fd1e478 commit 9469dba
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
11 changes: 11 additions & 0 deletions packages/angular/src/generators/remote/lib/add-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions packages/angular/src/generators/remote/remote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});

0 comments on commit 9469dba

Please sign in to comment.