feat(module-federation): add comment to generated module federation config explaining usage of external remotes (#20177)
This commit is contained in:
parent
58575616c0
commit
2a85bb48b5
@ -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`] = `
|
exports[`Host App Generator --ssr should generate the correct files 6`] = `
|
||||||
"module.exports = {
|
"module.exports = {
|
||||||
name: 'test',
|
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: [],
|
remotes: [],
|
||||||
};
|
};
|
||||||
"
|
"
|
||||||
@ -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`] = `
|
exports[`Host App Generator --ssr should generate the correct files for standalone 5`] = `
|
||||||
"module.exports = {
|
"module.exports = {
|
||||||
name: 'test',
|
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: [],
|
remotes: [],
|
||||||
};
|
};
|
||||||
"
|
"
|
||||||
@ -558,6 +582,18 @@ exports[`Host App Generator --ssr should generate the correct files for standalo
|
|||||||
|
|
||||||
const config: ModuleFederationConfig = {
|
const config: ModuleFederationConfig = {
|
||||||
name: 'test',
|
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: [],
|
remotes: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -775,6 +811,18 @@ exports[`Host App Generator --ssr should generate the correct files when --types
|
|||||||
|
|
||||||
const config: ModuleFederationConfig = {
|
const config: ModuleFederationConfig = {
|
||||||
name: 'test',
|
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: [],
|
remotes: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -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`] = `
|
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 = {
|
"module.exports = {
|
||||||
name: 'app1',
|
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'],
|
remotes: ['remote1', 'remote2'],
|
||||||
};
|
};
|
||||||
"
|
"
|
||||||
@ -56,6 +68,18 @@ exports[`Init MF should add a remote application and add it to a specified host
|
|||||||
|
|
||||||
const config: ModuleFederationConfig = {
|
const config: ModuleFederationConfig = {
|
||||||
name: 'app1',
|
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'],
|
remotes: ['remote1', 'remote2'],
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -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`] = `
|
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 = {
|
"module.exports = {
|
||||||
name: 'app1',
|
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'],
|
remotes: ['remote1'],
|
||||||
};
|
};
|
||||||
"
|
"
|
||||||
@ -76,6 +112,18 @@ exports[`Init MF should add a remote application and add it to a specified host
|
|||||||
|
|
||||||
const config: ModuleFederationConfig = {
|
const config: ModuleFederationConfig = {
|
||||||
name: 'app1',
|
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'],
|
remotes: ['remote1'],
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -131,6 +179,18 @@ module.exports = withModuleFederation(config);
|
|||||||
exports[`Init MF should create webpack and mf configs correctly 2`] = `
|
exports[`Init MF should create webpack and mf configs correctly 2`] = `
|
||||||
"module.exports = {
|
"module.exports = {
|
||||||
name: 'app1',
|
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: [],
|
remotes: [],
|
||||||
};
|
};
|
||||||
"
|
"
|
||||||
@ -166,6 +226,18 @@ exports[`Init MF should create webpack and mf configs correctly when --typescrip
|
|||||||
|
|
||||||
const config: ModuleFederationConfig = {
|
const config: ModuleFederationConfig = {
|
||||||
name: 'app1',
|
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: [],
|
remotes: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,18 @@ import { ModuleFederationConfig } from '@nx/webpack';
|
|||||||
|
|
||||||
const config: ModuleFederationConfig = {
|
const config: ModuleFederationConfig = {
|
||||||
name: '<%= name %>',<% if(type === 'host') { %>
|
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') { %>
|
remotes: [<% remotes.forEach(function(remote) { %>'<%= remote.remoteName %>',<% }); %>]<% } %><% if(type === 'remote') { %>
|
||||||
exposes: {<% if(standalone) { %>
|
exposes: {<% if(standalone) { %>
|
||||||
'./Routes': '<%= projectRoot %>/src/app/remote-entry/entry.routes.ts',<% } else { %>
|
'./Routes': '<%= projectRoot %>/src/app/remote-entry/entry.routes.ts',<% } else { %>
|
||||||
|
|||||||
@ -1,8 +1,20 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: '<%= name %>',<% if(type === 'host') { %>
|
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') { %>
|
remotes: [<% remotes.forEach(function(remote) { %>'<%= remote.remoteName %>',<% }); %>]<% } %><% if(type === 'remote') { %>
|
||||||
exposes: {<% if(standalone) { %>
|
exposes: {<% if(standalone) { %>
|
||||||
'./Routes': '<%= projectRoot %>/src/app/remote-entry/entry.routes.ts',<% } else { %>
|
'./Routes': '<%= projectRoot %>/src/app/remote-entry/entry.routes.ts',<% } else { %>
|
||||||
'./Module': '<%= projectRoot %>/src/app/remote-entry/entry.module.ts',<% } %>
|
'./Module': '<%= projectRoot %>/src/app/remote-entry/entry.module.ts',<% } %>
|
||||||
},<% } %>
|
},<% } %>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,18 @@ module.exports = composePlugins(
|
|||||||
exports[`hostGenerator should generate host files and configs 2`] = `
|
exports[`hostGenerator should generate host files and configs 2`] = `
|
||||||
"module.exports = {
|
"module.exports = {
|
||||||
name: 'test',
|
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: [],
|
remotes: [],
|
||||||
};
|
};
|
||||||
"
|
"
|
||||||
@ -120,6 +132,18 @@ exports[`hostGenerator should generate host files and configs when --typescriptC
|
|||||||
|
|
||||||
const config: ModuleFederationConfig = {
|
const config: ModuleFederationConfig = {
|
||||||
name: 'test',
|
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: [],
|
remotes: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,18 @@ import { ModuleFederationConfig } from '@nx/webpack';
|
|||||||
|
|
||||||
const config: ModuleFederationConfig = {
|
const config: ModuleFederationConfig = {
|
||||||
name: '<%= projectName %>',
|
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: [
|
||||||
<% remotes.forEach(function(r) {%> "<%= r.fileName %>", <% }); %>
|
<% remotes.forEach(function(r) {%> "<%= r.fileName %>", <% }); %>
|
||||||
],
|
],
|
||||||
|
|||||||
@ -1,5 +1,17 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
name: '<%= projectName %>',
|
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: [
|
||||||
<% remotes.forEach(function(r) {%> "<%= r.fileName %>", <% }); %>
|
<% remotes.forEach(function(r) {%> "<%= r.fileName %>", <% }); %>
|
||||||
],
|
],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user