vite-plugin-federation
vite-plugin-federation copied to clipboard
If I use modules with commonjs, generates strange imports
Hello. If in my remote project used node modules with commonjs, it generates expose js with imports like
const {default:React$1,c:commonjsGlobal,r:react,g:getDefaultExportFromCjs} = await importShared('react')
In my host project, react don't exports variables like r:react
and g:getDefaultExportFromCjs
. So, my remote module became incompatible with my host module. What I can do?
I think this is because the product of building cjs with different build tools is inconsistent, and it's hard to get cjs to form a completely consistent output with some configuration, so I recommend using ESM in preference
Or try to give me a reproduction of the repository, it is also possible that the bug is causing the problem
I use react components from npm, and vite detects them as cjs. As I understand, many react components from npm is commonjs.
https://github.com/ioBroker/ioBroker.vis-widget-thermostat