Search code examples
vue.jswebpack

Uncaught Error: Shared module is not available for eager consumption: webpack/sharing/consume/default/vue/vue module-federation Vue3-in-Vue2


problem: how can Vue3 component used in Vue2 app,with module-federation.someone need it,somewhow.

error: Uncaught Error: Shared module is not available for eager consumption: webpack/sharing/consume/default/vue/vue

hope: Vue3 component can be used in Vue2 app,with module-federation.


Solution

  • public/index.html:- add script tag

    <!DOCTYPE html>
    <html lang="">
    
    <head>
      <meta charset="utf-8">
      <meta name="referrer" content="no-referrer">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width,initial-scale=1.0">
      <link rel="icon" id="faviconLink" href="static/img/favicon.ico">
        <script src="http://localhost:3000/assets/remoteEntry-app3.js"></script>
    </head>
    
      <body>
        <div id="app"></div>
      </body>
    </html>