Skip to content

Commit

Permalink
feat(module-federation): add comment to generated module federation c…
Browse files Browse the repository at this point in the history
…onfig explaining usage of external remotes (nrwl#20177)
  • Loading branch information
Coly010 authored Nov 13, 2023
1 parent 5857561 commit 2a85bb4
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,18 @@ exports[`Host App Generator --ssr should generate the correct files 5`] = `
exports[`Host App Generator --ssr should generate the correct files 6`] = `
"module.exports = {
name: 'test',
/**
* To use a remote that does not exist in your current Nx Workspace
* You can use the tuple-syntax to define your remote
*
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
*
* You _may_ need to add a \`remotes.d.ts\` file to your \`src/\` folder declaring the external remote for tsc, with the
* following content:
*
* declare module 'my-external-remote';
*
*/
remotes: [],
};
"
Expand Down Expand Up @@ -358,6 +370,18 @@ exports[`Host App Generator --ssr should generate the correct files for standalo
exports[`Host App Generator --ssr should generate the correct files for standalone 5`] = `
"module.exports = {
name: 'test',
/**
* To use a remote that does not exist in your current Nx Workspace
* You can use the tuple-syntax to define your remote
*
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
*
* You _may_ need to add a \`remotes.d.ts\` file to your \`src/\` folder declaring the external remote for tsc, with the
* following content:
*
* declare module 'my-external-remote';
*
*/
remotes: [],
};
"
Expand Down Expand Up @@ -558,6 +582,18 @@ exports[`Host App Generator --ssr should generate the correct files for standalo
const config: ModuleFederationConfig = {
name: 'test',
/**
* To use a remote that does not exist in your current Nx Workspace
* You can use the tuple-syntax to define your remote
*
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
*
* You _may_ need to add a \`remotes.d.ts\` file to your \`src/\` folder declaring the external remote for tsc, with the
* following content:
*
* declare module 'my-external-remote';
*
*/
remotes: [],
};
Expand Down Expand Up @@ -775,6 +811,18 @@ exports[`Host App Generator --ssr should generate the correct files when --types
const config: ModuleFederationConfig = {
name: 'test',
/**
* To use a remote that does not exist in your current Nx Workspace
* You can use the tuple-syntax to define your remote
*
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
*
* You _may_ need to add a \`remotes.d.ts\` file to your \`src/\` folder declaring the external remote for tsc, with the
* following content:
*
* declare module 'my-external-remote';
*
*/
remotes: [],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ export const appRoutes: Route[] = [
exports[`Init MF should add a remote application and add it to a specified host applications webpack config that contains a remote application already 1`] = `
"module.exports = {
name: 'app1',
/**
* To use a remote that does not exist in your current Nx Workspace
* You can use the tuple-syntax to define your remote
*
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
*
* You _may_ need to add a \`remotes.d.ts\` file to your \`src/\` folder declaring the external remote for tsc, with the
* following content:
*
* declare module 'my-external-remote';
*
*/
remotes: ['remote1', 'remote2'],
};
"
Expand All @@ -56,6 +68,18 @@ exports[`Init MF should add a remote application and add it to a specified host
const config: ModuleFederationConfig = {
name: 'app1',
/**
* To use a remote that does not exist in your current Nx Workspace
* You can use the tuple-syntax to define your remote
*
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
*
* You _may_ need to add a \`remotes.d.ts\` file to your \`src/\` folder declaring the external remote for tsc, with the
* following content:
*
* declare module 'my-external-remote';
*
*/
remotes: ['remote1', 'remote2'],
};
Expand All @@ -66,6 +90,18 @@ export default config;
exports[`Init MF should add a remote application and add it to a specified host applications webpack config when no other remote has been added to it 1`] = `
"module.exports = {
name: 'app1',
/**
* To use a remote that does not exist in your current Nx Workspace
* You can use the tuple-syntax to define your remote
*
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
*
* You _may_ need to add a \`remotes.d.ts\` file to your \`src/\` folder declaring the external remote for tsc, with the
* following content:
*
* declare module 'my-external-remote';
*
*/
remotes: ['remote1'],
};
"
Expand All @@ -76,6 +112,18 @@ exports[`Init MF should add a remote application and add it to a specified host
const config: ModuleFederationConfig = {
name: 'app1',
/**
* To use a remote that does not exist in your current Nx Workspace
* You can use the tuple-syntax to define your remote
*
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
*
* You _may_ need to add a \`remotes.d.ts\` file to your \`src/\` folder declaring the external remote for tsc, with the
* following content:
*
* declare module 'my-external-remote';
*
*/
remotes: ['remote1'],
};
Expand Down Expand Up @@ -131,6 +179,18 @@ module.exports = withModuleFederation(config);
exports[`Init MF should create webpack and mf configs correctly 2`] = `
"module.exports = {
name: 'app1',
/**
* To use a remote that does not exist in your current Nx Workspace
* You can use the tuple-syntax to define your remote
*
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
*
* You _may_ need to add a \`remotes.d.ts\` file to your \`src/\` folder declaring the external remote for tsc, with the
* following content:
*
* declare module 'my-external-remote';
*
*/
remotes: [],
};
"
Expand Down Expand Up @@ -166,6 +226,18 @@ exports[`Init MF should create webpack and mf configs correctly when --typescrip
const config: ModuleFederationConfig = {
name: 'app1',
/**
* To use a remote that does not exist in your current Nx Workspace
* You can use the tuple-syntax to define your remote
*
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
*
* You _may_ need to add a \`remotes.d.ts\` file to your \`src/\` folder declaring the external remote for tsc, with the
* following content:
*
* declare module 'my-external-remote';
*
*/
remotes: [],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ import { ModuleFederationConfig } from '@nx/webpack';

const config: ModuleFederationConfig = {
name: '<%= name %>',<% if(type === 'host') { %>
/**
* To use a remote that does not exist in your current Nx Workspace
* You can use the tuple-syntax to define your remote
*
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
*
* You _may_ need to add a `remotes.d.ts` file to your `src/` folder declaring the external remote for tsc, with the
* following content:
*
* declare module 'my-external-remote';
*
*/
remotes: [<% remotes.forEach(function(remote) { %>'<%= remote.remoteName %>',<% }); %>]<% } %><% if(type === 'remote') { %>
exposes: {<% if(standalone) { %>
'./Routes': '<%= projectRoot %>/src/app/remote-entry/entry.routes.ts',<% } else { %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
module.exports = {
name: '<%= name %>',<% if(type === 'host') { %>
/**
* To use a remote that does not exist in your current Nx Workspace
* You can use the tuple-syntax to define your remote
*
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
*
* You _may_ need to add a `remotes.d.ts` file to your `src/` folder declaring the external remote for tsc, with the
* following content:
*
* declare module 'my-external-remote';
*
*/
remotes: [<% remotes.forEach(function(remote) { %>'<%= remote.remoteName %>',<% }); %>]<% } %><% if(type === 'remote') { %>
exposes: {<% if(standalone) { %>
'./Routes': '<%= projectRoot %>/src/app/remote-entry/entry.routes.ts',<% } else { %>
'./Module': '<%= projectRoot %>/src/app/remote-entry/entry.module.ts',<% } %>
},<% } %>
}
}
24 changes: 24 additions & 0 deletions packages/react/src/generators/host/__snapshots__/host.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ module.exports = composePlugins(
exports[`hostGenerator should generate host files and configs 2`] = `
"module.exports = {
name: 'test',
/**
* To use a remote that does not exist in your current Nx Workspace
* You can use the tuple-syntax to define your remote
*
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
*
* You _may_ need to add a \`remotes.d.ts\` file to your \`src/\` folder declaring the external remote for tsc, with the
* following content:
*
* declare module 'my-external-remote';
*
*/
remotes: [],
};
"
Expand Down Expand Up @@ -120,6 +132,18 @@ exports[`hostGenerator should generate host files and configs when --typescriptC
const config: ModuleFederationConfig = {
name: 'test',
/**
* To use a remote that does not exist in your current Nx Workspace
* You can use the tuple-syntax to define your remote
*
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
*
* You _may_ need to add a \`remotes.d.ts\` file to your \`src/\` folder declaring the external remote for tsc, with the
* following content:
*
* declare module 'my-external-remote';
*
*/
remotes: [],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ import { ModuleFederationConfig } from '@nx/webpack';

const config: ModuleFederationConfig = {
name: '<%= projectName %>',
/**
* To use a remote that does not exist in your current Nx Workspace
* You can use the tuple-syntax to define your remote
*
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
*
* You _may_ need to add a `remotes.d.ts` file to your `src/` folder declaring the external remote for tsc, with the
* following content:
*
* declare module 'my-external-remote';
*
*/
remotes: [
<% remotes.forEach(function(r) {%> "<%= r.fileName %>", <% }); %>
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
module.exports = {
name: '<%= projectName %>',
/**
* To use a remote that does not exist in your current Nx Workspace
* You can use the tuple-syntax to define your remote
*
* remotes: [['my-external-remote', 'https://nx-angular-remote.netlify.app']]
*
* You _may_ need to add a `remotes.d.ts` file to your `src/` folder declaring the external remote for tsc, with the
* following content:
*
* declare module 'my-external-remote';
*
*/
remotes: [
<% remotes.forEach(function(r) {%> "<%= r.fileName %>", <% }); %>
],
Expand Down

0 comments on commit 2a85bb4

Please sign in to comment.