Skip to content

Commit

Permalink
fix(module-federation): add comment clarifying default export in conf…
Browse files Browse the repository at this point in the history
…ig file (#28675)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
  • Loading branch information
Coly010 authored Oct 29, 2024
1 parent aec53a0 commit 5a3fd0e
Show file tree
Hide file tree
Showing 24 changed files with 161 additions and 17 deletions.
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

0 comments on commit 5a3fd0e

Please sign in to comment.