-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: shared-directory #4300
feat: shared-directory #4300
Conversation
Workflow status is success ✅ |
…viteViteRemote/localSharedImportMap.js
Workflow status is success ✅ |
Workflow status is success ✅ |
Workflow status is success ✅ |
Thanks for the example, it is helpful. There is my version import type { FederationRuntimePlugin } from '@module-federation/enhanced/runtime';
type LoadEntryParams = Parameters<NonNullable<FederationRuntimePlugin['loadEntry']>>[0];
type RemoteEntryExports = Awaited<ReturnType<NonNullable<FederationRuntimePlugin['loadEntry']>>>;
const modules = import.meta.glob(['./*.ts', '!./plugin.ts']) as Record<string, () => Promise<Record<string, any>>>;
export default function () {
return {
name: 'delegate-modules-plugin',
loadEntry({ remoteInfo }: LoadEntryParams) {
if (remoteInfo.name === 'shared') {
const exports: RemoteEntryExports = {
init() {},
get(id: string) {
return () => modules[id + '.ts']();
}
};
return exports;
}
}
};
} Issues
const modules = import.meta.glob(['./*.ts', '!./plugin.ts']) as Record<string, () => Promise<Record<string, any>>>;
get(id: string) {
return async () => {
const result = await modules[id + '.ts']();
return {
...result,
__esModule: true
};
};
} |
This is same as how webpack would do it as far as I remember. |
module-federation/vite#131
An alternative solution for the functionality of
shared: ["./shared/xxxx.js"]
.