hasanayan / craco-module-federation

Enable Module Federation on your CRA project without ejecting or losing update support of react-scripts
MIT License
51 stars 19 forks source link

Error on yarn start #3

Closed koengsen closed 2 years ago

koengsen commented 2 years ago

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?

BrunoSilvaDF commented 2 years ago

Hi there! same error here :(

Just used CRA, installed CRACO and craco-module-federation. On craco start get the same error:

TypeError: Cannot read properties of undefined (reading 'ModuleFederationPlugin')
    at Object.overrideWebpackConfig (D:\Work\microfrontends-craco\app1\node_modules\craco-module-federation\index.js:43:31)
    at overrideWebpack (D:\Work\microfrontends-craco\app1\node_modules\@craco\craco\lib\features\plugins.js:42:40)       
    at D:\Work\microfrontends-craco\app1\node_modules\@craco\craco\lib\features\plugins.js:64:29
    at Array.forEach (<anonymous>)
    at applyWebpackConfigPlugins (D:\Work\microfrontends-craco\app1\node_modules\@craco\craco\lib\features\plugins.js:63:29)
    at mergeWebpackConfig (D:\Work\microfrontends-craco\app1\node_modules\@craco\craco\lib\features\webpack\merge-webpack-config.js:110:30)
    at overrideWebpackDev (D:\Work\microfrontends-craco\app1\node_modules\@craco\craco\lib\features\webpack\override.js:11:36)
    at D:\Work\microfrontends-craco\app1\node_modules\@craco\craco\scripts\start.js:27:5

craco.config.js

const cracoModuleFederation = require('craco-module-federation')
module.exports = {
  devServer: {
    port: 8081,
  },
  plugins: [
    {
      plugin: cracoModuleFederation,
    },
  ],
}

modulefederation.config.js

const deps = require('./package.json').dependencies

module.exprots = {
  name: 'app1',
  filename: 'remoteEntry.js',
  exposes: {
    './App1': './src/bootstrap',
  },
  shared: deps,
}
victorsoares96 commented 2 years ago

Hi there! same error here :(

Just used CRA, installed CRACO and craco-module-federation. On craco start get the same error:

TypeError: Cannot read properties of undefined (reading 'ModuleFederationPlugin')
    at Object.overrideWebpackConfig (D:\Work\microfrontends-craco\app1\node_modules\craco-module-federation\index.js:43:31)
    at overrideWebpack (D:\Work\microfrontends-craco\app1\node_modules\@craco\craco\lib\features\plugins.js:42:40)       
    at D:\Work\microfrontends-craco\app1\node_modules\@craco\craco\lib\features\plugins.js:64:29
    at Array.forEach (<anonymous>)
    at applyWebpackConfigPlugins (D:\Work\microfrontends-craco\app1\node_modules\@craco\craco\lib\features\plugins.js:63:29)
    at mergeWebpackConfig (D:\Work\microfrontends-craco\app1\node_modules\@craco\craco\lib\features\webpack\merge-webpack-config.js:110:30)
    at overrideWebpackDev (D:\Work\microfrontends-craco\app1\node_modules\@craco\craco\lib\features\webpack\override.js:11:36)
    at D:\Work\microfrontends-craco\app1\node_modules\@craco\craco\scripts\start.js:27:5

craco.config.js

const cracoModuleFederation = require('craco-module-federation')
module.exports = {
  devServer: {
    port: 8081,
  },
  plugins: [
    {
      plugin: cracoModuleFederation,
    },
  ],
}

modulefederation.config.js

const deps = require('./package.json').dependencies

module.exprots = {
  name: 'app1',
  filename: 'remoteEntry.js',
  exposes: {
    './App1': './src/bootstrap',
  },
  shared: deps,
}

Did you update react-scripts to version 5?