vite-plugin-federation icon indicating copy to clipboard operation
vite-plugin-federation copied to clipboard

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

Open erkanisuf opened this issue 2 years ago • 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

erkanisuf avatar Sep 16 '23 20:09 erkanisuf

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

yves-v avatar Sep 18 '23 10:09 yves-v

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)

plukconexiom avatar Sep 19 '23 00:09 plukconexiom

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

SergeyKazarinov avatar Sep 19 '23 10:09 SergeyKazarinov

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)

siner308 avatar Sep 20 '23 06:09 siner308

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.

yousefZw avatar Sep 25 '23 20:09 yousefZw

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

Jiannan-dev avatar Sep 28 '23 09:09 Jiannan-dev

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

plukconexiom avatar Sep 28 '23 16:09 plukconexiom

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

aligator avatar Oct 12 '23 13:10 aligator

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

CamachoPt avatar Oct 26 '23 21:10 CamachoPt