originjs/vite-plugin-federation

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

erkanisuf opened this issue · 9 comments

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

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

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 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

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)

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.

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

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': {}
      }

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