Created
June 20, 2022 03:54
-
-
Save helton/f613e39ab6c1a23455b0d8bb96c206f1 to your computer and use it in GitHub Desktop.
Module Federation with Angular without ESM modules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.json') | |
); | |
module.exports = { | |
output: { | |
uniqueName: "products", | |
publicPath: "auto", | |
scriptType: 'text/javascript' | |
}, | |
optimization: { | |
runtimeChunk: false | |
}, | |
resolve: { | |
alias: { | |
...sharedMappings.getAliases(), | |
} | |
}, | |
experiments: { | |
outputModule: true | |
}, | |
plugins: [ | |
new ModuleFederationPlugin({ | |
name: "products", | |
filename: "remoteEntry.js", | |
exposes: { | |
'./Entrypoint': './src/entrypoint.ts', | |
}, | |
shared: share({ | |
"@angular/core": { singleton: true, strictVersion: true, requiredVersion: 'auto' }, | |
"@angular/common": { singleton: true, strictVersion: true, requiredVersion: 'auto' }, | |
"@angular/router": { singleton: true, strictVersion: true, requiredVersion: 'auto' }, | |
"@angular/common/http": { singleton: true, strictVersion: true, requiredVersion: 'auto' }, | |
// Uncomment for sharing lib of an Angular CLI or Nx workspace | |
...sharedMappings.getDescriptors() | |
}) | |
}), | |
// Uncomment for sharing lib of an Angular CLI or Nx workspace | |
sharedMappings.getPlugin(), | |
], | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment