hasanayan / craco-module-federation Goto Github PK
View Code? Open in Web Editor NEWEnable Module Federation on your CRA project without ejecting or losing update support of react-scripts
License: MIT License
Enable Module Federation on your CRA project without ejecting or losing update support of react-scripts
License: MIT License
I use create-react-app and craco to use webpack 5 module federation
"react-scripts": "5.0.0-next.47",
"@craco/craco": "^6.4.0",
"craco-module-federation": "^1.1.0",
I want to know why set publicPath to 'auto' in code
At my project,I edit publicPath by craco.config.js
like
module.exports = {
webpack: {
configure: (webpackConfig, { env, paths }) => {
webpackConfig.output = {
...webpackConfig.output,
publicPath: "https://abc.com",
};
return webpackConfig;
},
},
...
and run yarn build
-->"build": "craco build",
but it not works.
when I update it to "build": "PUBLIC_URL=https://abv.com craco build"
,it only works in index.html
, not work in remoteEntry.js
My case I have an react app using CRACO without your craco-module-federation plugin, so my craco.config file looks like:
craco.config
const ModuleFederationPlugin = require("webpack/lib/container/ModuleFederationPlugin");
const deps = require("./package.json").dependencies;
module.exports = {
devServer: {
port: 5004
},
webpack: {
plugins: [
new ModuleFederationPlugin({
name: "reactappcraco",
filename: "remoteEntry.js",
exposes: {
"./web-components": "./src/index.js",
},
shared: {
...deps,
react: {
singleton: true,
requiredVersion: deps.react,
},
"react-dom": {
singleton: true,
requiredVersion: deps["react-dom"],
},
},
})
],
}
}
But, when execute the app in the browser console shows:
However, when I use your plugin this error does not show, I can see that you are using in your plugin the overrideWebpackConfig function, I would like to know why don't show you the ChunkError?.
maybe could be for this
sorry this is not an issue, it is like a question.. ty.. :)
This is a great solution, but I need to add other plug-ins and modify the resolve attribute,how should i do,thanks
Checked my app in IE11 and got Automatic publicPath is not supported in this browser
Also, didn't find a way to rewrite this line, looks that craco runs plugins after webpack.configure
Tried different options from official docs but get this exception earlier than a workaround is executed
Please suggest a way to avoid the error
"@craco/craco": "^6.4.0"
"craco-module-federation": "^1.1.0"
"react-scripts": "^5.0.0"
Win10
IE 11.379.17763.0
We are exploring the possibilities of micro-frontend UIs and require to use Webpack 5 module federation feature and the Module Federation Plugin to achieve this. Came across this plugin when reading on Module Federation with Create React App - can you tell us when is this going to be ready for production use now that react-scripts has launched 5.0.0 officially?
Hey thank you for this project :)
I have a remote app with a craco.config.js
including a
plugins: [
{
plugin: CracoModuleFederation,
},
{
and when I am creating a modulefederation.config.js
const packageJson = require("./package.json")
module.exports = {
name: "BusinessPartnerInterface",
filename: "remoteEntry.js",
exposes: {
"./BusinessPartnerInterface": "./src/bootstrap",
},
shared: packageJson.dependencies,
}
to add the options I am getting an error, when doing yarn start
.
Failed to compile.
Cannot read properties of undefined (reading 'includes')
error Command failed with exit code 1.
Doesn't matter if the modulefederation config file is empty or not.
Any idea what's wrong here?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.