Open artem-kurchenko opened 2 years ago
The dist __federation_shared_vue.js
in 'hots' and 'remote' have a slight difference. In host it has not export vue_runtime_esmBundler
because it's not used.
If you add DxButton
in host code, the project can running properly.
import { DxButton } from 'devextreme-vue/button';
@artem-kurchenko
I clone the project, the reason for the problem is that devextreme-vue
import vue
using require (cjs
syntax)
which causes rollup
to add an extra cjs
transformed export when packaging the remote,otherwise devextreme-vue
cannot work.
but host
does not use cjs
syntax to import vue
, so it will not add an extra export
I haven't thought of a good way to deal with the problem yet, unless I add a cjs import on the host side as well
Thank you for the explanation @ruleeeer .
One more thing, do I understand correctly that now there is no way to somehow modify\patch Vite config for a project in vite.config.ts
to overcome this issue?
@artem-kurchenko sry,for the time being, in addition to https://github.com/originjs/vite-plugin-federation/issues/227#issuecomment-1207167441 I did not think of a better way
I've come across this issue too for other packages. What is the reason for this and is there any solve? I see this is marked as a bug but haven't received any feedback in a while.
i have the same error, comment out the share statement to return to normal
@ruleeeer, do I understand correctly that if there is a commonjs import of "react" somewhere in remote app then remote app generates additional import in the output?
I've encountered an issue where my remote app uses zustand as a state manager, but there is a commonjs import (require("react");
in zustand source files and I'm getting this line in the output:
import { r as reactExports, g as getDefaultExportFromCjs } from './__federation_shared_react.js';
As a result, host app has to load react two times (I can see in Network tab that '/__federation_shared_react.js' is repeated twice) and, moreover, this reactExports
is undefined.
There is an error in the console Error: Cannot read property useRef of undefined
.
Versions
Reproduction
Example: https://github.com/artem-kurchenko/module-federation-devextreme-vue
Steps to reproduce
Open terminals for both host and remote directory and run on both:
open a website for host url at http://localhost:5000
What is Expected?
The page should display a Button
What is actually happening?
The page throws the "Cannot read properties of undefined (reading 'default')" error
Additional information:
Having checked the code I see that
vue_runtime_esmBundler
is always undefined in the very first importThen, this logic affects the code of DxButton
Could you please help us understand whether it a module format (CommonJS) or some settings are missing for this particular case.