originjs / vite-plugin-federation

Module Federation for vite & rollup
Other
2.25k stars 234 forks source link

Having an issue when host is webpack #301

Open Moumenh opened 1 year ago

Moumenh commented 1 year ago

Versions

Reproduction

my remote vite.config export default defineConfig({ plugins: [ react(), federation({ name: 'external', filename: 'remoteEntry.js', exposes: { './ui': './src/Button.tsx' }, shared: ["@emotion/react", "@emotion/styled", "@mui/material", "react", "react-dom"] }) ], build: { target: 'esnext', cssCodeSplit: false, minify: false, } })

when my host is using vite it does work but switching to webpack host with this config

`const HtmlWebPackPlugin = require("html-webpack-plugin"); const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");

const deps = require("./package.json").dependencies; module.exports = { output: { publicPath: "http://localhost:3020/", },

resolve: { extensions: [".tsx", ".ts", ".jsx", ".js", ".json"], },

devServer: { port: 3020, historyApiFallback: true, },

module: { rules: [ { test: /.m?js/, type: "javascript/auto", resolve: { fullySpecified: false, }, }, { test: /.(css|s[ac]ss)$/i, use: ["style-loader", "css-loader", "postcss-loader"], }, { test: /.(ts|tsx|js|jsx)$/, exclude: /node_modules/, use: { loader: "babel-loader", }, }, ], },

plugins: [ new ModuleFederationPlugin({ name: "host", filename: "remoteEntry.js", remotes: { external: "external@http://127.0.0.1:5001/assets/remoteEntry.js", }, shared: { ...deps, react: { singleton: true, requiredVersion: deps.react, }, "react-dom": { singleton: true, requiredVersion: deps["react-dom"], }, }, }), new HtmlWebPackPlugin({ template: "./src/index.html", }), ], };`

it does not work

having this error image

do I need to change something with my webpack config or It is a bug in this release ?

rodoabad commented 1 year ago

It looks like it's a bug! Would like to know more. Thanks, maintainers!

Kami-Vourdalak commented 1 year ago

same here

ruleeeer commented 1 year ago

Can you give me the reproduced repo address? I have no idea what happened.