Skip to content

Instantly share code, notes, and snippets.

@kahboom
Last active July 29, 2022 12:13
Show Gist options
  • Save kahboom/f771a5674d6f419f61c9c4e9ceeb51e7 to your computer and use it in GitHub Desktop.
Save kahboom/f771a5674d6f419f61c9c4e9ceeb51e7 to your computer and use it in GitHub Desktop.
Module Federation part of Kaoto: https://github.com/KaotoIO/kaoto-ui
{
"compilerOptions": {
"declaration": true,
"esModuleInterop": true,
"importHelpers": true,
"jsx": "react-jsx",
"lib": ["dom", "esnext"],
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "dist",
"sourceMap": true,
"strict": true,
"target": "es6",
},
"exclude": [
"dist",
"node_modules",
"**/*.stories.tsx",
"**/*.test.ts*",
]
}
{
"extends": "./tsconfig.build.json",
"compilerOptions": {
"allowJs": false,
"baseUrl": ".",
"declaration": true,
"paths": {
"*": ["*", "types/*"]
},
"typeRoots": ["./node_modules/@types"],
},
"include": ["src", "webpack.common.js", "setupTests.ts"]
}
const path = require('path');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const { dependencies, federatedModuleName } = require('./package.json');
const webpack = require('webpack');
// host app webpack
module.exports = () => {
return {
entry: {
app: path.resolve(__dirname, 'src', 'index.tsx'),
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: [
{
loader: 'dts-loader',
options: {
name: federatedModuleName,
exposes: {
'./integrationJson': './src/store/integrationJsonStore.tsx',
'./visualizationStore': './src/store/visualizationStore.tsx',
},
typesOutputDir: '.wp_federation',
},
},
],
},
],
},
output: {
path: path.resolve(__dirname, 'dist'),
},
plugins: [
new webpack.container.ModuleFederationPlugin({
name: federatedModuleName,
exposes: {
'./integrationJson': './src/store/integrationJsonStore.tsx',
'./visualizationStore': './src/store/visualizationStore.tsx',
},
shared: {
react: {
eager: true,
singleton: true,
requiredVersion: dependencies['react'],
},
'react-dom': {
eager: true,
singleton: true,
requiredVersion: dependencies['react-dom'],
},
'react-router-dom': {
singleton: true,
eager: true,
requiredVersion: dependencies['react-router-dom'],
},
},
}),
],
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment