Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(module-federation): add comment clarifying default export in config file #28675

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,10 @@ exports[`Host App Generator --ssr should generate the correct files 5`] = `
`;

exports[`Host App Generator --ssr should generate the correct files 6`] = `
"module.exports = {
"/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
module.exports = {
name: 'test',
/**
* To use a remote that does not exist in your current Nx Workspace
Expand Down Expand Up @@ -421,7 +424,10 @@ 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 = {
"/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
module.exports = {
name: 'test',
/**
* To use a remote that does not exist in your current Nx Workspace
Expand Down Expand Up @@ -655,6 +661,9 @@ const config: ModuleFederationConfig = {
remotes: []
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
export default config;
"
`;
Expand Down Expand Up @@ -890,6 +899,9 @@ const config: ModuleFederationConfig = {
remotes: []
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
export default config;
"
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ exports[`MF Remote App Generator --ssr should generate the correct files 5`] = `
`;

exports[`MF Remote App Generator --ssr should generate the correct files 6`] = `
"module.exports = {
"/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
module.exports = {
name: 'test',
exposes: {
'./Module': 'test/src/app/remote-entry/entry.module.ts',
Expand Down Expand Up @@ -441,6 +444,9 @@ const config: ModuleFederationConfig = {
},
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
export default config;
"
`;
Expand Down Expand Up @@ -623,7 +629,10 @@ bootstrapApplication(RemoteEntryComponent, appConfig).catch((err) =>
`;

exports[`MF Remote App Generator should generate the a remote setup for standalone components 2`] = `
"module.exports = {
"/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
module.exports = {
name: 'test',
exposes: {
'./Routes': 'test/src/app/remote-entry/entry.routes.ts',
Expand Down Expand Up @@ -691,6 +700,9 @@ const config: ModuleFederationConfig = {
},
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
export default config;
"
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ 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 = {
"/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
module.exports = {
name: 'app1',
/**
* To use a remote that does not exist in your current Nx Workspace
Expand Down Expand Up @@ -112,12 +115,18 @@ const config: ModuleFederationConfig = {
remotes: ['remote1','remote2',]
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
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 = {
"/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
module.exports = {
name: 'app1',
/**
* To use a remote that does not exist in your current Nx Workspace
Expand Down Expand Up @@ -156,6 +165,9 @@ const config: ModuleFederationConfig = {
remotes: ['remote1',]
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
export default config;
"
`;
Expand Down Expand Up @@ -208,7 +220,10 @@ module.exports = withModuleFederation(config, { dts: false });
`;

exports[`Init MF should create webpack and mf configs correctly 2`] = `
"module.exports = {
"/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
module.exports = {
name: 'app1',
/**
* To use a remote that does not exist in your current Nx Workspace
Expand Down Expand Up @@ -241,7 +256,10 @@ module.exports = withModuleFederation(config, { dts: false });
`;

exports[`Init MF should create webpack and mf configs correctly 4`] = `
"module.exports = {
"/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
module.exports = {
name: 'remote1',
exposes: {
'./Module': 'remote1/src/app/remote-entry/entry.module.ts',
Expand Down Expand Up @@ -283,6 +301,9 @@ const config: ModuleFederationConfig = {
remotes: []
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
export default config;
"
`;
Expand Down Expand Up @@ -310,6 +331,9 @@ const config: ModuleFederationConfig = {
},
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
export default config;
"
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ const config: ModuleFederationConfig = {
},<% } %>
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
export default config;
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
module.exports = {
name: '<%= name %>',<% if(type === 'host') { %>
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ const moduleFederationConfig = {
remotes: [],
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
module.exports = moduleFederationConfig;
"
`;
Expand Down Expand Up @@ -73,6 +76,9 @@ const config: ModuleFederationConfig = {
remotes: [],
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
export default config;
"
`;
Expand Down Expand Up @@ -103,7 +109,10 @@ module.exports = composePlugins(
`;

exports[`hostGenerator bundler=webpack should generate host files and configs when --typescriptConfiguration=false 2`] = `
"module.exports = {
"/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
module.exports = {
name: 'test',
/**
* To use a remote that does not exist in your current Nx Workspace
Expand Down Expand Up @@ -165,6 +174,9 @@ const config: ModuleFederationConfig = {
],
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
export default config;
"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ const config: ModuleFederationConfig = {
],
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ const moduleFederationConfig = {
],
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
module.exports = moduleFederationConfig;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ const config: ModuleFederationConfig = {
],
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
export default config;
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
module.exports = {
name: '<%= projectName %>',
/**
Expand All @@ -18,4 +21,4 @@ module.exports = {
}
%>
],
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ const config: ModuleFederationConfig = {
],
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ const moduleFederationConfig = {
],
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
module.exports = moduleFederationConfig;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@ const config: ModuleFederationConfig = {
],
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
export default config;
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
module.exports = {
name: '<%= projectName %>',
/**
Expand All @@ -18,4 +21,4 @@ module.exports = {
}
%>
],
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ module.exports = composePlugins(withNx(), withReact(), withModuleFederation(conf
exports[`remote generator bundler=rspack should create the remote with the correct config files 2`] = `"module.exports = require('./rspack.config');"`;

exports[`remote generator bundler=rspack should create the remote with the correct config files 3`] = `
"module.exports = {
"/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
module.exports = {
name: 'test',

exposes: {
Expand Down Expand Up @@ -56,7 +59,10 @@ module.exports = composePlugins(withNx(), withReact(), withModuleFederation(conf
exports[`remote generator bundler=rspack should create the remote with the correct config files when --js=true 2`] = `"module.exports = require('./rspack.config');"`;

exports[`remote generator bundler=rspack should create the remote with the correct config files when --js=true 3`] = `
"module.exports = {
"/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
module.exports = {
name: 'test',

exposes: {
Expand Down Expand Up @@ -106,6 +112,9 @@ const config: ModuleFederationConfig = {
},
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
export default config;
"
`;
Expand All @@ -131,7 +140,10 @@ module.exports = composePlugins(withNx(), withReact({ssr: true}), withModuleFede
`;

exports[`remote generator bundler=rspack should generate correct remote with config files when using --ssr 2`] = `
"module.exports = {
"/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
module.exports = {
name: 'test',
exposes: {
'./Module': './src/remote-entry.ts',
Expand Down Expand Up @@ -174,6 +186,9 @@ const config: ModuleFederationConfig = {
},
};

/**
* Nx requires a default export of the config to allow correct resolution of the module federation graph.
**/
export default config;
"
`;
Loading