I am trying to share my shared auth library in my microfrontends in the SharedMappings in the webpackconfig but whenever I serve the app I get the following error:
ENOENT: no such file or directory, scandir 'C:\Users\stefa\Local_Storage\advanced-nx-workspace\node_modules@flight-workspace\shared\util-auth'
So it seems like it is searching in the node_modules instead of using the typescript path mapping from the tsconfig.
webpackconfig:
const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');
const mf = require('@angular-architects/module-federation/webpack');
const path = require('path');
const share = mf.share;
const sharedMappings = new mf.SharedMappings();
sharedMappings.register(path.join(__dirname, '../../tsconfig.base.json'), [
'@flight-workspace/shared/util-auth',
]);
module.exports = {
output: {
uniqueName: 'passenger',
publicPath: 'auto',
},
optimization: {
runtimeChunk: false,
},
resolve: {
alias: {
...sharedMappings.getAliases(),
},
},
experiments: {
outputModule: true,
},
plugins: [
new ModuleFederationPlugin({
library: { type: 'module' },
// For remotes (please adjust)
name: 'passenger',
filename: 'remoteEntry.js', // <-- Metadata generated by webpack
exposes: {
'./Module': './apps/passenger/src/app/passenger/passenger.module.ts',
},
shared: share({
'@angular/core': {
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
},
'@angular/common': {
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
},
'@angular/common/http': {
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
},
'@angular/router': {
singleton: true,
strictVersion: true,
requiredVersion: 'auto',
},
...sharedMappings.getDescriptors(),
}),
}),
sharedMappings.getPlugin(),
],
};