Skip to content

How can I use mf in react with 「externals」? #3467

Open
@qiujie8092916

Description

@qiujie8092916

Hi, I am using module federation to build a application

my remote webpack conf:

// remote webpack
shared: {
  ...deps,
  react: {
    singleton: true,
    import: false,
    eager: false,
    version: '0',
    requiredVersion: "*"
  },
  'react-dom': {
    singleton: true,
    import: false,
    eager: false,
    version: '0',
    requiredVersion: "*"
  },
},

my host webpack conf:

// host webpack
shared: {
  react: {
    eager: true,
    singleton: true,
    requiredVersion: "16.14.0"
  },
  'react-dom': {
    eager: true,
    singleton: true,
    requiredVersion: "16.14.0"
  }
},
//...
externals: {
  react: 'React',
  'react-dom': 'ReactDOM'
},

And I use <script> to import react and react-dom from public/index.html

I got an error:
image

what should I do?
thanks for your help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions