originjs / vite-plugin-federation

Module Federation for vite & rollup
Other
2.28k stars 236 forks source link

Uncaught (in promise) TypeError: m.createContext is not a function at #499

Open erkanisuf opened 1 year ago

erkanisuf commented 1 year ago

I have Vite in Host and Remote is with webpack. I am getting this error when I build the project:  __federation_shared_…uter-af1a6369.js:20 Uncaught (in promise) TypeError: m.createContext is not a function at __federation_shared_…-af1a6369.js:20:272

I tested with every Vite plugin version its same error.

My config is like this:
     plugins: [react(),
    federation({
      name: "Test",
      remotes: {
        // @ts-ignore
        COMMON: {
          external: 'https://myurl/remoteEntry.js',
          from: 'webpack',
          format:"var",
          externalType: 'url',
        },
      },
      shared: {...deps},
    })
  ]

I cant see remoteEntry.js here in production mode but in dev mode is there.

Screenshot 2023-09-16 at 22 44 36

Screenshot 2023-09-16 at 22 44 14

yves-v commented 1 year ago

getting the same error, though both host and remotes are Vite

plukconexiom commented 1 year ago

I had a similar issue, and I was able to temporarily work around it by downgrading and specifically setting the version of vite-plugin-federation to the previous version (1.2.3):

"@originjs/vite-plugin-federation": "1.2.3" (no ^ in the version)

SergeyKazarinov commented 1 year ago

I had a similar issue, and I was able to temporarily work around it by downgrading and specifically setting the version of vite-plugin-federation to the previous version (1.2.3):

"@originjs/vite-plugin-federation": "1.2.3" (no ^ in the version)

I also had the same problem, your advice helped me, thank you.

I would like to note that this error does not depend on whether the module is imported or not. The assembly itself does not start due to the fact that federation() settings have been added to vite.config

siner308 commented 1 year ago

I had a similar issue, and I was able to temporarily work around it by downgrading and specifically setting the version of vite-plugin-federation to the previous version (1.2.3):

"@originjs/vite-plugin-federation": "1.2.3" (no ^ in the version)

For this reason, pnpm only works now in ^1.2.3. (yarn, npm is not working)

yousefZw commented 1 year ago

I encountered the same issue with version @originjs/vite-plugin-federation:1.3.1. However, after downgrading to version 1.2.3, the problem was resolved. Thanks @plukconexiom! I spent a significant amount of time attempting to fix this issue. Given this experience, I am reconsidering the use of this framework for production in a large-scale company setting. I am leaning towards transitioning to single-spa instead.

ruleeeer commented 12 months ago

Try checking the status of this issue after upgrading to 1.3.2 ,MauriceAyasse submitted PR(#505) to fix the issue

plukconexiom commented 12 months ago

I won't be confident that the issue is fully fixed as some of the pipeline tests are still failing https://github.com/originjs/vite-plugin-federation/actions/runs/6334057639/job/17203107159 https://github.com/originjs/vite-plugin-federation/actions/runs/6334057639/job/17203107273

aligator commented 11 months ago

In our project it is still failing with 1.3.2 only 1.2.3 works. We use those shared libs:

      shared: {
        'react': {},
        'react-dom': {},
        'notistack': {},
        '@emotion/react': {},
        '@emotion/styled': {},
        '@mui/material': {}
      }
CamachoPt commented 11 months ago

I had the same experience with a material-react-table that needs @emotion/styled, it only works with 1.2.3