Nx loading in multiple instances of packages and the shared function in webpack.config.js does nothing #26043
Closed
1 of 4 tasks
Labels
blocked: more info needed
outdated
scope: module federation
Issues related to module federation support
scope: react
Issues related to React support for Nx
stale
type: bug
Current Behavior
The shared function in the webpack.config.js doesn't do anything:
`
import { composePlugins, withNx } from '@nx/webpack';
import { withReact } from '@nx/react';
import { withModuleFederation } from '@nx/react/module-federation';
import baseConfig from './module-federation.config';
const coreLibraries = new Set([
"test"
]);
const config = {
...baseConfig,
shared: (libraryName, defaultConfig) => {
console.log('libraryName:', libraryName);
throw new Error('shared');
// Returning false means the library is not shared.
return defaultConfig;
},
};
// Nx plugins for webpack to build config object from Nx options and context.
export default composePlugins(
withNx(),
withReact(),
withModuleFederation(config)
);
`
The shared function never does any console.log or hits the exception here.
There is no issue on standalone mode, only when ingesting remote federated modules from a shell is there a problem.
Expected Behavior
The shared function should get triggered and work to prevent duplicate packages
GitHub Repo
https://github.com/Aubrey-Russell/grommet-react-mfe-issue-example
Steps to Reproduce
Nx Report
Failure Logs
No response
Package Manager Version
No response
Operating System
Additional Information
No response
The text was updated successfully, but these errors were encountered: