Hi,
In my remote project, I'm installing packages from a private registry (Azure artifacts), together with regular packages from npmjs.
remote/vite.config
import { federation } from '@module-federation/vite';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import { dependencies } from './package.json';
export default defineConfig(({ mode }) => {
return {
server: {
fs: {
allow: ['.', '../shared']
}
},
build: {
target: 'chrome89'
},
plugins: [
federation({
filename: 'remoteEntry.js',
name: 'remote',
exposes: {
'./remote-app': './src/App.jsx'
},
remotes: {},
shared: {
react: {
requiredVersion: dependencies.react,
singleton: true
}
}
}),
react()
]
};
});
When I run the app in isolation, nothing is rendered in the browser and there's no build error either.
However, if I remove the shared dependencies object, it runs in isolation, but when importing it from the Host, there's an error in the browser, because there's more than one React instance:
Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons (...)
Thanks for your help.
Hi,
In my remote project, I'm installing packages from a private registry (Azure artifacts), together with regular packages from npmjs.
remote/vite.config
When I run the app in isolation, nothing is rendered in the browser and there's no build error either.
However, if I remove the shared dependencies object, it runs in isolation, but when importing it from the Host, there's an error in the browser, because there's more than one React instance:
Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons (...)Thanks for your help.