Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module Federation with Library Type Module (ESM) is not working #14111

Closed
saravanan10393 opened this issue Sep 2, 2021 · 15 comments
Closed

Module Federation with Library Type Module (ESM) is not working #14111

saravanan10393 opened this issue Sep 2, 2021 · 15 comments
Labels
enhancement module-federation issues related to module federation webpack-5

Comments

@saravanan10393
Copy link

Bug report

What is the current behavior?
When setting

    new ModuleFederationPlugin({
      name: "app1",
      filename: "remoteEntry.js",
      library: {
        type: "module"
      },
      remotes: {
        app2: "http://127.0.0.1:3002/remoteEntry.js",
      },
      exposes: {
        "./Button": "./src/Button",
      }
    })

in module federation plugin config, the generate remote entry is not exporting anything. Or simply saying, consuming remote is not working.

If the current behavior is a bug, please provide the steps to reproduce.

(https://github.com/saravanan10393/mf-es-module)[Here is the reproduce repo] also (https://gist.github.com/saravanan10393/8185ef0a3e56f9419bbc5a299815aad4)[here is the generated removeEntry of app1.]

What is the expected behavior?
The remoteEntry with ESM target support is needed.

Other relevant information:
webpack version: 5.51.1
Node.js version: 14
Operating System: Mac
Additional tools:

@saravanan10393
Copy link
Author

@sokra any idea on this

@ckken
Copy link

ckken commented Nov 8, 2021

i fine when use es5
image
is work, when use ES2015
image
the library is change~ and load failed

@rakshans1
Copy link

@ckken Try setting library.type to window

    new ModuleFederationPlugin({
      name: 'app',
      filename: 'remoteEntry.js',
      remotes: {},
      exposes: {
        './App': './app.js',
      },
      shared: sharedDependencies,
      library: {
        type: 'window',
        name: 'app',
      },
    }),

@vankop vankop added the module-federation issues related to module federation label Nov 20, 2021
@alexander-akait
Copy link
Member

Fixed #14827

@ckken
Copy link

ckken commented Nov 25, 2021

no work also in 5.64.4 when build bundle

@alexander-akait
Copy link
Member

Please create reproducible test repo

@ckken
Copy link

ckken commented Nov 25, 2021

Are there any simple demos? My cases are more complex

@ckken
Copy link

ckken commented Nov 25, 2021

Maybe I set it wrong

@alexander-akait
Copy link
Member

That is why I asked repo, you do not need to provide the entire project, cut it to reproduce repo

@ckken
Copy link

ckken commented Nov 25, 2021

https://github.com/saravanan10393/mf-es-module it work! thanks

@alexander-akait
Copy link
Member

It works with ESM? So I don't need to check it?

@ckken
Copy link

ckken commented Nov 26, 2021

mmexport1637917597941
work well!

@erickbelfy
Copy link

Is there a place or documentation where I can see all the library types? I'm passing through the same problem above, with same configuration, but I can't find a place where there's a detailed explanation of library types.

@alexander-akait
Copy link
Member

You can open an issue in our docs and we will try to improve

@wibed
Copy link

wibed commented Jul 9, 2023

i still expirience this issue:

issue including reproduction,
module-federation/module-federation-examples#3108

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement module-federation issues related to module federation webpack-5
Projects
None yet
Development

No branches or pull requests

8 participants